d4c357d0deaa35d322e740f3999addf52dc0c6cf
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebCoreSupport / WebChromeClient.cpp
1 /*
2  * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
3  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24  * THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include "config.h"
28 #include "WebChromeClient.h"
29
30 #include "DrawingArea.h"
31 #include "InjectedBundleNavigationAction.h"
32 #include "InjectedBundleUserMessageCoders.h"
33 #include "WebContextMenu.h"
34 #include "WebCoreArgumentCoders.h"
35 #include "WebFrame.h"
36 #include "WebFrameLoaderClient.h"
37 #include "WebOpenPanelParameters.h"
38 #include "WebOpenPanelResultListener.h"
39 #include "WebPage.h"
40 #include "WebPageCreationParameters.h"
41 #include "WebPageProxyMessages.h"
42 #include "WebPopupMenu.h"
43 #include "WebPreferencesStore.h"
44 #include "WebProcess.h"
45 #include "WebProcessProxyMessageKinds.h"
46 #include "WebSearchPopupMenu.h"
47 #include <WebCore/DatabaseTracker.h>
48 #include <WebCore/FileChooser.h>
49 #include <WebCore/Frame.h>
50 #include <WebCore/FrameLoader.h>
51 #include <WebCore/FrameView.h>
52 #include <WebCore/HTMLNames.h>
53 #include <WebCore/HTMLPlugInImageElement.h>
54 #include <WebCore/NotImplemented.h>
55 #include <WebCore/Page.h>
56 #include <WebCore/SecurityOrigin.h>
57
58 using namespace WebCore;
59 using namespace HTMLNames;
60
61 namespace WebKit {
62
63 static double area(WebFrame* frame)
64 {
65     IntSize size = frame->visibleContentBoundsExcludingScrollbars().size();
66     return static_cast<double>(size.height()) * size.width();
67 }
68
69
70 static WebFrame* findLargestFrameInFrameSet(WebPage* page)
71 {
72     // Approximate what a user could consider a default target frame for application menu operations.
73
74     WebFrame* mainFrame = page->mainFrame();
75     if (!mainFrame->isFrameSet())
76         return 0;
77
78     WebFrame* largestSoFar = 0;
79
80     RefPtr<ImmutableArray> frameChildren = mainFrame->childFrames();
81     size_t count = frameChildren->size();
82     for (size_t i = 0; i < count; ++i) {
83         WebFrame* childFrame = frameChildren->at<WebFrame>(i);
84         if (!largestSoFar || area(childFrame) > area(largestSoFar))
85             largestSoFar = childFrame;
86     }
87
88     return largestSoFar;
89 }
90
91 void WebChromeClient::chromeDestroyed()
92 {
93     delete this;
94 }
95
96 void WebChromeClient::setWindowRect(const FloatRect& windowFrame)
97 {
98     m_page->send(Messages::WebPageProxy::SetWindowFrame(windowFrame));
99 }
100
101 FloatRect WebChromeClient::windowRect()
102 {
103     FloatRect newWindowFrame;
104
105     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetWindowFrame(), Messages::WebPageProxy::GetWindowFrame::Reply(newWindowFrame), m_page->pageID()))
106         return FloatRect();
107
108     return newWindowFrame;
109 }
110
111 FloatRect WebChromeClient::pageRect()
112 {
113     return FloatRect(FloatPoint(), m_page->size());
114 }
115
116 float WebChromeClient::scaleFactor()
117 {
118     notImplemented();
119     return 1.0;
120 }
121
122 void WebChromeClient::focus()
123 {
124     notImplemented();
125 }
126
127 void WebChromeClient::unfocus()
128 {
129     notImplemented();
130 }
131
132 bool WebChromeClient::canTakeFocus(FocusDirection)
133 {
134     notImplemented();
135     return true;
136 }
137
138 void WebChromeClient::takeFocus(FocusDirection direction)
139 {
140     m_page->send(Messages::WebPageProxy::TakeFocus(direction == FocusDirectionForward ? true : false));
141 }
142
143 void WebChromeClient::focusedNodeChanged(Node*)
144 {
145     notImplemented();
146 }
147
148 void WebChromeClient::focusedFrameChanged(Frame* frame)
149 {
150     WebFrame* webFrame = frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : 0;
151
152     WebProcess::shared().connection()->send(Messages::WebPageProxy::FocusedFrameChanged(webFrame ? webFrame->frameID() : 0), m_page->pageID());
153 }
154
155 Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures& windowFeatures, const NavigationAction& navigationAction)
156 {
157     uint32_t modifiers = static_cast<uint32_t>(InjectedBundleNavigationAction::modifiersForNavigationAction(navigationAction));
158     int32_t mouseButton = static_cast<int32_t>(InjectedBundleNavigationAction::mouseButtonForNavigationAction(navigationAction));
159
160     uint64_t newPageID = 0;
161     WebPageCreationParameters parameters;
162     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::CreateNewPage(windowFeatures, modifiers, mouseButton), Messages::WebPageProxy::CreateNewPage::Reply(newPageID, parameters), m_page->pageID()))
163         return 0;
164
165     if (!newPageID)
166         return 0;
167
168     WebProcess::shared().createWebPage(newPageID, parameters);
169     return WebProcess::shared().webPage(newPageID)->corePage();
170 }
171
172 void WebChromeClient::show()
173 {
174     m_page->show();
175 }
176
177 bool WebChromeClient::canRunModal()
178 {
179     return m_page->canRunModal();
180 }
181
182 void WebChromeClient::runModal()
183 {
184     m_page->runModal();
185 }
186
187 void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible)
188 {
189     m_page->send(Messages::WebPageProxy::SetToolbarsAreVisible(toolbarsAreVisible));
190 }
191
192 bool WebChromeClient::toolbarsVisible()
193 {
194     bool toolbarsAreVisible = true;
195     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetToolbarsAreVisible(), Messages::WebPageProxy::GetToolbarsAreVisible::Reply(toolbarsAreVisible), m_page->pageID()))
196         return true;
197
198     return toolbarsAreVisible;
199 }
200
201 void WebChromeClient::setStatusbarVisible(bool statusBarIsVisible)
202 {
203     m_page->send(Messages::WebPageProxy::SetStatusBarIsVisible(statusBarIsVisible));
204 }
205
206 bool WebChromeClient::statusbarVisible()
207 {
208     bool statusBarIsVisible = true;
209     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetStatusBarIsVisible(), Messages::WebPageProxy::GetStatusBarIsVisible::Reply(statusBarIsVisible), m_page->pageID()))
210         return true;
211
212     return statusBarIsVisible;
213 }
214
215 void WebChromeClient::setScrollbarsVisible(bool)
216 {
217     notImplemented();
218 }
219
220 bool WebChromeClient::scrollbarsVisible()
221 {
222     notImplemented();
223     return true;
224 }
225
226 void WebChromeClient::setMenubarVisible(bool menuBarVisible)
227 {
228     m_page->send(Messages::WebPageProxy::SetMenuBarIsVisible(menuBarVisible));
229 }
230
231 bool WebChromeClient::menubarVisible()
232 {
233     bool menuBarIsVisible = true;
234     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetMenuBarIsVisible(), Messages::WebPageProxy::GetMenuBarIsVisible::Reply(menuBarIsVisible), m_page->pageID()))
235         return true;
236
237     return menuBarIsVisible;
238 }
239
240 void WebChromeClient::setResizable(bool resizable)
241 {
242     m_page->send(Messages::WebPageProxy::SetIsResizable(resizable));
243 }
244
245 void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID)
246 {
247     // Notify the bundle client.
248     m_page->injectedBundleUIClient().willAddMessageToConsole(m_page, message, lineNumber);
249
250     notImplemented();
251 }
252
253 bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
254 {
255     return m_page->canRunBeforeUnloadConfirmPanel();
256 }
257
258 bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
259 {
260     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
261
262     bool shouldClose = false;
263     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID()))
264         return false;
265
266     return shouldClose;
267 }
268
269 void WebChromeClient::closeWindowSoon()
270 {
271     // FIXME: This code assumes that the client will respond to a close page
272     // message by actually closing the page. Safari does this, but there is
273     // no guarantee that other applications will, which will leave this page
274     // half detached. This approach is an inherent limitation making parts of
275     // a close execute synchronously as part of window.close, but other parts
276     // later on.
277
278     m_page->corePage()->setGroupName(String());
279
280     if (WebFrame* frame = m_page->mainFrame()) {
281         if (Frame* coreFrame = frame->coreFrame())
282             coreFrame->loader()->stopForUserCancel();
283     }
284
285     m_page->sendClose();
286 }
287
288 void WebChromeClient::runJavaScriptAlert(Frame* frame, const String& alertText)
289 {
290     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
291
292     // Notify the bundle client.
293     m_page->injectedBundleUIClient().willRunJavaScriptAlert(m_page, alertText, webFrame);
294
295     WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID());
296 }
297
298 bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message)
299 {
300     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
301
302     // Notify the bundle client.
303     m_page->injectedBundleUIClient().willRunJavaScriptConfirm(m_page, message, webFrame);
304
305     bool result = false;
306     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID()))
307         return false;
308
309     return result;
310 }
311
312 bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
313 {
314     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
315
316     // Notify the bundle client.
317     m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame);
318
319     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID()))
320         return false;
321
322     return !result.isNull();
323 }
324
325 void WebChromeClient::setStatusbarText(const String& statusbarText)
326 {
327     // Notify the bundle client.
328     m_page->injectedBundleUIClient().willSetStatusbarText(m_page, statusbarText);
329
330     m_page->send(Messages::WebPageProxy::SetStatusText(statusbarText));
331 }
332
333 bool WebChromeClient::shouldInterruptJavaScript()
334 {
335     notImplemented();
336     return false;
337 }
338
339 KeyboardUIMode WebChromeClient::keyboardUIMode()
340 {
341     return m_page->keyboardUIMode();
342 }
343
344 IntRect WebChromeClient::windowResizerRect() const
345 {
346     return m_page->windowResizerRect();
347 }
348
349 void WebChromeClient::invalidateWindow(const IntRect&, bool)
350 {
351     // Do nothing here, there's no concept of invalidating the window in the web process.
352 }
353
354 void WebChromeClient::invalidateContentsAndWindow(const IntRect& rect, bool)
355 {
356     if (m_page->corePage()->mainFrame()->document()->printing())
357         return;
358     m_page->drawingArea()->setNeedsDisplay(rect);
359 }
360
361 void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool)
362 {
363     if (m_page->corePage()->mainFrame()->document()->printing())
364         return;
365     m_page->pageDidScroll();
366     m_page->drawingArea()->setNeedsDisplay(rect);
367 }
368
369 void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollRect, const IntRect& clipRect)
370 {
371     m_page->pageDidScroll();
372     m_page->drawingArea()->scroll(intersection(scrollRect, clipRect), scrollOffset);
373 }
374
375 #if ENABLE(TILED_BACKING_STORE)
376 void WebChromeClient::delegatedScrollRequested(const IntSize& scrollOffset)
377 {
378     m_page->pageDidRequestScroll(scrollOffset);
379 }
380 #endif
381
382 IntPoint WebChromeClient::screenToWindow(const IntPoint&) const
383 {
384     notImplemented();
385     return IntPoint();
386 }
387
388 IntRect WebChromeClient::windowToScreen(const IntRect&) const
389 {
390     notImplemented();
391     return IntRect();
392 }
393
394 PlatformPageClient WebChromeClient::platformPageClient() const
395 {
396     notImplemented();
397     return 0;
398 }
399
400 void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) const
401 {
402 #if PLATFORM(QT)
403 #if ENABLE(TILED_BACKING_STORE)
404     if (frame->page()->mainFrame() == frame)
405         m_page->resizeToContentsIfNeeded();
406 #endif
407
408     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
409
410     if (!m_page->mainFrame() || m_page->mainFrame() != webFrame)
411         return;
412
413     m_page->send(Messages::WebPageProxy::DidChangeContentsSize(size));
414 #endif
415
416     WebFrame* largestFrame = findLargestFrameInFrameSet(m_page);
417     if (largestFrame != m_cachedFrameSetLargestFrame.get()) {
418         m_cachedFrameSetLargestFrame = largestFrame;
419         m_page->send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0));
420     }
421
422     if (frame->page()->mainFrame() != frame)
423         return;
424     FrameView* frameView = frame->view();
425     if (!frameView)
426         return;
427
428     bool hasHorizontalScrollbar = frameView->horizontalScrollbar();
429     bool hasVerticalScrollbar = frameView->verticalScrollbar();
430
431     if (hasHorizontalScrollbar != m_cachedMainFrameHasHorizontalScrollbar || hasVerticalScrollbar != m_cachedMainFrameHasVerticalScrollbar) {
432         m_page->send(Messages::WebPageProxy::DidChangeScrollbarsForMainFrame(hasHorizontalScrollbar, hasVerticalScrollbar));
433         
434         m_cachedMainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
435         m_cachedMainFrameHasVerticalScrollbar = hasVerticalScrollbar;
436     }
437 }
438
439 void WebChromeClient::scrollRectIntoView(const IntRect&, const ScrollView*) const
440 {
441     notImplemented();
442 }
443
444 bool WebChromeClient::shouldMissingPluginMessageBeButton() const
445 {
446     // FIXME: <rdar://problem/8794397> We should only return true when there is a 
447     // missingPluginButtonClicked callback defined on the Page UI client.
448     return true;
449 }
450     
451 void WebChromeClient::missingPluginButtonClicked(Element* element) const
452 {
453     ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag));
454
455     HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element);
456
457     m_page->send(Messages::WebPageProxy::MissingPluginButtonClicked(pluginElement->serviceType(), pluginElement->url(), pluginElement->getAttribute(pluginspageAttr)));
458 }
459
460 void WebChromeClient::scrollbarsModeDidChange() const
461 {
462     notImplemented();
463 }
464
465 void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult, unsigned modifierFlags)
466 {
467     RefPtr<APIObject> userData;
468
469     // Notify the bundle client.
470     m_page->injectedBundleUIClient().mouseDidMoveOverElement(m_page, hitTestResult, static_cast<WebEvent::Modifiers>(modifierFlags), userData);
471
472     // Notify the UIProcess.
473     m_page->send(Messages::WebPageProxy::MouseDidMoveOverElement(modifierFlags, InjectedBundleUserMessageEncoder(userData.get())));
474 }
475
476 void WebChromeClient::setToolTip(const String& toolTip, TextDirection)
477 {
478     // Only send a tool tip to the WebProcess if it has changed since the last time this function was called.
479
480     if (toolTip == m_cachedToolTip)
481         return;
482     m_cachedToolTip = toolTip;
483
484     m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip));
485 }
486
487 void WebChromeClient::print(Frame* frame)
488 {
489     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
490     m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply());
491 }
492
493 #if ENABLE(DATABASE)
494 void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName)
495 {
496     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
497     SecurityOrigin* origin = frame->document()->securityOrigin();
498
499     DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseName, origin);
500     uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin);
501     uint64_t newQuota = 0;
502     WebProcess::shared().connection()->sendSync(
503         Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, details.currentUsage(), details.expectedUsage()),
504         Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID());
505
506     DatabaseTracker::tracker().setQuota(origin, newQuota);
507 }
508 #endif
509
510
511 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
512 void WebChromeClient::reachedMaxAppCacheSize(int64_t)
513 {
514     notImplemented();
515 }
516
517 void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*)
518 {
519     notImplemented();
520 }
521 #endif
522
523 #if ENABLE(DASHBOARD_SUPPORT)
524 void WebChromeClient::dashboardRegionsChanged()
525 {
526     notImplemented();
527 }
528 #endif
529
530 void WebChromeClient::populateVisitedLinks()
531 {
532 }
533
534 FloatRect WebChromeClient::customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect)
535 {
536     notImplemented();
537     return FloatRect();
538 }
539
540 void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
541                                   bool behindText, bool entireLine)
542 {
543     notImplemented();
544 }
545
546 bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
547 {
548     notImplemented();
549     return false;
550 }
551
552 String WebChromeClient::generateReplacementFile(const String& path)
553 {
554     notImplemented();
555     return String();
556 }
557
558 bool WebChromeClient::paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize, 
559                                            ScrollbarControlState, ScrollbarPart pressedPart, bool vertical,
560                                            float value, float proportion, ScrollbarControlPartMask)
561 {
562     notImplemented();
563     return false;
564 }
565
566 bool WebChromeClient::paintCustomScrollCorner(GraphicsContext*, const FloatRect&)
567 {
568     notImplemented();
569     return false;
570 }
571
572 bool WebChromeClient::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
573 {
574     if (!m_page->injectedBundleUIClient().shouldPaintCustomOverhangArea())
575         return false;
576
577     m_page->injectedBundleUIClient().paintCustomOverhangArea(m_page, context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
578     return true;
579 }
580
581 void WebChromeClient::requestGeolocationPermissionForFrame(Frame*, Geolocation*)
582 {
583     notImplemented();
584 }
585
586 void WebChromeClient::cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*)
587 {
588     notImplemented();
589 }
590
591 void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
592 {
593     if (m_page->activeOpenPanelResultListener())
594         return;
595
596     RefPtr<FileChooser> fileChooser = prpFileChooser;
597
598     m_page->setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser.get()));
599     
600     WebOpenPanelParameters::Data parameters;
601     parameters.allowMultipleFiles = fileChooser->allowsMultipleFiles();
602 #if ENABLE(DIRECTORY_UPLOAD)
603     parameters.allowsDirectoryUpload = fileChooser->allowsDirectoryUpload();
604 #else
605     parameters.allowsDirectoryUpload = false;
606 #endif
607     parameters.acceptTypes = fileChooser->acceptTypes();
608     parameters.filenames = fileChooser->filenames();
609
610     m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), parameters));
611 }
612
613 void WebChromeClient::chooseIconForFiles(const Vector<String>&, FileChooser*)
614 {
615     notImplemented();
616 }
617
618 void WebChromeClient::setCursor(const WebCore::Cursor& cursor)
619 {
620 #if USE(LAZY_NATIVE_CURSOR)
621     m_page->send(Messages::WebPageProxy::SetCursor(cursor));
622 #endif
623 }
624
625 void WebChromeClient::formStateDidChange(const Node*)
626 {
627     notImplemented();
628 }
629
630 void WebChromeClient::formDidFocus(const Node*)
631
632     notImplemented();
633 }
634
635 void WebChromeClient::formDidBlur(const Node*)
636 {
637     notImplemented();
638 }
639
640 bool WebChromeClient::selectItemWritingDirectionIsNatural()
641 {
642     return false;
643 }
644
645 bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
646 {
647     return true;
648 }
649
650 PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
651 {
652     return WebPopupMenu::create(m_page, client);
653 }
654
655 PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
656 {
657     return WebSearchPopupMenu::create(m_page, client);
658 }
659
660 #if ENABLE(CONTEXT_MENUS)
661 void WebChromeClient::showContextMenu()
662 {
663     m_page->contextMenu()->show();
664 }
665 #endif
666
667 #if USE(ACCELERATED_COMPOSITING)
668 void WebChromeClient::attachRootGraphicsLayer(Frame*, GraphicsLayer* layer)
669 {
670     if (layer)
671         m_page->enterAcceleratedCompositingMode(layer);
672     else
673         m_page->exitAcceleratedCompositingMode();
674 }
675
676 void WebChromeClient::setNeedsOneShotDrawingSynchronization()
677 {
678     notImplemented();
679 }
680
681 void WebChromeClient::scheduleCompositingLayerSync()
682 {
683     if (m_page->drawingArea())
684         m_page->drawingArea()->scheduleCompositingLayerSync();
685 }
686
687 #endif
688
689 #if ENABLE(NOTIFICATIONS)
690 WebCore::NotificationPresenter* WebChromeClient::notificationPresenter() const
691 {
692     return 0;
693 }
694 #endif
695
696 #if ENABLE(TOUCH_EVENTS)
697 void WebChromeClient::needTouchEvents(bool)
698 {
699 }
700 #endif
701
702 #if PLATFORM(WIN)
703 void WebChromeClient::setLastSetCursorToCurrentCursor()
704 {
705 }
706 #endif
707
708 void WebChromeClient::dispatchViewportDataDidChange(const ViewportArguments& args) const
709 {
710     m_page->send(Messages::WebPageProxy::DidChangeViewportData(args));
711 }
712
713 void WebChromeClient::didCompleteRubberBandForMainFrame(const IntSize& initialOverhang) const
714 {
715     m_page->send(Messages::WebPageProxy::DidCompleteRubberBandForMainFrame(initialOverhang));
716 }
717
718 } // namespace WebKit