• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "WebFullScreenManager.h"
38 #include "WebOpenPanelParameters.h"
39 #include "WebOpenPanelResultListener.h"
40 #include "WebPage.h"
41 #include "WebPageCreationParameters.h"
42 #include "WebPageProxyMessages.h"
43 #include "WebPopupMenu.h"
44 #include "WebPreferencesStore.h"
45 #include "WebProcess.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/Icon.h>
55 #include <WebCore/NotImplemented.h>
56 #include <WebCore/Page.h>
57 #include <WebCore/SecurityOrigin.h>
58 
59 using namespace WebCore;
60 using namespace HTMLNames;
61 
62 namespace WebKit {
63 
area(WebFrame * frame)64 static double area(WebFrame* frame)
65 {
66     IntSize size = frame->visibleContentBoundsExcludingScrollbars().size();
67     return static_cast<double>(size.height()) * size.width();
68 }
69 
70 
findLargestFrameInFrameSet(WebPage * page)71 static WebFrame* findLargestFrameInFrameSet(WebPage* page)
72 {
73     // Approximate what a user could consider a default target frame for application menu operations.
74 
75     WebFrame* mainFrame = page->mainFrame();
76     if (!mainFrame->isFrameSet())
77         return 0;
78 
79     WebFrame* largestSoFar = 0;
80 
81     RefPtr<ImmutableArray> frameChildren = mainFrame->childFrames();
82     size_t count = frameChildren->size();
83     for (size_t i = 0; i < count; ++i) {
84         WebFrame* childFrame = frameChildren->at<WebFrame>(i);
85         if (!largestSoFar || area(childFrame) > area(largestSoFar))
86             largestSoFar = childFrame;
87     }
88 
89     return largestSoFar;
90 }
91 
chromeDestroyed()92 void WebChromeClient::chromeDestroyed()
93 {
94     delete this;
95 }
96 
setWindowRect(const FloatRect & windowFrame)97 void WebChromeClient::setWindowRect(const FloatRect& windowFrame)
98 {
99     m_page->send(Messages::WebPageProxy::SetWindowFrame(windowFrame));
100 }
101 
windowRect()102 FloatRect WebChromeClient::windowRect()
103 {
104     FloatRect newWindowFrame;
105 
106     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetWindowFrame(), Messages::WebPageProxy::GetWindowFrame::Reply(newWindowFrame), m_page->pageID()))
107         return FloatRect();
108 
109     return newWindowFrame;
110 }
111 
pageRect()112 FloatRect WebChromeClient::pageRect()
113 {
114     return FloatRect(FloatPoint(), m_page->size());
115 }
116 
scaleFactor()117 float WebChromeClient::scaleFactor()
118 {
119     return m_page->userSpaceScaleFactor();
120 }
121 
focus()122 void WebChromeClient::focus()
123 {
124     m_page->send(Messages::WebPageProxy::SetFocus(true));
125 }
126 
unfocus()127 void WebChromeClient::unfocus()
128 {
129     m_page->send(Messages::WebPageProxy::SetFocus(false));
130 }
131 
canTakeFocus(FocusDirection)132 bool WebChromeClient::canTakeFocus(FocusDirection)
133 {
134     notImplemented();
135     return true;
136 }
137 
takeFocus(FocusDirection direction)138 void WebChromeClient::takeFocus(FocusDirection direction)
139 {
140     m_page->send(Messages::WebPageProxy::TakeFocus(direction));
141 }
142 
focusedNodeChanged(Node *)143 void WebChromeClient::focusedNodeChanged(Node*)
144 {
145     notImplemented();
146 }
147 
focusedFrameChanged(Frame * frame)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 
createWindow(Frame *,const FrameLoadRequest &,const WindowFeatures & windowFeatures,const NavigationAction & navigationAction)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 
show()172 void WebChromeClient::show()
173 {
174     m_page->show();
175 }
176 
canRunModal()177 bool WebChromeClient::canRunModal()
178 {
179     return m_page->canRunModal();
180 }
181 
runModal()182 void WebChromeClient::runModal()
183 {
184     m_page->runModal();
185 }
186 
setToolbarsVisible(bool toolbarsAreVisible)187 void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible)
188 {
189     m_page->send(Messages::WebPageProxy::SetToolbarsAreVisible(toolbarsAreVisible));
190 }
191 
toolbarsVisible()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 
setStatusbarVisible(bool statusBarIsVisible)201 void WebChromeClient::setStatusbarVisible(bool statusBarIsVisible)
202 {
203     m_page->send(Messages::WebPageProxy::SetStatusBarIsVisible(statusBarIsVisible));
204 }
205 
statusbarVisible()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 
setScrollbarsVisible(bool)215 void WebChromeClient::setScrollbarsVisible(bool)
216 {
217     notImplemented();
218 }
219 
scrollbarsVisible()220 bool WebChromeClient::scrollbarsVisible()
221 {
222     notImplemented();
223     return true;
224 }
225 
setMenubarVisible(bool menuBarVisible)226 void WebChromeClient::setMenubarVisible(bool menuBarVisible)
227 {
228     m_page->send(Messages::WebPageProxy::SetMenuBarIsVisible(menuBarVisible));
229 }
230 
menubarVisible()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 
setResizable(bool resizable)240 void WebChromeClient::setResizable(bool resizable)
241 {
242     m_page->send(Messages::WebPageProxy::SetIsResizable(resizable));
243 }
244 
addMessageToConsole(MessageSource,MessageType,MessageLevel,const String & message,unsigned int lineNumber,const String & sourceID)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 
canRunBeforeUnloadConfirmPanel()253 bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
254 {
255     return m_page->canRunBeforeUnloadConfirmPanel();
256 }
257 
runBeforeUnloadConfirmPanel(const String & message,Frame * frame)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 
closeWindowSoon()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 
runJavaScriptAlert(Frame * frame,const String & alertText)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 
runJavaScriptConfirm(Frame * frame,const String & message)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 
runJavaScriptPrompt(Frame * frame,const String & message,const String & defaultValue,String & result)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 
setStatusbarText(const String & statusbarText)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 
shouldInterruptJavaScript()333 bool WebChromeClient::shouldInterruptJavaScript()
334 {
335     notImplemented();
336     return false;
337 }
338 
keyboardUIMode()339 KeyboardUIMode WebChromeClient::keyboardUIMode()
340 {
341     return m_page->keyboardUIMode();
342 }
343 
windowResizerRect() const344 IntRect WebChromeClient::windowResizerRect() const
345 {
346     return m_page->windowResizerRect();
347 }
348 
invalidateWindow(const IntRect &,bool)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 
invalidateContentsAndWindow(const IntRect & rect,bool)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 
invalidateContentsForSlowScroll(const IntRect & rect,bool)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 
scroll(const IntSize & scrollOffset,const IntRect & scrollRect,const IntRect & clipRect)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)
delegatedScrollRequested(const IntPoint & scrollOffset)376 void WebChromeClient::delegatedScrollRequested(const IntPoint& scrollOffset)
377 {
378     m_page->pageDidRequestScroll(scrollOffset);
379 }
380 #endif
381 
screenToWindow(const IntPoint &) const382 IntPoint WebChromeClient::screenToWindow(const IntPoint&) const
383 {
384     notImplemented();
385     return IntPoint();
386 }
387 
windowToScreen(const IntRect & rect) const388 IntRect WebChromeClient::windowToScreen(const IntRect& rect) const
389 {
390     return m_page->windowToScreen(rect);
391 }
392 
platformPageClient() const393 PlatformPageClient WebChromeClient::platformPageClient() const
394 {
395     notImplemented();
396     return 0;
397 }
398 
contentsSizeChanged(Frame * frame,const IntSize & size) const399 void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) const
400 {
401 #if PLATFORM(QT)
402 #if ENABLE(TILED_BACKING_STORE)
403     if (frame->page()->mainFrame() == frame)
404         m_page->resizeToContentsIfNeeded();
405 #endif
406 
407     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
408 
409     if (!m_page->mainFrame() || m_page->mainFrame() != webFrame)
410         return;
411 
412     m_page->send(Messages::WebPageProxy::DidChangeContentsSize(size));
413 #endif
414 
415     WebFrame* largestFrame = findLargestFrameInFrameSet(m_page);
416     if (largestFrame != m_cachedFrameSetLargestFrame.get()) {
417         m_cachedFrameSetLargestFrame = largestFrame;
418         m_page->send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0));
419     }
420 
421     if (frame->page()->mainFrame() != frame)
422         return;
423     FrameView* frameView = frame->view();
424     if (!frameView)
425         return;
426 
427     bool hasHorizontalScrollbar = frameView->horizontalScrollbar();
428     bool hasVerticalScrollbar = frameView->verticalScrollbar();
429 
430     if (hasHorizontalScrollbar != m_cachedMainFrameHasHorizontalScrollbar || hasVerticalScrollbar != m_cachedMainFrameHasVerticalScrollbar) {
431         m_page->send(Messages::WebPageProxy::DidChangeScrollbarsForMainFrame(hasHorizontalScrollbar, hasVerticalScrollbar));
432 
433         m_cachedMainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
434         m_cachedMainFrameHasVerticalScrollbar = hasVerticalScrollbar;
435     }
436 }
437 
scrollRectIntoView(const IntRect &,const ScrollView *) const438 void WebChromeClient::scrollRectIntoView(const IntRect&, const ScrollView*) const
439 {
440     notImplemented();
441 }
442 
shouldMissingPluginMessageBeButton() const443 bool WebChromeClient::shouldMissingPluginMessageBeButton() const
444 {
445     // FIXME: <rdar://problem/8794397> We should only return true when there is a
446     // missingPluginButtonClicked callback defined on the Page UI client.
447     return true;
448 }
449 
missingPluginButtonClicked(Element * element) const450 void WebChromeClient::missingPluginButtonClicked(Element* element) const
451 {
452     ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag));
453 
454     HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element);
455 
456     m_page->send(Messages::WebPageProxy::MissingPluginButtonClicked(pluginElement->serviceType(), pluginElement->url(), pluginElement->getAttribute(pluginspageAttr)));
457 }
458 
scrollbarsModeDidChange() const459 void WebChromeClient::scrollbarsModeDidChange() const
460 {
461     notImplemented();
462 }
463 
mouseDidMoveOverElement(const HitTestResult & hitTestResult,unsigned modifierFlags)464 void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult, unsigned modifierFlags)
465 {
466     RefPtr<APIObject> userData;
467 
468     // Notify the bundle client.
469     m_page->injectedBundleUIClient().mouseDidMoveOverElement(m_page, hitTestResult, static_cast<WebEvent::Modifiers>(modifierFlags), userData);
470 
471     // Notify the UIProcess.
472     m_page->send(Messages::WebPageProxy::MouseDidMoveOverElement(modifierFlags, InjectedBundleUserMessageEncoder(userData.get())));
473 }
474 
setToolTip(const String & toolTip,TextDirection)475 void WebChromeClient::setToolTip(const String& toolTip, TextDirection)
476 {
477     // Only send a tool tip to the WebProcess if it has changed since the last time this function was called.
478 
479     if (toolTip == m_cachedToolTip)
480         return;
481     m_cachedToolTip = toolTip;
482 
483     m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip));
484 }
485 
print(Frame * frame)486 void WebChromeClient::print(Frame* frame)
487 {
488     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
489     m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply());
490 }
491 
492 #if ENABLE(DATABASE)
exceededDatabaseQuota(Frame * frame,const String & databaseName)493 void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName)
494 {
495     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
496     SecurityOrigin* origin = frame->document()->securityOrigin();
497 
498     DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseName, origin);
499     uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin);
500     uint64_t newQuota = 0;
501     WebProcess::shared().connection()->sendSync(
502         Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, details.currentUsage(), details.expectedUsage()),
503         Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID());
504 
505     DatabaseTracker::tracker().setQuota(origin, newQuota);
506 }
507 #endif
508 
509 
510 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
reachedMaxAppCacheSize(int64_t)511 void WebChromeClient::reachedMaxAppCacheSize(int64_t)
512 {
513     notImplemented();
514 }
515 
reachedApplicationCacheOriginQuota(SecurityOrigin *)516 void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*)
517 {
518     notImplemented();
519 }
520 #endif
521 
522 #if ENABLE(DASHBOARD_SUPPORT)
dashboardRegionsChanged()523 void WebChromeClient::dashboardRegionsChanged()
524 {
525     notImplemented();
526 }
527 #endif
528 
populateVisitedLinks()529 void WebChromeClient::populateVisitedLinks()
530 {
531 }
532 
customHighlightRect(Node *,const AtomicString & type,const FloatRect & lineRect)533 FloatRect WebChromeClient::customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect)
534 {
535     notImplemented();
536     return FloatRect();
537 }
538 
paintCustomHighlight(Node *,const AtomicString & type,const FloatRect & boxRect,const FloatRect & lineRect,bool behindText,bool entireLine)539 void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
540                                   bool behindText, bool entireLine)
541 {
542     notImplemented();
543 }
544 
shouldReplaceWithGeneratedFileForUpload(const String & path,String & generatedFilename)545 bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
546 {
547     generatedFilename = m_page->injectedBundleUIClient().shouldGenerateFileForUpload(m_page, path);
548     return !generatedFilename.isNull();
549 }
550 
generateReplacementFile(const String & path)551 String WebChromeClient::generateReplacementFile(const String& path)
552 {
553     return m_page->injectedBundleUIClient().generateFileForUpload(m_page, path);
554 }
555 
paintCustomScrollbar(GraphicsContext *,const FloatRect &,ScrollbarControlSize,ScrollbarControlState,ScrollbarPart pressedPart,bool vertical,float value,float proportion,ScrollbarControlPartMask)556 bool WebChromeClient::paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize,
557                                            ScrollbarControlState, ScrollbarPart pressedPart, bool vertical,
558                                            float value, float proportion, ScrollbarControlPartMask)
559 {
560     notImplemented();
561     return false;
562 }
563 
paintCustomScrollCorner(GraphicsContext *,const FloatRect &)564 bool WebChromeClient::paintCustomScrollCorner(GraphicsContext*, const FloatRect&)
565 {
566     notImplemented();
567     return false;
568 }
569 
paintCustomOverhangArea(GraphicsContext * context,const IntRect & horizontalOverhangArea,const IntRect & verticalOverhangArea,const IntRect & dirtyRect)570 bool WebChromeClient::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
571 {
572     if (!m_page->injectedBundleUIClient().shouldPaintCustomOverhangArea())
573         return false;
574 
575     m_page->injectedBundleUIClient().paintCustomOverhangArea(m_page, context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
576     return true;
577 }
578 
requestGeolocationPermissionForFrame(Frame *,Geolocation *)579 void WebChromeClient::requestGeolocationPermissionForFrame(Frame*, Geolocation*)
580 {
581     notImplemented();
582 }
583 
cancelGeolocationPermissionRequestForFrame(Frame *,Geolocation *)584 void WebChromeClient::cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*)
585 {
586     notImplemented();
587 }
588 
runOpenPanel(Frame * frame,PassRefPtr<FileChooser> prpFileChooser)589 void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
590 {
591     if (m_page->activeOpenPanelResultListener())
592         return;
593 
594     RefPtr<FileChooser> fileChooser = prpFileChooser;
595 
596     m_page->setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser.get()));
597 
598     WebOpenPanelParameters::Data parameters;
599     parameters.allowMultipleFiles = fileChooser->allowsMultipleFiles();
600 #if ENABLE(DIRECTORY_UPLOAD)
601     parameters.allowsDirectoryUpload = fileChooser->allowsDirectoryUpload();
602 #else
603     parameters.allowsDirectoryUpload = false;
604 #endif
605     parameters.acceptTypes = fileChooser->acceptTypes();
606     parameters.filenames = fileChooser->filenames();
607 
608     m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), parameters));
609 }
610 
chooseIconForFiles(const Vector<String> & filenames,FileChooser * chooser)611 void WebChromeClient::chooseIconForFiles(const Vector<String>& filenames, FileChooser* chooser)
612 {
613     chooser->iconLoaded(Icon::createIconForFiles(filenames));
614 }
615 
setCursor(const WebCore::Cursor & cursor)616 void WebChromeClient::setCursor(const WebCore::Cursor& cursor)
617 {
618 #if USE(LAZY_NATIVE_CURSOR)
619     m_page->send(Messages::WebPageProxy::SetCursor(cursor));
620 #endif
621 }
622 
formStateDidChange(const Node *)623 void WebChromeClient::formStateDidChange(const Node*)
624 {
625     notImplemented();
626 }
627 
formDidFocus(const Node *)628 void WebChromeClient::formDidFocus(const Node*)
629 {
630     notImplemented();
631 }
632 
formDidBlur(const Node *)633 void WebChromeClient::formDidBlur(const Node*)
634 {
635     notImplemented();
636 }
637 
selectItemWritingDirectionIsNatural()638 bool WebChromeClient::selectItemWritingDirectionIsNatural()
639 {
640 #if PLATFORM(WIN)
641     return true;
642 #else
643     return false;
644 #endif
645 }
646 
selectItemAlignmentFollowsMenuWritingDirection()647 bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
648 {
649 #if PLATFORM(WIN)
650     return false;
651 #else
652     return true;
653 #endif
654 }
655 
createPopupMenu(WebCore::PopupMenuClient * client) const656 PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
657 {
658     return WebPopupMenu::create(m_page, client);
659 }
660 
createSearchPopupMenu(WebCore::PopupMenuClient * client) const661 PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
662 {
663     return WebSearchPopupMenu::create(m_page, client);
664 }
665 
666 #if ENABLE(CONTEXT_MENUS)
showContextMenu()667 void WebChromeClient::showContextMenu()
668 {
669     m_page->contextMenu()->show();
670 }
671 #endif
672 
673 #if USE(ACCELERATED_COMPOSITING)
attachRootGraphicsLayer(Frame *,GraphicsLayer * layer)674 void WebChromeClient::attachRootGraphicsLayer(Frame*, GraphicsLayer* layer)
675 {
676     if (layer)
677         m_page->enterAcceleratedCompositingMode(layer);
678     else
679         m_page->exitAcceleratedCompositingMode();
680 }
681 
setNeedsOneShotDrawingSynchronization()682 void WebChromeClient::setNeedsOneShotDrawingSynchronization()
683 {
684     notImplemented();
685 }
686 
scheduleCompositingLayerSync()687 void WebChromeClient::scheduleCompositingLayerSync()
688 {
689     if (m_page->drawingArea())
690         m_page->drawingArea()->scheduleCompositingLayerSync();
691 }
692 
693 #endif
694 
695 #if ENABLE(NOTIFICATIONS)
notificationPresenter() const696 WebCore::NotificationPresenter* WebChromeClient::notificationPresenter() const
697 {
698     return 0;
699 }
700 #endif
701 
702 #if ENABLE(TOUCH_EVENTS)
needTouchEvents(bool)703 void WebChromeClient::needTouchEvents(bool)
704 {
705 }
706 #endif
707 
708 #if PLATFORM(WIN)
setLastSetCursorToCurrentCursor()709 void WebChromeClient::setLastSetCursorToCurrentCursor()
710 {
711 }
712 #endif
713 
714 #if ENABLE(FULLSCREEN_API)
supportsFullScreenForElement(const WebCore::Element * element,bool withKeyboard)715 bool WebChromeClient::supportsFullScreenForElement(const WebCore::Element* element, bool withKeyboard)
716 {
717     return m_page->fullScreenManager()->supportsFullScreen(withKeyboard);
718 }
719 
enterFullScreenForElement(WebCore::Element * element)720 void WebChromeClient::enterFullScreenForElement(WebCore::Element* element)
721 {
722     m_page->fullScreenManager()->enterFullScreenForElement(element);
723 }
724 
exitFullScreenForElement(WebCore::Element * element)725 void WebChromeClient::exitFullScreenForElement(WebCore::Element* element)
726 {
727     m_page->fullScreenManager()->exitFullScreenForElement(element);
728 }
729 
setRootFullScreenLayer(GraphicsLayer * layer)730 void WebChromeClient::setRootFullScreenLayer(GraphicsLayer* layer)
731 {
732     m_page->fullScreenManager()->setRootFullScreenLayer(layer);
733 }
734 
735 #endif
736 
dispatchViewportDataDidChange(const ViewportArguments & args) const737 void WebChromeClient::dispatchViewportDataDidChange(const ViewportArguments& args) const
738 {
739     m_page->send(Messages::WebPageProxy::DidChangeViewportData(args));
740 }
741 
didCompleteRubberBandForMainFrame(const IntSize & initialOverhang) const742 void WebChromeClient::didCompleteRubberBandForMainFrame(const IntSize& initialOverhang) const
743 {
744     m_page->send(Messages::WebPageProxy::DidCompleteRubberBandForMainFrame(initialOverhang));
745 }
746 
747 } // namespace WebKit
748