[WK2][WKTR] TestRunner needs to implement dumpApplicationCacheDelegateCallbacks
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebCoreSupport / WebChromeClient.cpp
1 /*
2  * Copyright (C) 2010, 2011, 2012 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 "LayerTreeHost.h"
34 #include "WebColorChooser.h"
35 #include "WebCoreArgumentCoders.h"
36 #include "WebFrame.h"
37 #include "WebFrameLoaderClient.h"
38 #include "WebFullScreenManager.h"
39 #include "WebOpenPanelParameters.h"
40 #include "WebOpenPanelResultListener.h"
41 #include "WebPage.h"
42 #include "WebPageCreationParameters.h"
43 #include "WebPageProxyMessages.h"
44 #include "WebPopupMenu.h"
45 #include "WebPreferencesStore.h"
46 #include "WebProcess.h"
47 #include "WebSearchPopupMenu.h"
48 #include "WebSecurityOrigin.h"
49 #include <WebCore/AXObjectCache.h>
50 #include <WebCore/ColorChooser.h>
51 #include <WebCore/DatabaseTracker.h>
52 #include <WebCore/FileChooser.h>
53 #include <WebCore/FileIconLoader.h>
54 #include <WebCore/Frame.h>
55 #include <WebCore/FrameLoadRequest.h>
56 #include <WebCore/FrameLoader.h>
57 #include <WebCore/FrameView.h>
58 #include <WebCore/HTMLNames.h>
59 #include <WebCore/HTMLPlugInImageElement.h>
60 #include <WebCore/Icon.h>
61 #include <WebCore/NotImplemented.h>
62 #include <WebCore/Page.h>
63 #include <WebCore/SecurityOrigin.h>
64 #include <WebCore/Settings.h>
65
66 using namespace WebCore;
67 using namespace HTMLNames;
68
69 namespace WebKit {
70
71 static double area(WebFrame* frame)
72 {
73     IntSize size = frame->visibleContentBoundsExcludingScrollbars().size();
74     return static_cast<double>(size.height()) * size.width();
75 }
76
77
78 static WebFrame* findLargestFrameInFrameSet(WebPage* page)
79 {
80     // Approximate what a user could consider a default target frame for application menu operations.
81
82     WebFrame* mainFrame = page->mainWebFrame();
83     if (!mainFrame->isFrameSet())
84         return 0;
85
86     WebFrame* largestSoFar = 0;
87
88     RefPtr<ImmutableArray> frameChildren = mainFrame->childFrames();
89     size_t count = frameChildren->size();
90     for (size_t i = 0; i < count; ++i) {
91         WebFrame* childFrame = frameChildren->at<WebFrame>(i);
92         if (!largestSoFar || area(childFrame) > area(largestSoFar))
93             largestSoFar = childFrame;
94     }
95
96     return largestSoFar;
97 }
98
99 void WebChromeClient::chromeDestroyed()
100 {
101     delete this;
102 }
103
104 void WebChromeClient::setWindowRect(const FloatRect& windowFrame)
105 {
106     m_page->send(Messages::WebPageProxy::SetWindowFrame(windowFrame));
107 }
108
109 FloatRect WebChromeClient::windowRect()
110 {
111     FloatRect newWindowFrame;
112
113     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetWindowFrame(), Messages::WebPageProxy::GetWindowFrame::Reply(newWindowFrame), m_page->pageID()))
114         return FloatRect();
115
116     return newWindowFrame;
117 }
118
119 FloatRect WebChromeClient::pageRect()
120 {
121     return FloatRect(FloatPoint(), m_page->size());
122 }
123
124 void WebChromeClient::focus()
125 {
126     m_page->send(Messages::WebPageProxy::SetFocus(true));
127 }
128
129 void WebChromeClient::unfocus()
130 {
131     m_page->send(Messages::WebPageProxy::SetFocus(false));
132 }
133
134 #if PLATFORM(MAC)
135 void WebChromeClient::makeFirstResponder()
136 {
137     m_page->send(Messages::WebPageProxy::MakeFirstResponder());
138 }    
139 #endif    
140
141 bool WebChromeClient::canTakeFocus(FocusDirection)
142 {
143     notImplemented();
144     return true;
145 }
146
147 void WebChromeClient::takeFocus(FocusDirection direction)
148 {
149     m_page->send(Messages::WebPageProxy::TakeFocus(direction));
150 }
151
152 void WebChromeClient::focusedNodeChanged(Node*)
153 {
154     notImplemented();
155 }
156
157 void WebChromeClient::focusedFrameChanged(Frame* frame)
158 {
159     WebFrame* webFrame = frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : 0;
160
161     WebProcess::shared().connection()->send(Messages::WebPageProxy::FocusedFrameChanged(webFrame ? webFrame->frameID() : 0), m_page->pageID());
162 }
163
164 Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& windowFeatures, const NavigationAction& navigationAction)
165 {
166     uint32_t modifiers = static_cast<uint32_t>(InjectedBundleNavigationAction::modifiersForNavigationAction(navigationAction));
167     int32_t mouseButton = static_cast<int32_t>(InjectedBundleNavigationAction::mouseButtonForNavigationAction(navigationAction));
168
169     uint64_t newPageID = 0;
170     WebPageCreationParameters parameters;
171     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::CreateNewPage(request.resourceRequest(), windowFeatures, modifiers, mouseButton), Messages::WebPageProxy::CreateNewPage::Reply(newPageID, parameters), m_page->pageID()))
172         return 0;
173
174     if (!newPageID)
175         return 0;
176
177     WebProcess::shared().createWebPage(newPageID, parameters);
178     return WebProcess::shared().webPage(newPageID)->corePage();
179 }
180
181 void WebChromeClient::show()
182 {
183     m_page->show();
184 }
185
186 bool WebChromeClient::canRunModal()
187 {
188     return m_page->canRunModal();
189 }
190
191 void WebChromeClient::runModal()
192 {
193     m_page->runModal();
194 }
195
196 void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible)
197 {
198     m_page->send(Messages::WebPageProxy::SetToolbarsAreVisible(toolbarsAreVisible));
199 }
200
201 bool WebChromeClient::toolbarsVisible()
202 {
203     WKBundlePageUIElementVisibility toolbarsVisibility = m_page->injectedBundleUIClient().toolbarsAreVisible(m_page);
204     if (toolbarsVisibility != WKBundlePageUIElementVisibilityUnknown)
205         return toolbarsVisibility == WKBundlePageUIElementVisible;
206     
207     bool toolbarsAreVisible = true;
208     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetToolbarsAreVisible(), Messages::WebPageProxy::GetToolbarsAreVisible::Reply(toolbarsAreVisible), m_page->pageID()))
209         return true;
210
211     return toolbarsAreVisible;
212 }
213
214 void WebChromeClient::setStatusbarVisible(bool statusBarIsVisible)
215 {
216     m_page->send(Messages::WebPageProxy::SetStatusBarIsVisible(statusBarIsVisible));
217 }
218
219 bool WebChromeClient::statusbarVisible()
220 {
221     WKBundlePageUIElementVisibility statusbarVisibility = m_page->injectedBundleUIClient().statusBarIsVisible(m_page);
222     if (statusbarVisibility != WKBundlePageUIElementVisibilityUnknown)
223         return statusbarVisibility == WKBundlePageUIElementVisible;
224
225     bool statusBarIsVisible = true;
226     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetStatusBarIsVisible(), Messages::WebPageProxy::GetStatusBarIsVisible::Reply(statusBarIsVisible), m_page->pageID()))
227         return true;
228
229     return statusBarIsVisible;
230 }
231
232 void WebChromeClient::setScrollbarsVisible(bool)
233 {
234     notImplemented();
235 }
236
237 bool WebChromeClient::scrollbarsVisible()
238 {
239     notImplemented();
240     return true;
241 }
242
243 void WebChromeClient::setMenubarVisible(bool menuBarVisible)
244 {
245     m_page->send(Messages::WebPageProxy::SetMenuBarIsVisible(menuBarVisible));
246 }
247
248 bool WebChromeClient::menubarVisible()
249 {
250     WKBundlePageUIElementVisibility menubarVisibility = m_page->injectedBundleUIClient().menuBarIsVisible(m_page);
251     if (menubarVisibility != WKBundlePageUIElementVisibilityUnknown)
252         return menubarVisibility == WKBundlePageUIElementVisible;
253     
254     bool menuBarIsVisible = true;
255     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetMenuBarIsVisible(), Messages::WebPageProxy::GetMenuBarIsVisible::Reply(menuBarIsVisible), m_page->pageID()))
256         return true;
257
258     return menuBarIsVisible;
259 }
260
261 void WebChromeClient::setResizable(bool resizable)
262 {
263     m_page->send(Messages::WebPageProxy::SetIsResizable(resizable));
264 }
265
266 void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID)
267 {
268     // Notify the bundle client.
269     m_page->injectedBundleUIClient().willAddMessageToConsole(m_page, message, lineNumber);
270
271     notImplemented();
272 }
273
274 bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
275 {
276     return m_page->canRunBeforeUnloadConfirmPanel();
277 }
278
279 bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
280 {
281     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
282
283     bool shouldClose = false;
284     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID()))
285         return false;
286
287     return shouldClose;
288 }
289
290 void WebChromeClient::closeWindowSoon()
291 {
292     // FIXME: This code assumes that the client will respond to a close page
293     // message by actually closing the page. Safari does this, but there is
294     // no guarantee that other applications will, which will leave this page
295     // half detached. This approach is an inherent limitation making parts of
296     // a close execute synchronously as part of window.close, but other parts
297     // later on.
298
299     m_page->corePage()->setGroupName(String());
300
301     if (WebFrame* frame = m_page->mainWebFrame()) {
302         if (Frame* coreFrame = frame->coreFrame())
303             coreFrame->loader()->stopForUserCancel();
304     }
305
306     m_page->sendClose();
307 }
308
309 void WebChromeClient::runJavaScriptAlert(Frame* frame, const String& alertText)
310 {
311     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
312
313     // Notify the bundle client.
314     m_page->injectedBundleUIClient().willRunJavaScriptAlert(m_page, alertText, webFrame);
315
316     unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
317     WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags);
318 }
319
320 bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message)
321 {
322     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
323
324     // Notify the bundle client.
325     m_page->injectedBundleUIClient().willRunJavaScriptConfirm(m_page, message, webFrame);
326
327     unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
328     bool result = false;
329     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
330         return false;
331
332     return result;
333 }
334
335 bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
336 {
337     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
338
339     // Notify the bundle client.
340     m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame);
341
342     unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
343     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
344         return false;
345
346     return !result.isNull();
347 }
348
349 void WebChromeClient::setStatusbarText(const String& statusbarText)
350 {
351     // Notify the bundle client.
352     m_page->injectedBundleUIClient().willSetStatusbarText(m_page, statusbarText);
353
354     m_page->send(Messages::WebPageProxy::SetStatusText(statusbarText));
355 }
356
357 bool WebChromeClient::shouldInterruptJavaScript()
358 {
359     bool shouldInterrupt = false;
360     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ShouldInterruptJavaScript(), Messages::WebPageProxy::ShouldInterruptJavaScript::Reply(shouldInterrupt), m_page->pageID()))
361         return false;
362
363     return shouldInterrupt;
364 }
365
366 KeyboardUIMode WebChromeClient::keyboardUIMode()
367 {
368     return m_page->keyboardUIMode();
369 }
370
371 IntRect WebChromeClient::windowResizerRect() const
372 {
373     return m_page->windowResizerRect();
374 }
375
376 void WebChromeClient::invalidateRootView(const IntRect&, bool)
377 {
378     // Do nothing here, there's no concept of invalidating the window in the web process.
379 }
380
381 void WebChromeClient::invalidateContentsAndRootView(const IntRect& rect, bool)
382 {
383     if (Document* document = m_page->corePage()->mainFrame()->document()) {
384         if (document->printing())
385             return;
386     }
387
388     m_page->drawingArea()->setNeedsDisplay(rect);
389 }
390
391 void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool)
392 {
393     if (Document* document = m_page->corePage()->mainFrame()->document()) {
394         if (document->printing())
395             return;
396     }
397
398     m_page->pageDidScroll();
399     m_page->drawingArea()->setNeedsDisplay(rect);
400 }
401
402 void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollRect, const IntRect& clipRect)
403 {
404     m_page->pageDidScroll();
405     m_page->drawingArea()->scroll(intersection(scrollRect, clipRect), scrollOffset);
406 }
407
408 #if USE(TILED_BACKING_STORE)
409 void WebChromeClient::delegatedScrollRequested(const IntPoint& scrollOffset)
410 {
411     m_page->pageDidRequestScroll(scrollOffset);
412 }
413 #endif
414
415 IntPoint WebChromeClient::screenToRootView(const IntPoint& point) const
416 {
417     return m_page->screenToWindow(point);
418 }
419
420 IntRect WebChromeClient::rootViewToScreen(const IntRect& rect) const
421 {
422     return m_page->windowToScreen(rect);
423 }
424
425 PlatformPageClient WebChromeClient::platformPageClient() const
426 {
427     notImplemented();
428     return 0;
429 }
430
431 void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) const
432 {
433     if (!m_page->corePage()->settings()->frameFlatteningEnabled()) {
434         WebFrame* largestFrame = findLargestFrameInFrameSet(m_page);
435         if (largestFrame != m_cachedFrameSetLargestFrame.get()) {
436             m_cachedFrameSetLargestFrame = largestFrame;
437             m_page->send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0));
438         }
439     }
440
441     if (frame->page()->mainFrame() != frame)
442         return;
443
444 #if PLATFORM(QT) || (PLATFORM(EFL) && USE(TILED_BACKING_STORE))
445     if (m_page->useFixedLayout()) {
446         // The below method updates the size().
447         m_page->resizeToContentsIfNeeded();
448         m_page->drawingArea()->layerTreeHost()->sizeDidChange(m_page->size());
449     }
450
451     m_page->send(Messages::WebPageProxy::DidChangeContentsSize(m_page->size()));
452
453 #endif
454
455     FrameView* frameView = frame->view();
456     if (frameView && !frameView->delegatesScrolling())  {
457         bool hasHorizontalScrollbar = frameView->horizontalScrollbar();
458         bool hasVerticalScrollbar = frameView->verticalScrollbar();
459
460         if (hasHorizontalScrollbar != m_cachedMainFrameHasHorizontalScrollbar || hasVerticalScrollbar != m_cachedMainFrameHasVerticalScrollbar) {
461             m_page->send(Messages::WebPageProxy::DidChangeScrollbarsForMainFrame(hasHorizontalScrollbar, hasVerticalScrollbar));
462
463             m_cachedMainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
464             m_cachedMainFrameHasVerticalScrollbar = hasVerticalScrollbar;
465         }
466     }
467 }
468
469 void WebChromeClient::scrollRectIntoView(const IntRect&) const
470 {
471     notImplemented();
472 }
473
474 bool WebChromeClient::shouldUnavailablePluginMessageBeButton(RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
475 {
476     if (pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion) {
477         // FIXME: <rdar://problem/8794397> We should only return true when there is a
478         // missingPluginButtonClicked callback defined on the Page UI client.
479         return true;
480     }
481
482     return false;
483 }
484     
485 void WebChromeClient::unavailablePluginButtonClicked(Element* element, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
486 {
487     ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag) || element->hasTagName(appletTag));
488     ASSERT(pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion);
489
490     HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element);
491
492     m_page->send(Messages::WebPageProxy::UnavailablePluginButtonClicked(pluginUnavailabilityReason, pluginElement->serviceType(), pluginElement->url(), pluginElement->getAttribute(pluginspageAttr)));
493 }
494
495 void WebChromeClient::scrollbarsModeDidChange() const
496 {
497     notImplemented();
498 }
499
500 void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult, unsigned modifierFlags)
501 {
502     RefPtr<APIObject> userData;
503
504     // Notify the bundle client.
505     m_page->injectedBundleUIClient().mouseDidMoveOverElement(m_page, hitTestResult, static_cast<WebEvent::Modifiers>(modifierFlags), userData);
506
507     // Notify the UIProcess.
508     WebHitTestResult::Data webHitTestResultData(hitTestResult);
509     m_page->send(Messages::WebPageProxy::MouseDidMoveOverElement(webHitTestResultData, modifierFlags, InjectedBundleUserMessageEncoder(userData.get())));
510 }
511
512 void WebChromeClient::setToolTip(const String& toolTip, TextDirection)
513 {
514     // Only send a tool tip to the WebProcess if it has changed since the last time this function was called.
515
516     if (toolTip == m_cachedToolTip)
517         return;
518     m_cachedToolTip = toolTip;
519
520     m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip));
521 }
522
523 void WebChromeClient::print(Frame* frame)
524 {
525     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
526     m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply());
527 }
528
529 #if ENABLE(SQL_DATABASE)
530 void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName)
531 {
532     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
533     SecurityOrigin* origin = frame->document()->securityOrigin();
534
535     DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseName, origin);
536     uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin);
537     uint64_t currentOriginUsage = DatabaseTracker::tracker().usageForOrigin(origin);
538     uint64_t newQuota = 0;
539     WebProcess::shared().connection()->sendSync(
540         Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
541         Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID());
542
543     DatabaseTracker::tracker().setQuota(origin, newQuota);
544 }
545 #endif
546
547
548 void WebChromeClient::reachedMaxAppCacheSize(int64_t)
549 {
550     notImplemented();
551 }
552
553 void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin* origin, int64_t totalBytesNeeded)
554 {
555     RefPtr<WebSecurityOrigin> webSecurityOrigin = WebSecurityOrigin::createFromString(origin->toString());
556     m_page->injectedBundleUIClient().didReachApplicationCacheOriginQuota(m_page, webSecurityOrigin.get(), totalBytesNeeded);
557 }
558
559 #if ENABLE(DASHBOARD_SUPPORT)
560 void WebChromeClient::dashboardRegionsChanged()
561 {
562     notImplemented();
563 }
564 #endif
565
566 void WebChromeClient::populateVisitedLinks()
567 {
568 }
569
570 FloatRect WebChromeClient::customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect)
571 {
572     notImplemented();
573     return FloatRect();
574 }
575
576 void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
577                                   bool behindText, bool entireLine)
578 {
579     notImplemented();
580 }
581
582 bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
583 {
584     generatedFilename = m_page->injectedBundleUIClient().shouldGenerateFileForUpload(m_page, path);
585     return !generatedFilename.isNull();
586 }
587
588 String WebChromeClient::generateReplacementFile(const String& path)
589 {
590     return m_page->injectedBundleUIClient().generateFileForUpload(m_page, path);
591 }
592
593 bool WebChromeClient::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
594 {
595     if (!m_page->injectedBundleUIClient().shouldPaintCustomOverhangArea())
596         return false;
597
598     m_page->injectedBundleUIClient().paintCustomOverhangArea(m_page, context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
599     return true;
600 }
601
602 #if ENABLE(INPUT_TYPE_COLOR)
603 PassOwnPtr<ColorChooser> WebChromeClient::createColorChooser(ColorChooserClient* client, const Color& initialColor)
604 {
605     if (m_page->activeColorChooser())
606         return nullptr;
607
608     return adoptPtr(new WebColorChooser(m_page, client, initialColor));
609 }
610 #endif
611
612 void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
613 {
614     if (m_page->activeOpenPanelResultListener())
615         return;
616
617     RefPtr<FileChooser> fileChooser = prpFileChooser;
618
619     m_page->setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser.get()));
620     m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), fileChooser->settings()));
621 }
622
623 void WebChromeClient::loadIconForFiles(const Vector<String>& filenames, FileIconLoader* loader)
624 {
625     loader->notifyFinished(Icon::createIconForFiles(filenames));
626 }
627
628 void WebChromeClient::setCursor(const WebCore::Cursor& cursor)
629 {
630 #if USE(LAZY_NATIVE_CURSOR)
631     m_page->send(Messages::WebPageProxy::SetCursor(cursor));
632 #endif
633 }
634
635 void WebChromeClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
636 {
637     m_page->send(Messages::WebPageProxy::SetCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves));
638 }
639
640 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
641 void WebChromeClient::scheduleAnimation()
642 {
643 #if USE(COORDINATED_GRAPHICS)
644     m_page->drawingArea()->layerTreeHost()->scheduleAnimation();
645 #endif
646 }
647 #endif
648
649 void WebChromeClient::formStateDidChange(const Node*)
650 {
651     notImplemented();
652 }
653
654 bool WebChromeClient::selectItemWritingDirectionIsNatural()
655 {
656 #if PLATFORM(WIN)
657     return true;
658 #else
659     return false;
660 #endif
661 }
662
663 bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
664 {
665 #if PLATFORM(WIN)
666     return false;
667 #else
668     return true;
669 #endif
670 }
671
672 bool WebChromeClient::hasOpenedPopup() const
673 {
674     notImplemented();
675     return false;
676 }
677
678 PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
679 {
680     return WebPopupMenu::create(m_page, client);
681 }
682
683 PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
684 {
685     return WebSearchPopupMenu::create(m_page, client);
686 }
687
688 #if USE(ACCELERATED_COMPOSITING)
689 void WebChromeClient::attachRootGraphicsLayer(Frame*, GraphicsLayer* layer)
690 {
691     if (layer)
692         m_page->enterAcceleratedCompositingMode(layer);
693     else
694         m_page->exitAcceleratedCompositingMode();
695 }
696
697 void WebChromeClient::setNeedsOneShotDrawingSynchronization()
698 {
699     notImplemented();
700 }
701
702 void WebChromeClient::scheduleCompositingLayerSync()
703 {
704     if (m_page->drawingArea())
705         m_page->drawingArea()->scheduleCompositingLayerSync();
706 }
707
708 #endif
709
710 #if PLATFORM(WIN) && USE(AVFOUNDATION)
711 WebCore::GraphicsDeviceAdapter* WebChromeClient::graphicsDeviceAdapter() const
712 {
713     if (!m_page->drawingArea())
714         return 0;
715     return m_page->drawingArea()->layerTreeHost()->graphicsDeviceAdapter();
716 }
717 #endif
718
719 #if ENABLE(TOUCH_EVENTS)
720 void WebChromeClient::needTouchEvents(bool needTouchEvents)
721 {
722     m_page->send(Messages::WebPageProxy::NeedTouchEvents(needTouchEvents));
723 }
724 #endif
725
726 #if PLATFORM(WIN)
727 void WebChromeClient::setLastSetCursorToCurrentCursor()
728 {
729 }
730 #endif
731
732 #if ENABLE(FULLSCREEN_API)
733 bool WebChromeClient::supportsFullScreenForElement(const WebCore::Element* element, bool withKeyboard)
734 {
735     return m_page->fullScreenManager()->supportsFullScreen(withKeyboard);
736 }
737
738 void WebChromeClient::enterFullScreenForElement(WebCore::Element* element)
739 {
740     m_page->fullScreenManager()->enterFullScreenForElement(element);
741 }
742
743 void WebChromeClient::exitFullScreenForElement(WebCore::Element* element)
744 {
745     m_page->fullScreenManager()->exitFullScreenForElement(element);
746 }
747 #endif
748
749 void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments&) const
750 {
751 #if USE(TILED_BACKING_STORE)
752     if (!m_page->useFixedLayout())
753         return;
754
755     m_page->sendViewportAttributesChanged();
756 #endif
757 }
758
759 void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
760 {
761     m_page->send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
762 }
763
764 void WebChromeClient::recommendedScrollbarStyleDidChange(int32_t newStyle)
765 {
766     m_page->send(Messages::WebPageProxy::RecommendedScrollbarStyleDidChange(newStyle));
767 }
768
769 bool WebChromeClient::shouldRubberBandInDirection(WebCore::ScrollDirection direction) const
770 {
771     ASSERT(direction != WebCore::ScrollUp && direction != WebCore::ScrollDown);
772     
773     if (direction == WebCore::ScrollLeft)
774         return m_page->injectedBundleUIClient().shouldRubberBandInDirection(m_page, WKScrollDirectionLeft);
775     if (direction == WebCore::ScrollRight)
776         return m_page->injectedBundleUIClient().shouldRubberBandInDirection(m_page, WKScrollDirectionRight);
777
778     ASSERT_NOT_REACHED();
779     return true;
780 }
781
782 void WebChromeClient::numWheelEventHandlersChanged(unsigned count)
783 {
784     m_page->numWheelEventHandlersChanged(count);
785 }
786
787 void WebChromeClient::logDiagnosticMessage(const String& message, const String& description, const String& success)
788 {
789     if (!m_page->corePage()->settings()->diagnosticLoggingEnabled())
790         return;
791
792     m_page->injectedBundleDiagnosticLoggingClient().logDiagnosticMessage(m_page, message, description, success);
793 }
794
795 } // namespace WebKit