2 * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
28 #include "WebChromeClient.h"
30 #include "DrawingArea.h"
31 #include "InjectedBundleNavigationAction.h"
32 #include "InjectedBundleUserMessageCoders.h"
33 #include "LayerTreeHost.h"
34 #include "WebColorChooser.h"
35 #include "WebCoreArgumentCoders.h"
37 #include "WebFrameLoaderClient.h"
38 #include "WebFullScreenManager.h"
39 #include "WebOpenPanelParameters.h"
40 #include "WebOpenPanelResultListener.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 <WebCore/AXObjectCache.h>
49 #include <WebCore/ColorChooser.h>
50 #include <WebCore/DatabaseTracker.h>
51 #include <WebCore/FileChooser.h>
52 #include <WebCore/FileIconLoader.h>
53 #include <WebCore/Frame.h>
54 #include <WebCore/FrameLoadRequest.h>
55 #include <WebCore/FrameLoader.h>
56 #include <WebCore/FrameView.h>
57 #include <WebCore/HTMLNames.h>
58 #include <WebCore/HTMLPlugInImageElement.h>
59 #include <WebCore/Icon.h>
60 #include <WebCore/NotImplemented.h>
61 #include <WebCore/Page.h>
62 #include <WebCore/SecurityOrigin.h>
63 #include <WebCore/Settings.h>
65 #if ENABLE(TIZEN_DISPLAY_MESSAGE_TO_CONSOLE)
66 #include <dlog/dlog.h>
69 using namespace WebCore;
70 using namespace HTMLNames;
74 static double area(WebFrame* frame)
76 IntSize size = frame->visibleContentBoundsExcludingScrollbars().size();
77 return static_cast<double>(size.height()) * size.width();
81 static WebFrame* findLargestFrameInFrameSet(WebPage* page)
83 // Approximate what a user could consider a default target frame for application menu operations.
85 WebFrame* mainFrame = page->mainWebFrame();
86 if (!mainFrame->isFrameSet())
89 WebFrame* largestSoFar = 0;
91 RefPtr<ImmutableArray> frameChildren = mainFrame->childFrames();
92 size_t count = frameChildren->size();
93 for (size_t i = 0; i < count; ++i) {
94 WebFrame* childFrame = frameChildren->at<WebFrame>(i);
95 if (!largestSoFar || area(childFrame) > area(largestSoFar))
96 largestSoFar = childFrame;
102 void WebChromeClient::chromeDestroyed()
107 void WebChromeClient::setWindowRect(const FloatRect& windowFrame)
109 m_page->send(Messages::WebPageProxy::SetWindowFrame(windowFrame));
112 FloatRect WebChromeClient::windowRect()
114 FloatRect newWindowFrame;
116 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetWindowFrame(), Messages::WebPageProxy::GetWindowFrame::Reply(newWindowFrame), m_page->pageID()))
119 return newWindowFrame;
122 FloatRect WebChromeClient::pageRect()
124 return FloatRect(FloatPoint(), m_page->size());
127 void WebChromeClient::focus()
129 m_page->send(Messages::WebPageProxy::SetFocus(true));
132 void WebChromeClient::unfocus()
134 m_page->send(Messages::WebPageProxy::SetFocus(false));
138 void WebChromeClient::makeFirstResponder()
140 m_page->send(Messages::WebPageProxy::MakeFirstResponder());
144 bool WebChromeClient::canTakeFocus(FocusDirection)
150 void WebChromeClient::takeFocus(FocusDirection direction)
152 m_page->send(Messages::WebPageProxy::TakeFocus(direction));
155 void WebChromeClient::focusedNodeChanged(Node* node)
158 IntRect nodeRect = IntRect(0, 0, 0, 0);
160 nodeRect = WebCore::pixelSnappedIntRect(node->getRect());
161 Frame* mainFrame = m_page->corePage()->mainFrame();
162 Frame* frame = node->document()->frame();
164 while (frame && frame != mainFrame) {
165 owner = frame->ownerElement();
167 nodeRect.setX(nodeRect.x() + owner->getRect().x());
168 nodeRect.setY(nodeRect.y() + owner->getRect().y());
169 frame = owner->document()->frame();
174 // we have to divide (x, y) with pageZoomFactor because pageZoomFactor was applied to them.
175 nodeRect.setX(nodeRect.x() / m_page->pageScaleFactor());
176 nodeRect.setY(nodeRect.y() / m_page->pageScaleFactor());
178 m_page->send(Messages::WebPageProxy::FocusedNodeChanged(nodeRect));
184 void WebChromeClient::focusedFrameChanged(Frame* frame)
186 WebFrame* webFrame = frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : 0;
188 WebProcess::shared().connection()->send(Messages::WebPageProxy::FocusedFrameChanged(webFrame ? webFrame->frameID() : 0), m_page->pageID());
191 Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& windowFeatures, const NavigationAction& navigationAction)
193 uint32_t modifiers = static_cast<uint32_t>(InjectedBundleNavigationAction::modifiersForNavigationAction(navigationAction));
194 int32_t mouseButton = static_cast<int32_t>(InjectedBundleNavigationAction::mouseButtonForNavigationAction(navigationAction));
196 uint64_t newPageID = 0;
197 WebPageCreationParameters parameters;
198 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::CreateNewPage(request.resourceRequest(), windowFeatures, modifiers, mouseButton), Messages::WebPageProxy::CreateNewPage::Reply(newPageID, parameters), m_page->pageID()))
204 WebProcess::shared().createWebPage(newPageID, parameters);
205 return WebProcess::shared().webPage(newPageID)->corePage();
208 void WebChromeClient::show()
213 bool WebChromeClient::canRunModal()
215 return m_page->canRunModal();
218 void WebChromeClient::runModal()
223 void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible)
225 m_page->send(Messages::WebPageProxy::SetToolbarsAreVisible(toolbarsAreVisible));
228 bool WebChromeClient::toolbarsVisible()
230 WKBundlePageUIElementVisibility toolbarsVisibility = m_page->injectedBundleUIClient().toolbarsAreVisible(m_page);
231 if (toolbarsVisibility != WKBundlePageUIElementVisibilityUnknown)
232 return toolbarsVisibility == WKBundlePageUIElementVisible;
234 bool toolbarsAreVisible = true;
235 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetToolbarsAreVisible(), Messages::WebPageProxy::GetToolbarsAreVisible::Reply(toolbarsAreVisible), m_page->pageID()))
238 return toolbarsAreVisible;
241 void WebChromeClient::setStatusbarVisible(bool statusBarIsVisible)
243 m_page->send(Messages::WebPageProxy::SetStatusBarIsVisible(statusBarIsVisible));
246 bool WebChromeClient::statusbarVisible()
248 WKBundlePageUIElementVisibility statusbarVisibility = m_page->injectedBundleUIClient().statusBarIsVisible(m_page);
249 if (statusbarVisibility != WKBundlePageUIElementVisibilityUnknown)
250 return statusbarVisibility == WKBundlePageUIElementVisible;
252 bool statusBarIsVisible = true;
253 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetStatusBarIsVisible(), Messages::WebPageProxy::GetStatusBarIsVisible::Reply(statusBarIsVisible), m_page->pageID()))
256 return statusBarIsVisible;
259 void WebChromeClient::setScrollbarsVisible(bool)
264 bool WebChromeClient::scrollbarsVisible()
270 void WebChromeClient::setMenubarVisible(bool menuBarVisible)
272 m_page->send(Messages::WebPageProxy::SetMenuBarIsVisible(menuBarVisible));
275 bool WebChromeClient::menubarVisible()
277 WKBundlePageUIElementVisibility menubarVisibility = m_page->injectedBundleUIClient().menuBarIsVisible(m_page);
278 if (menubarVisibility != WKBundlePageUIElementVisibilityUnknown)
279 return menubarVisibility == WKBundlePageUIElementVisible;
281 bool menuBarIsVisible = true;
282 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetMenuBarIsVisible(), Messages::WebPageProxy::GetMenuBarIsVisible::Reply(menuBarIsVisible), m_page->pageID()))
285 return menuBarIsVisible;
288 void WebChromeClient::setResizable(bool resizable)
290 m_page->send(Messages::WebPageProxy::SetIsResizable(resizable));
293 #if ENABLE(TIZEN_DISPLAY_MESSAGE_TO_CONSOLE)
294 void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel level, const String& message, unsigned int lineNumber, const String& sourceID)
296 void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID)
299 #if ENABLE(TIZEN_DISPLAY_MESSAGE_TO_CONSOLE) // Request for WAC SDK
302 newMessage = String::format("%s:%d:%s", sourceID.utf8().data(), lineNumber, message.utf8().data());
304 newMessage = message;
307 case WarningMessageLevel:
308 ALOG(LOG_WARN, "ConsoleMessage", "%s", newMessage.utf8().data());
310 case ErrorMessageLevel:
311 ALOG(LOG_ERROR, "ConsoleMessage", "%s", newMessage.utf8().data());
313 case LogMessageLevel:
314 ALOG(LOG_DEBUG, "ConsoleMessage", "%s", newMessage.utf8().data());
317 ALOG(LOG_INFO, "ConsoleMessage", "%s", newMessage.utf8().data());
321 // Notify the bundle client.
322 m_page->injectedBundleUIClient().willAddMessageToConsole(m_page, message, lineNumber);
327 bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
329 return m_page->canRunBeforeUnloadConfirmPanel();
332 bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
334 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
335 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
337 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
338 bool shouldClose = false;
339 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
340 WebProcess::WaitForJavaScriptPopupFinished waiting;
342 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
347 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
349 bool shouldClose = false;
350 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID()))
357 void WebChromeClient::closeWindowSoon()
359 // FIXME: This code assumes that the client will respond to a close page
360 // message by actually closing the page. Safari does this, but there is
361 // no guarantee that other applications will, which will leave this page
362 // half detached. This approach is an inherent limitation making parts of
363 // a close execute synchronously as part of window.close, but other parts
366 m_page->corePage()->setGroupName(String());
368 if (WebFrame* frame = m_page->mainWebFrame()) {
369 if (Frame* coreFrame = frame->coreFrame())
370 coreFrame->loader()->stopForUserCancel();
376 void WebChromeClient::runJavaScriptAlert(Frame* frame, const String& alertText)
378 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
380 // Notify the bundle client.
381 m_page->injectedBundleUIClient().willRunJavaScriptAlert(m_page, alertText, webFrame);
383 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
384 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
385 WebProcess::WaitForJavaScriptPopupFinished waiting;
387 WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags);
390 bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message)
392 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
394 // Notify the bundle client.
395 m_page->injectedBundleUIClient().willRunJavaScriptConfirm(m_page, message, webFrame);
397 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
399 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
400 WebProcess::WaitForJavaScriptPopupFinished waiting;
402 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
408 bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
410 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
412 // Notify the bundle client.
413 m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame);
415 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
416 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
417 WebProcess::WaitForJavaScriptPopupFinished waiting;
419 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
422 return !result.isNull();
425 void WebChromeClient::setStatusbarText(const String& statusbarText)
427 // Notify the bundle client.
428 m_page->injectedBundleUIClient().willSetStatusbarText(m_page, statusbarText);
430 m_page->send(Messages::WebPageProxy::SetStatusText(statusbarText));
433 bool WebChromeClient::shouldInterruptJavaScript()
435 bool shouldInterrupt = false;
436 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ShouldInterruptJavaScript(), Messages::WebPageProxy::ShouldInterruptJavaScript::Reply(shouldInterrupt), m_page->pageID()))
439 return shouldInterrupt;
442 KeyboardUIMode WebChromeClient::keyboardUIMode()
444 return m_page->keyboardUIMode();
447 IntRect WebChromeClient::windowResizerRect() const
449 return m_page->windowResizerRect();
452 void WebChromeClient::invalidateRootView(const IntRect&, bool)
454 // Do nothing here, there's no concept of invalidating the window in the web process.
457 void WebChromeClient::invalidateContentsAndRootView(const IntRect& rect, bool)
459 if (Document* document = m_page->corePage()->mainFrame()->document()) {
460 if (document->printing())
464 m_page->drawingArea()->setNeedsDisplay(rect);
467 void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool)
469 if (Document* document = m_page->corePage()->mainFrame()->document()) {
470 if (document->printing())
474 m_page->pageDidScroll();
475 m_page->drawingArea()->setNeedsDisplay(rect);
478 void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollRect, const IntRect& clipRect)
480 m_page->pageDidScroll();
481 m_page->drawingArea()->scroll(intersection(scrollRect, clipRect), scrollOffset);
484 #if USE(TILED_BACKING_STORE)
485 void WebChromeClient::delegatedScrollRequested(const IntPoint& scrollOffset)
487 m_page->pageDidRequestScroll(scrollOffset);
491 IntPoint WebChromeClient::screenToRootView(const IntPoint& point) const
493 return m_page->screenToWindow(point);
496 IntRect WebChromeClient::rootViewToScreen(const IntRect& rect) const
498 return m_page->windowToScreen(rect);
501 PlatformPageClient WebChromeClient::platformPageClient() const
507 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
508 bool WebChromeClient::getStandaloneStatus()
510 bool standalone = false;
511 m_page->sendSync(Messages::WebPageProxy::GetStandaloneStatus(), Messages::WebPageProxy::GetStandaloneStatus::Reply(standalone), m_page->pageID());
516 #if ENABLE(TIZEN_SEARCH_PROVIDER)
517 void WebChromeClient::addSearchProvider(const String& baseURL, const String& engineURL)
519 m_page->send(Messages::WebPageProxy::AddSearchProvider(baseURL, engineURL));
522 unsigned long WebChromeClient::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
525 m_page->sendSync(Messages::WebPageProxy::IsSearchProviderInstalled(baseURL, engineURL), Messages::WebPageProxy::IsSearchProviderInstalled::Reply(result));
530 void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) const
532 if (!m_page->corePage()->settings()->frameFlatteningEnabled()) {
533 WebFrame* largestFrame = findLargestFrameInFrameSet(m_page);
534 if (largestFrame != m_cachedFrameSetLargestFrame.get()) {
535 m_cachedFrameSetLargestFrame = largestFrame;
536 m_page->send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0));
540 if (frame->page()->mainFrame() != frame)
543 #if PLATFORM(QT) || (PLATFORM(EFL) && USE(TILED_BACKING_STORE))
544 if (m_page->useFixedLayout()) {
545 // The below method updates the size().
546 m_page->resizeToContentsIfNeeded();
547 m_page->drawingArea()->layerTreeHost()->sizeDidChange(m_page->size());
550 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
551 // FIXME: Logic to calculate the node's position is inefficient.
552 Frame* focusedFrame = m_page->corePage()->focusController()->focusedFrame();
553 if(focusedFrame && focusedFrame->document() && focusedFrame->document()->focusedNode()) {
554 Node* node = focusedFrame->document()->focusedNode();
555 IntRect nodeRect = IntRect(0, 0, 0, 0);
557 nodeRect = WebCore::pixelSnappedIntRect(node->getRect());
558 Frame* mainFrame = m_page->corePage()->mainFrame();
559 Frame* frame = node->document()->frame();
561 while (frame && frame != mainFrame) {
562 owner = frame->ownerElement();
566 nodeRect.setX(nodeRect.x() + owner->getRect().x());
567 nodeRect.setY(nodeRect.y() + owner->getRect().y());
568 frame = owner->document()->frame();
570 // we have to divide (x, y) with pageZoomFactor because pageZoomFactor was applied to them.
571 nodeRect.setX(nodeRect.x() / m_page->pageScaleFactor());
572 nodeRect.setY(nodeRect.y() / m_page->pageScaleFactor());
574 m_page->send(Messages::WebPageProxy::FocusedNodeChanged(nodeRect));
578 m_page->send(Messages::WebPageProxy::DidChangeContentsSize(m_page->size()));
581 FrameView* frameView = frame->view();
582 if (frameView && !frameView->delegatesScrolling()) {
583 bool hasHorizontalScrollbar = frameView->horizontalScrollbar();
584 bool hasVerticalScrollbar = frameView->verticalScrollbar();
586 if (hasHorizontalScrollbar != m_cachedMainFrameHasHorizontalScrollbar || hasVerticalScrollbar != m_cachedMainFrameHasVerticalScrollbar) {
587 m_page->send(Messages::WebPageProxy::DidChangeScrollbarsForMainFrame(hasHorizontalScrollbar, hasVerticalScrollbar));
589 m_cachedMainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
590 m_cachedMainFrameHasVerticalScrollbar = hasVerticalScrollbar;
595 void WebChromeClient::scrollRectIntoView(const IntRect&) const
600 bool WebChromeClient::shouldUnavailablePluginMessageBeButton(RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
602 if (pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion) {
603 // FIXME: <rdar://problem/8794397> We should only return true when there is a
604 // missingPluginButtonClicked callback defined on the Page UI client.
611 void WebChromeClient::unavailablePluginButtonClicked(Element* element, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
613 ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag) || element->hasTagName(appletTag));
614 ASSERT(pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion);
616 HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element);
618 m_page->send(Messages::WebPageProxy::UnavailablePluginButtonClicked(pluginUnavailabilityReason, pluginElement->serviceType(), pluginElement->url(), pluginElement->getAttribute(pluginspageAttr)));
621 void WebChromeClient::scrollbarsModeDidChange() const
626 void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult, unsigned modifierFlags)
628 RefPtr<APIObject> userData;
630 // Notify the bundle client.
631 m_page->injectedBundleUIClient().mouseDidMoveOverElement(m_page, hitTestResult, static_cast<WebEvent::Modifiers>(modifierFlags), userData);
633 // Notify the UIProcess.
634 WebHitTestResult::Data webHitTestResultData(hitTestResult);
635 m_page->send(Messages::WebPageProxy::MouseDidMoveOverElement(webHitTestResultData, modifierFlags, InjectedBundleUserMessageEncoder(userData.get())));
638 void WebChromeClient::setToolTip(const String& toolTip, TextDirection)
640 // Only send a tool tip to the WebProcess if it has changed since the last time this function was called.
642 if (toolTip == m_cachedToolTip)
644 m_cachedToolTip = toolTip;
646 m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip));
649 void WebChromeClient::print(Frame* frame)
651 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
652 m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply());
655 #if ENABLE(SQL_DATABASE)
656 void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName)
658 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
659 SecurityOrigin* origin = frame->document()->securityOrigin();
661 DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseName, origin);
662 uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin);
663 uint64_t currentOriginUsage = DatabaseTracker::tracker().usageForOrigin(origin);
664 uint64_t newQuota = 0;
665 #if ENABLE(TIZEN_SQL_DATABASE)
666 const uint64_t defaultQuota = 5 * 1024 * 1024;
667 uint64_t requirement = currentQuota + details.expectedUsage();
668 if (requirement <= defaultQuota)
669 newQuota = requirement;
671 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
672 bool allowExceed = false;
673 WebProcess::shared().connection()->sendSync(
674 Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), details.displayName(), details.expectedUsage()),
675 Messages::WebPageProxy::ExceededDatabaseQuota::Reply(allowExceed), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags);
677 newQuota = currentQuota + details.expectedUsage();
679 newQuota = currentQuota;
682 WebProcess::shared().connection()->sendSync(
683 Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
684 Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID());
687 DatabaseTracker::tracker().setQuota(origin, newQuota);
692 void WebChromeClient::reachedMaxAppCacheSize(int64_t)
697 void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t)
702 #if ENABLE(TIZEN_APPLICATION_CACHE)
703 bool WebChromeClient::requestApplicationCachePermission(Frame* frame)
705 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
706 SecurityOrigin* origin = frame->document()->securityOrigin();
708 unsigned syncSendFlags = WebCore::AXObjectCache::accessibilityEnabled() ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
710 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
711 WebProcess::WaitForJavaScriptPopupFinished waiting;
714 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RequestApplicationCachePermission(webFrame->frameID(), origin->databaseIdentifier()), Messages::WebPageProxy::RequestApplicationCachePermission::Reply(allow), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
721 #if ENABLE(DASHBOARD_SUPPORT)
722 void WebChromeClient::dashboardRegionsChanged()
728 void WebChromeClient::populateVisitedLinks()
732 FloatRect WebChromeClient::customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect)
738 void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
739 bool behindText, bool entireLine)
744 bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
746 generatedFilename = m_page->injectedBundleUIClient().shouldGenerateFileForUpload(m_page, path);
747 return !generatedFilename.isNull();
750 String WebChromeClient::generateReplacementFile(const String& path)
752 return m_page->injectedBundleUIClient().generateFileForUpload(m_page, path);
755 bool WebChromeClient::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
757 if (!m_page->injectedBundleUIClient().shouldPaintCustomOverhangArea())
760 m_page->injectedBundleUIClient().paintCustomOverhangArea(m_page, context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
764 #if ENABLE(INPUT_TYPE_COLOR)
765 PassOwnPtr<ColorChooser> WebChromeClient::createColorChooser(ColorChooserClient* client, const Color& initialColor)
767 if (m_page->activeColorChooser())
770 return adoptPtr(new WebColorChooser(m_page, client, initialColor));
774 void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
776 if (m_page->activeOpenPanelResultListener())
779 RefPtr<FileChooser> fileChooser = prpFileChooser;
781 m_page->setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser.get()));
782 m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), fileChooser->settings()));
785 void WebChromeClient::loadIconForFiles(const Vector<String>& filenames, FileIconLoader* loader)
787 loader->notifyFinished(Icon::createIconForFiles(filenames));
790 void WebChromeClient::setCursor(const WebCore::Cursor& cursor)
792 #if USE(LAZY_NATIVE_CURSOR)
793 m_page->send(Messages::WebPageProxy::SetCursor(cursor));
797 void WebChromeClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
799 m_page->send(Messages::WebPageProxy::SetCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves));
802 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
803 void WebChromeClient::scheduleAnimation()
805 #if USE(UI_SIDE_COMPOSITING)
806 m_page->drawingArea()->layerTreeHost()->scheduleAnimation();
811 void WebChromeClient::formStateDidChange(const Node*)
816 bool WebChromeClient::selectItemWritingDirectionIsNatural()
825 bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
834 bool WebChromeClient::hasOpenedPopup() const
840 PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
842 return WebPopupMenu::create(m_page, client);
845 PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
847 return WebSearchPopupMenu::create(m_page, client);
850 #if USE(ACCELERATED_COMPOSITING)
851 void WebChromeClient::attachRootGraphicsLayer(Frame*, GraphicsLayer* layer)
854 m_page->enterAcceleratedCompositingMode(layer);
856 m_page->exitAcceleratedCompositingMode();
859 void WebChromeClient::setNeedsOneShotDrawingSynchronization()
861 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
862 if (m_page->drawingArea())
863 m_page->drawingArea()->setNeedsOneShotDrawingSynchronization();
869 void WebChromeClient::scheduleCompositingLayerSync()
871 if (m_page->drawingArea())
872 m_page->drawingArea()->scheduleCompositingLayerSync();
875 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
876 void WebChromeClient::addOrUpdateScrollingLayer(WebCore::Node*, WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer, const WebCore::IntSize& scrollSize)
878 if (!m_page->drawingArea())
880 m_page->drawingArea()->addOrUpdateScrollingLayer(scrollingLayer, contentsLayer, scrollSize);
883 void WebChromeClient::removeScrollingLayer(WebCore::Node*, WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer)
885 if (!m_page->drawingArea())
887 m_page->drawingArea()->removeScrollingLayer(scrollingLayer, contentsLayer);
889 #endif // ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
890 #endif // USE(ACCELERATED_COMPOSITING)
892 #if PLATFORM(WIN) && USE(AVFOUNDATION)
893 WebCore::GraphicsDeviceAdapter* WebChromeClient::graphicsDeviceAdapter() const
895 if (!m_page->drawingArea())
897 return m_page->drawingArea()->layerTreeHost()->graphicsDeviceAdapter();
901 #if ENABLE(TOUCH_EVENTS)
902 void WebChromeClient::needTouchEvents(bool needTouchEvents)
904 m_page->send(Messages::WebPageProxy::NeedTouchEvents(needTouchEvents));
909 void WebChromeClient::setLastSetCursorToCurrentCursor()
914 #if ENABLE(FULLSCREEN_API)
915 bool WebChromeClient::supportsFullScreenForElement(const WebCore::Element* element, bool withKeyboard)
917 return m_page->fullScreenManager()->supportsFullScreen(withKeyboard);
920 void WebChromeClient::enterFullScreenForElement(WebCore::Element* element)
922 m_page->fullScreenManager()->enterFullScreenForElement(element);
925 void WebChromeClient::exitFullScreenForElement(WebCore::Element* element)
927 m_page->fullScreenManager()->exitFullScreenForElement(element);
931 void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments&) const
933 #if USE(TILED_BACKING_STORE)
934 if (!m_page->useFixedLayout())
937 m_page->sendViewportAttributesChanged();
941 void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
943 m_page->send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
946 void WebChromeClient::recommendedScrollbarStyleDidChange(int32_t newStyle)
948 m_page->send(Messages::WebPageProxy::RecommendedScrollbarStyleDidChange(newStyle));
951 bool WebChromeClient::shouldRubberBandInDirection(WebCore::ScrollDirection direction) const
953 ASSERT(direction != WebCore::ScrollUp && direction != WebCore::ScrollDown);
955 if (direction == WebCore::ScrollLeft)
956 return m_page->injectedBundleUIClient().shouldRubberBandInDirection(m_page, WKScrollDirectionLeft);
957 if (direction == WebCore::ScrollRight)
958 return m_page->injectedBundleUIClient().shouldRubberBandInDirection(m_page, WKScrollDirectionRight);
960 ASSERT_NOT_REACHED();
964 void WebChromeClient::numWheelEventHandlersChanged(unsigned count)
966 m_page->numWheelEventHandlersChanged(count);
969 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
970 bool WebChromeClient::lockOrientation(int willLockOrientation)
973 m_page->sendSync(Messages::WebPageProxy::LockOrientation(willLockOrientation), Messages::WebPageProxy::LockOrientation::Reply(result));
976 void WebChromeClient::unlockOrientation()
978 m_page->send(Messages::WebPageProxy::UnlockOrientation());
982 void WebChromeClient::logDiagnosticMessage(const String& message, const String& description, const String& success)
984 if (!m_page->corePage()->settings()->diagnosticLoggingEnabled())
987 m_page->injectedBundleDiagnosticLoggingClient().logDiagnosticMessage(m_page, message, description, success);
990 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
991 void WebChromeClient::requestVisibleContentRectRestore(const IntPoint& scrollOffset, float scale)
993 m_page->pageDidRequestRestoreVisibleContentRect(scrollOffset, scale);
996 float WebChromeClient::contentsScaleFactor() const
998 if (!m_page->drawingArea())
1000 return m_page->drawingArea()->layerTreeHost()->contentsScaleFactor();
1004 #if ENABLE(TIZEN_SCREEN_READER)
1005 void WebChromeClient::rendererWillBeDestroyed(RenderObject* object)
1007 m_page->updateScreenReaderFocus(object);
1011 #if ENABLE(TIZEN_INDEXED_DATABASE)
1012 bool WebChromeClient::exceededIndexedDatabaseQuota(Frame* frame, int64_t currentQuota)
1014 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
1015 SecurityOrigin* origin = frame->document()->securityOrigin();
1017 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
1019 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
1020 WebProcess::WaitForJavaScriptPopupFinished waiting;
1022 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ExceededIndexedDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), currentQuota), Messages::WebPageProxy::ExceededIndexedDatabaseQuota::Reply(allow), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
1029 } // namespace WebKit