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 using namespace WebCore;
66 using namespace HTMLNames;
70 static double area(WebFrame* frame)
72 IntSize size = frame->visibleContentBoundsExcludingScrollbars().size();
73 return static_cast<double>(size.height()) * size.width();
77 static WebFrame* findLargestFrameInFrameSet(WebPage* page)
79 // Approximate what a user could consider a default target frame for application menu operations.
81 WebFrame* mainFrame = page->mainWebFrame();
82 if (!mainFrame->isFrameSet())
85 WebFrame* largestSoFar = 0;
87 RefPtr<ImmutableArray> frameChildren = mainFrame->childFrames();
88 size_t count = frameChildren->size();
89 for (size_t i = 0; i < count; ++i) {
90 WebFrame* childFrame = frameChildren->at<WebFrame>(i);
91 if (!largestSoFar || area(childFrame) > area(largestSoFar))
92 largestSoFar = childFrame;
98 void WebChromeClient::chromeDestroyed()
103 void WebChromeClient::setWindowRect(const FloatRect& windowFrame)
105 m_page->send(Messages::WebPageProxy::SetWindowFrame(windowFrame));
108 FloatRect WebChromeClient::windowRect()
110 FloatRect newWindowFrame;
112 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetWindowFrame(), Messages::WebPageProxy::GetWindowFrame::Reply(newWindowFrame), m_page->pageID()))
115 return newWindowFrame;
118 FloatRect WebChromeClient::pageRect()
120 return FloatRect(FloatPoint(), m_page->size());
123 void WebChromeClient::focus()
125 m_page->send(Messages::WebPageProxy::SetFocus(true));
128 void WebChromeClient::unfocus()
130 m_page->send(Messages::WebPageProxy::SetFocus(false));
134 void WebChromeClient::makeFirstResponder()
136 m_page->send(Messages::WebPageProxy::MakeFirstResponder());
140 bool WebChromeClient::canTakeFocus(FocusDirection)
146 void WebChromeClient::takeFocus(FocusDirection direction)
148 m_page->send(Messages::WebPageProxy::TakeFocus(direction));
151 void WebChromeClient::focusedNodeChanged(Node* node)
154 IntRect nodeRect = IntRect(0, 0, 0, 0);
156 nodeRect = WebCore::pixelSnappedIntRect(node->getRect());
157 Frame* mainFrame = m_page->corePage()->mainFrame();
158 Frame* frame = node->document()->frame();
160 while (frame && frame != mainFrame) {
161 owner = frame->ownerElement();
163 nodeRect.setX(nodeRect.x() + owner->getRect().x());
164 nodeRect.setY(nodeRect.y() + owner->getRect().y());
165 frame = owner->document()->frame();
170 // we have to divide (x, y) with pageZoomFactor because pageZoomFactor was applied to them.
171 nodeRect.setX(nodeRect.x() / m_page->pageScaleFactor());
172 nodeRect.setY(nodeRect.y() / m_page->pageScaleFactor());
174 m_page->send(Messages::WebPageProxy::FocusedNodeChanged(nodeRect));
180 void WebChromeClient::focusedFrameChanged(Frame* frame)
182 WebFrame* webFrame = frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : 0;
184 WebProcess::shared().connection()->send(Messages::WebPageProxy::FocusedFrameChanged(webFrame ? webFrame->frameID() : 0), m_page->pageID());
187 Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& windowFeatures, const NavigationAction& navigationAction)
189 uint32_t modifiers = static_cast<uint32_t>(InjectedBundleNavigationAction::modifiersForNavigationAction(navigationAction));
190 int32_t mouseButton = static_cast<int32_t>(InjectedBundleNavigationAction::mouseButtonForNavigationAction(navigationAction));
192 uint64_t newPageID = 0;
193 WebPageCreationParameters parameters;
194 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::CreateNewPage(request.resourceRequest(), windowFeatures, modifiers, mouseButton), Messages::WebPageProxy::CreateNewPage::Reply(newPageID, parameters), m_page->pageID()))
200 WebProcess::shared().createWebPage(newPageID, parameters);
201 return WebProcess::shared().webPage(newPageID)->corePage();
204 void WebChromeClient::show()
209 bool WebChromeClient::canRunModal()
211 return m_page->canRunModal();
214 void WebChromeClient::runModal()
219 void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible)
221 m_page->send(Messages::WebPageProxy::SetToolbarsAreVisible(toolbarsAreVisible));
224 bool WebChromeClient::toolbarsVisible()
226 WKBundlePageUIElementVisibility toolbarsVisibility = m_page->injectedBundleUIClient().toolbarsAreVisible(m_page);
227 if (toolbarsVisibility != WKBundlePageUIElementVisibilityUnknown)
228 return toolbarsVisibility == WKBundlePageUIElementVisible;
230 bool toolbarsAreVisible = true;
231 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetToolbarsAreVisible(), Messages::WebPageProxy::GetToolbarsAreVisible::Reply(toolbarsAreVisible), m_page->pageID()))
234 return toolbarsAreVisible;
237 void WebChromeClient::setStatusbarVisible(bool statusBarIsVisible)
239 m_page->send(Messages::WebPageProxy::SetStatusBarIsVisible(statusBarIsVisible));
242 bool WebChromeClient::statusbarVisible()
244 WKBundlePageUIElementVisibility statusbarVisibility = m_page->injectedBundleUIClient().statusBarIsVisible(m_page);
245 if (statusbarVisibility != WKBundlePageUIElementVisibilityUnknown)
246 return statusbarVisibility == WKBundlePageUIElementVisible;
248 bool statusBarIsVisible = true;
249 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetStatusBarIsVisible(), Messages::WebPageProxy::GetStatusBarIsVisible::Reply(statusBarIsVisible), m_page->pageID()))
252 return statusBarIsVisible;
255 void WebChromeClient::setScrollbarsVisible(bool)
260 bool WebChromeClient::scrollbarsVisible()
266 void WebChromeClient::setMenubarVisible(bool menuBarVisible)
268 m_page->send(Messages::WebPageProxy::SetMenuBarIsVisible(menuBarVisible));
271 bool WebChromeClient::menubarVisible()
273 WKBundlePageUIElementVisibility menubarVisibility = m_page->injectedBundleUIClient().menuBarIsVisible(m_page);
274 if (menubarVisibility != WKBundlePageUIElementVisibilityUnknown)
275 return menubarVisibility == WKBundlePageUIElementVisible;
277 bool menuBarIsVisible = true;
278 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetMenuBarIsVisible(), Messages::WebPageProxy::GetMenuBarIsVisible::Reply(menuBarIsVisible), m_page->pageID()))
281 return menuBarIsVisible;
284 void WebChromeClient::setResizable(bool resizable)
286 m_page->send(Messages::WebPageProxy::SetIsResizable(resizable));
289 #if ENABLE(TIZEN_DISPLAY_MESSAGE_TO_CONSOLE)
290 void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel level, const String& message, unsigned int lineNumber, const String& sourceID)
292 void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID)
295 #if ENABLE(TIZEN_DISPLAY_MESSAGE_TO_CONSOLE) // Request for WAC SDK
298 newMessage = String::format("%s:%d:%s", sourceID.utf8().data(), lineNumber, message.utf8().data());
300 newMessage = message;
303 case WarningMessageLevel:
304 TIZEN_CONSOLEW("%s", newMessage.utf8().data());
306 case ErrorMessageLevel:
307 TIZEN_CONSOLEE("%s", newMessage.utf8().data());
309 case LogMessageLevel:
310 TIZEN_CONSOLED("%s", newMessage.utf8().data());
313 TIZEN_CONSOLEI("%s", newMessage.utf8().data());
317 // Notify the bundle client.
318 m_page->injectedBundleUIClient().willAddMessageToConsole(m_page, message, lineNumber);
323 bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
325 return m_page->canRunBeforeUnloadConfirmPanel();
328 bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
330 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
331 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
333 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
334 bool shouldClose = false;
335 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
336 WebProcess::WaitForJavaScriptPopupFinished waiting;
338 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
343 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
345 bool shouldClose = false;
346 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID()))
353 void WebChromeClient::closeWindowSoon()
355 // FIXME: This code assumes that the client will respond to a close page
356 // message by actually closing the page. Safari does this, but there is
357 // no guarantee that other applications will, which will leave this page
358 // half detached. This approach is an inherent limitation making parts of
359 // a close execute synchronously as part of window.close, but other parts
362 m_page->corePage()->setGroupName(String());
364 if (WebFrame* frame = m_page->mainWebFrame()) {
365 if (Frame* coreFrame = frame->coreFrame())
366 coreFrame->loader()->stopForUserCancel();
372 void WebChromeClient::runJavaScriptAlert(Frame* frame, const String& alertText)
374 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
376 // Notify the bundle client.
377 m_page->injectedBundleUIClient().willRunJavaScriptAlert(m_page, alertText, webFrame);
379 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
380 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
381 WebProcess::WaitForJavaScriptPopupFinished waiting;
383 WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags);
386 bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message)
388 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
390 // Notify the bundle client.
391 m_page->injectedBundleUIClient().willRunJavaScriptConfirm(m_page, message, webFrame);
393 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
395 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
396 WebProcess::WaitForJavaScriptPopupFinished waiting;
398 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
404 bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
406 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
408 // Notify the bundle client.
409 m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame);
411 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
412 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
413 WebProcess::WaitForJavaScriptPopupFinished waiting;
415 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
418 return !result.isNull();
421 void WebChromeClient::setStatusbarText(const String& statusbarText)
423 // Notify the bundle client.
424 m_page->injectedBundleUIClient().willSetStatusbarText(m_page, statusbarText);
426 m_page->send(Messages::WebPageProxy::SetStatusText(statusbarText));
429 bool WebChromeClient::shouldInterruptJavaScript()
431 bool shouldInterrupt = false;
432 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ShouldInterruptJavaScript(), Messages::WebPageProxy::ShouldInterruptJavaScript::Reply(shouldInterrupt), m_page->pageID()))
435 return shouldInterrupt;
438 KeyboardUIMode WebChromeClient::keyboardUIMode()
440 return m_page->keyboardUIMode();
443 IntRect WebChromeClient::windowResizerRect() const
445 return m_page->windowResizerRect();
448 void WebChromeClient::invalidateRootView(const IntRect&, bool)
450 // Do nothing here, there's no concept of invalidating the window in the web process.
453 void WebChromeClient::invalidateContentsAndRootView(const IntRect& rect, bool)
455 if (Document* document = m_page->corePage()->mainFrame()->document()) {
456 if (document->printing())
460 m_page->drawingArea()->setNeedsDisplay(rect);
463 void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool)
465 if (Document* document = m_page->corePage()->mainFrame()->document()) {
466 if (document->printing())
470 m_page->pageDidScroll();
471 m_page->drawingArea()->setNeedsDisplay(rect);
474 void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollRect, const IntRect& clipRect)
476 m_page->pageDidScroll();
477 m_page->drawingArea()->scroll(intersection(scrollRect, clipRect), scrollOffset);
480 #if USE(TILED_BACKING_STORE)
481 void WebChromeClient::delegatedScrollRequested(const IntPoint& scrollOffset)
483 m_page->pageDidRequestScroll(scrollOffset);
487 IntPoint WebChromeClient::screenToRootView(const IntPoint& point) const
489 return m_page->screenToWindow(point);
492 IntRect WebChromeClient::rootViewToScreen(const IntRect& rect) const
494 return m_page->windowToScreen(rect);
497 PlatformPageClient WebChromeClient::platformPageClient() const
503 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
504 bool WebChromeClient::getStandaloneStatus()
506 bool standalone = false;
507 m_page->sendSync(Messages::WebPageProxy::GetStandaloneStatus(), Messages::WebPageProxy::GetStandaloneStatus::Reply(standalone), m_page->pageID());
512 #if ENABLE(TIZEN_SEARCH_PROVIDER)
513 void WebChromeClient::addSearchProvider(const String& baseURL, const String& engineURL)
515 m_page->send(Messages::WebPageProxy::AddSearchProvider(baseURL, engineURL));
518 unsigned long WebChromeClient::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
521 m_page->sendSync(Messages::WebPageProxy::IsSearchProviderInstalled(baseURL, engineURL), Messages::WebPageProxy::IsSearchProviderInstalled::Reply(result));
526 void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) const
528 if (!m_page->corePage()->settings()->frameFlatteningEnabled()) {
529 WebFrame* largestFrame = findLargestFrameInFrameSet(m_page);
530 if (largestFrame != m_cachedFrameSetLargestFrame.get()) {
531 m_cachedFrameSetLargestFrame = largestFrame;
532 m_page->send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0));
536 if (frame->page()->mainFrame() != frame)
539 #if PLATFORM(QT) || (PLATFORM(EFL) && USE(TILED_BACKING_STORE))
540 if (m_page->useFixedLayout()) {
541 // The below method updates the size().
542 m_page->resizeToContentsIfNeeded();
543 m_page->drawingArea()->layerTreeHost()->sizeDidChange(m_page->size());
546 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
547 // FIXME: Logic to calculate the node's position is inefficient.
548 Frame* focusedFrame = m_page->corePage()->focusController()->focusedFrame();
549 if(focusedFrame && focusedFrame->document() && focusedFrame->document()->focusedNode()) {
550 Node* node = focusedFrame->document()->focusedNode();
551 IntRect nodeRect = IntRect(0, 0, 0, 0);
553 nodeRect = WebCore::pixelSnappedIntRect(node->getRect());
554 Frame* mainFrame = m_page->corePage()->mainFrame();
555 Frame* frame = node->document()->frame();
557 while (frame && frame != mainFrame) {
558 owner = frame->ownerElement();
562 nodeRect.setX(nodeRect.x() + owner->getRect().x());
563 nodeRect.setY(nodeRect.y() + owner->getRect().y());
564 frame = owner->document()->frame();
566 // we have to divide (x, y) with pageZoomFactor because pageZoomFactor was applied to them.
567 nodeRect.setX(nodeRect.x() / m_page->pageScaleFactor());
568 nodeRect.setY(nodeRect.y() / m_page->pageScaleFactor());
570 m_page->send(Messages::WebPageProxy::FocusedNodeChanged(nodeRect));
574 m_page->send(Messages::WebPageProxy::DidChangeContentsSize(m_page->size()));
577 FrameView* frameView = frame->view();
578 if (frameView && !frameView->delegatesScrolling()) {
579 bool hasHorizontalScrollbar = frameView->horizontalScrollbar();
580 bool hasVerticalScrollbar = frameView->verticalScrollbar();
582 if (hasHorizontalScrollbar != m_cachedMainFrameHasHorizontalScrollbar || hasVerticalScrollbar != m_cachedMainFrameHasVerticalScrollbar) {
583 m_page->send(Messages::WebPageProxy::DidChangeScrollbarsForMainFrame(hasHorizontalScrollbar, hasVerticalScrollbar));
585 m_cachedMainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
586 m_cachedMainFrameHasVerticalScrollbar = hasVerticalScrollbar;
591 void WebChromeClient::scrollRectIntoView(const IntRect&) const
596 bool WebChromeClient::shouldUnavailablePluginMessageBeButton(RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
598 if (pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion) {
599 // FIXME: <rdar://problem/8794397> We should only return true when there is a
600 // missingPluginButtonClicked callback defined on the Page UI client.
607 void WebChromeClient::unavailablePluginButtonClicked(Element* element, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
609 ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag) || element->hasTagName(appletTag));
610 ASSERT(pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion);
612 HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element);
614 m_page->send(Messages::WebPageProxy::UnavailablePluginButtonClicked(pluginUnavailabilityReason, pluginElement->serviceType(), pluginElement->url(), pluginElement->getAttribute(pluginspageAttr)));
617 void WebChromeClient::scrollbarsModeDidChange() const
622 void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult, unsigned modifierFlags)
624 RefPtr<APIObject> userData;
626 // Notify the bundle client.
627 m_page->injectedBundleUIClient().mouseDidMoveOverElement(m_page, hitTestResult, static_cast<WebEvent::Modifiers>(modifierFlags), userData);
629 // Notify the UIProcess.
630 WebHitTestResult::Data webHitTestResultData(hitTestResult);
631 m_page->send(Messages::WebPageProxy::MouseDidMoveOverElement(webHitTestResultData, modifierFlags, InjectedBundleUserMessageEncoder(userData.get())));
634 void WebChromeClient::setToolTip(const String& toolTip, TextDirection)
636 // Only send a tool tip to the WebProcess if it has changed since the last time this function was called.
638 if (toolTip == m_cachedToolTip)
640 m_cachedToolTip = toolTip;
642 m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip));
645 void WebChromeClient::print(Frame* frame)
647 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
648 m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply());
651 #if ENABLE(SQL_DATABASE)
652 void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName)
654 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
655 SecurityOrigin* origin = frame->document()->securityOrigin();
657 DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseName, origin);
658 uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin);
660 #if ENABLE(TIZEN_SQL_DATABASE)
661 uint64_t newQuota = 0;
662 const uint64_t defaultQuota = 5 * 1024 * 1024;
663 uint64_t requirement = currentQuota + details.expectedUsage();
664 if (requirement <= defaultQuota)
665 newQuota = requirement;
667 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
668 bool allowExceed = false;
669 WebProcess::shared().connection()->sendSync(
670 Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), details.displayName(), details.expectedUsage()),
671 Messages::WebPageProxy::ExceededDatabaseQuota::Reply(allowExceed), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags);
673 newQuota = currentQuota + details.expectedUsage();
675 newQuota = currentQuota;
678 uint64_t currentOriginUsage = DatabaseTracker::tracker().usageForOrigin(origin);
679 uint64_t newQuota = 0;
680 WebProcess::shared().connection()->sendSync(
681 Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
682 Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID());
685 DatabaseTracker::tracker().setQuota(origin, newQuota);
690 void WebChromeClient::reachedMaxAppCacheSize(int64_t)
695 void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t)
700 #if ENABLE(TIZEN_APPLICATION_CACHE)
701 bool WebChromeClient::requestApplicationCachePermission(Frame* frame)
703 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
704 SecurityOrigin* origin = frame->document()->securityOrigin();
706 unsigned syncSendFlags = WebCore::AXObjectCache::accessibilityEnabled() ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
708 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
709 WebProcess::WaitForJavaScriptPopupFinished waiting;
712 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RequestApplicationCachePermission(webFrame->frameID(), origin->databaseIdentifier()), Messages::WebPageProxy::RequestApplicationCachePermission::Reply(allow), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
719 #if ENABLE(DASHBOARD_SUPPORT)
720 void WebChromeClient::dashboardRegionsChanged()
726 void WebChromeClient::populateVisitedLinks()
730 FloatRect WebChromeClient::customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect)
736 void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
737 bool behindText, bool entireLine)
742 bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
744 generatedFilename = m_page->injectedBundleUIClient().shouldGenerateFileForUpload(m_page, path);
745 return !generatedFilename.isNull();
748 String WebChromeClient::generateReplacementFile(const String& path)
750 return m_page->injectedBundleUIClient().generateFileForUpload(m_page, path);
753 bool WebChromeClient::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
755 if (!m_page->injectedBundleUIClient().shouldPaintCustomOverhangArea())
758 m_page->injectedBundleUIClient().paintCustomOverhangArea(m_page, context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
762 #if ENABLE(INPUT_TYPE_COLOR)
763 PassOwnPtr<ColorChooser> WebChromeClient::createColorChooser(ColorChooserClient* client, const Color& initialColor)
765 if (m_page->activeColorChooser())
768 return adoptPtr(new WebColorChooser(m_page, client, initialColor));
772 void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
775 if (m_page->activeOpenPanelResultListener())
776 m_page->cancelForOpenPanel();
778 if (m_page->activeOpenPanelResultListener())
782 RefPtr<FileChooser> fileChooser = prpFileChooser;
784 m_page->setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser.get()));
785 m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), fileChooser->settings()));
788 void WebChromeClient::loadIconForFiles(const Vector<String>& filenames, FileIconLoader* loader)
790 loader->notifyFinished(Icon::createIconForFiles(filenames));
793 void WebChromeClient::setCursor(const WebCore::Cursor& cursor)
795 #if USE(LAZY_NATIVE_CURSOR)
796 m_page->send(Messages::WebPageProxy::SetCursor(cursor));
800 void WebChromeClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
802 m_page->send(Messages::WebPageProxy::SetCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves));
805 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
806 void WebChromeClient::scheduleAnimation()
808 #if USE(UI_SIDE_COMPOSITING)
809 m_page->drawingArea()->layerTreeHost()->scheduleAnimation();
814 void WebChromeClient::formStateDidChange(const Node*)
819 bool WebChromeClient::selectItemWritingDirectionIsNatural()
828 bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
837 bool WebChromeClient::hasOpenedPopup() const
843 PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
845 return WebPopupMenu::create(m_page, client);
848 PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
850 return WebSearchPopupMenu::create(m_page, client);
853 #if USE(ACCELERATED_COMPOSITING)
854 void WebChromeClient::attachRootGraphicsLayer(Frame*, GraphicsLayer* layer)
857 m_page->enterAcceleratedCompositingMode(layer);
859 m_page->exitAcceleratedCompositingMode();
862 void WebChromeClient::setNeedsOneShotDrawingSynchronization()
864 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
865 if (m_page->drawingArea())
866 m_page->drawingArea()->setNeedsOneShotDrawingSynchronization();
872 void WebChromeClient::scheduleCompositingLayerSync()
874 if (m_page->drawingArea())
875 m_page->drawingArea()->scheduleCompositingLayerSync();
878 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
879 void WebChromeClient::addOrUpdateScrollingLayer(WebCore::Node*, WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer, const WebCore::IntSize& scrollSize)
881 if (!m_page->drawingArea())
883 m_page->drawingArea()->addOrUpdateScrollingLayer(scrollingLayer, contentsLayer, scrollSize);
886 void WebChromeClient::removeScrollingLayer(WebCore::Node*, WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer)
888 if (!m_page->drawingArea())
890 m_page->drawingArea()->removeScrollingLayer(scrollingLayer, contentsLayer);
892 #endif // ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
893 #endif // USE(ACCELERATED_COMPOSITING)
895 #if PLATFORM(WIN) && USE(AVFOUNDATION)
896 WebCore::GraphicsDeviceAdapter* WebChromeClient::graphicsDeviceAdapter() const
898 if (!m_page->drawingArea())
900 return m_page->drawingArea()->layerTreeHost()->graphicsDeviceAdapter();
904 #if ENABLE(TOUCH_EVENTS)
905 void WebChromeClient::needTouchEvents(bool needTouchEvents)
907 m_page->send(Messages::WebPageProxy::NeedTouchEvents(needTouchEvents));
912 void WebChromeClient::setLastSetCursorToCurrentCursor()
917 #if ENABLE(FULLSCREEN_API)
918 bool WebChromeClient::supportsFullScreenForElement(const WebCore::Element* element, bool withKeyboard)
920 return m_page->fullScreenManager()->supportsFullScreen(withKeyboard);
923 void WebChromeClient::enterFullScreenForElement(WebCore::Element* element)
925 m_page->fullScreenManager()->enterFullScreenForElement(element);
928 void WebChromeClient::exitFullScreenForElement(WebCore::Element* element)
930 m_page->fullScreenManager()->exitFullScreenForElement(element);
934 void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments&) const
936 #if USE(TILED_BACKING_STORE)
937 if (!m_page->useFixedLayout())
940 m_page->sendViewportAttributesChanged();
944 void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
946 m_page->send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
949 void WebChromeClient::recommendedScrollbarStyleDidChange(int32_t newStyle)
951 m_page->send(Messages::WebPageProxy::RecommendedScrollbarStyleDidChange(newStyle));
954 bool WebChromeClient::shouldRubberBandInDirection(WebCore::ScrollDirection direction) const
956 ASSERT(direction != WebCore::ScrollUp && direction != WebCore::ScrollDown);
958 if (direction == WebCore::ScrollLeft)
959 return m_page->injectedBundleUIClient().shouldRubberBandInDirection(m_page, WKScrollDirectionLeft);
960 if (direction == WebCore::ScrollRight)
961 return m_page->injectedBundleUIClient().shouldRubberBandInDirection(m_page, WKScrollDirectionRight);
963 ASSERT_NOT_REACHED();
967 void WebChromeClient::numWheelEventHandlersChanged(unsigned count)
969 m_page->numWheelEventHandlersChanged(count);
972 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
973 bool WebChromeClient::lockOrientation(int willLockOrientation)
976 m_page->sendSync(Messages::WebPageProxy::LockOrientation(willLockOrientation), Messages::WebPageProxy::LockOrientation::Reply(result));
979 void WebChromeClient::unlockOrientation()
981 m_page->send(Messages::WebPageProxy::UnlockOrientation());
985 void WebChromeClient::logDiagnosticMessage(const String& message, const String& description, const String& success)
987 if (!m_page->corePage()->settings()->diagnosticLoggingEnabled())
990 m_page->injectedBundleDiagnosticLoggingClient().logDiagnosticMessage(m_page, message, description, success);
993 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
994 void WebChromeClient::requestVisibleContentRectRestore(const IntPoint& scrollOffset, float scale)
996 m_page->pageDidRequestRestoreVisibleContentRect(scrollOffset, scale);
999 float WebChromeClient::contentsScaleFactor() const
1001 if (!m_page->drawingArea())
1003 return m_page->drawingArea()->layerTreeHost()->contentsScaleFactor();
1008 void WebChromeClient::rendererWillBeDestroyed(RenderObject* object)
1010 #if ENABLE(TIZEN_SCREEN_READER)
1011 m_page->updateScreenReaderFocus(object);
1014 #if ENABLE(TIZEN_ISF_PORT)
1015 if (object->node() && object->node()->isRootEditableElement())
1016 m_page->send(Messages::WebPageProxy::RemoveInputMethodContext(reinterpret_cast<uintptr_t>(object->node())));
1021 #if ENABLE(TIZEN_INDEXED_DATABASE)
1022 bool WebChromeClient::exceededIndexedDatabaseQuota(Frame* frame, int64_t currentQuota)
1024 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
1025 SecurityOrigin* origin = frame->document()->securityOrigin();
1027 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
1029 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
1030 WebProcess::WaitForJavaScriptPopupFinished waiting;
1032 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))
1039 #if ENABLE(TIZEN_FILE_SYSTEM)
1040 bool WebChromeClient::exceededLocalFileSystemQuota(Frame* frame, int64_t currentQuota)
1042 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
1043 SecurityOrigin* origin = frame->document()->securityOrigin();
1045 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
1046 bool result = false;
1047 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
1048 WebProcess::WaitForJavaScriptPopupFinished waiting;
1050 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ExceededLocalFileSystemQuota(webFrame->frameID(), origin->databaseIdentifier(), currentQuota), Messages::WebPageProxy::ExceededLocalFileSystemQuota::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
1057 } // namespace WebKit