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* 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 #if ENABLE(TIZEN_WEBKIT2_SAME_PAGE_GROUP_FOR_CREATE_WINDOW_OPERATION)
202 WebCore::Page* page = WebProcess::shared().webPage(newPageID)->corePage();
203 page->setGroupName(frame->page()->groupName());
206 return WebProcess::shared().webPage(newPageID)->corePage();
209 void WebChromeClient::show()
214 bool WebChromeClient::canRunModal()
216 return m_page->canRunModal();
219 void WebChromeClient::runModal()
224 void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible)
226 m_page->send(Messages::WebPageProxy::SetToolbarsAreVisible(toolbarsAreVisible));
229 bool WebChromeClient::toolbarsVisible()
231 WKBundlePageUIElementVisibility toolbarsVisibility = m_page->injectedBundleUIClient().toolbarsAreVisible(m_page);
232 if (toolbarsVisibility != WKBundlePageUIElementVisibilityUnknown)
233 return toolbarsVisibility == WKBundlePageUIElementVisible;
235 bool toolbarsAreVisible = true;
236 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetToolbarsAreVisible(), Messages::WebPageProxy::GetToolbarsAreVisible::Reply(toolbarsAreVisible), m_page->pageID()))
239 return toolbarsAreVisible;
242 void WebChromeClient::setStatusbarVisible(bool statusBarIsVisible)
244 m_page->send(Messages::WebPageProxy::SetStatusBarIsVisible(statusBarIsVisible));
247 bool WebChromeClient::statusbarVisible()
249 WKBundlePageUIElementVisibility statusbarVisibility = m_page->injectedBundleUIClient().statusBarIsVisible(m_page);
250 if (statusbarVisibility != WKBundlePageUIElementVisibilityUnknown)
251 return statusbarVisibility == WKBundlePageUIElementVisible;
253 bool statusBarIsVisible = true;
254 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetStatusBarIsVisible(), Messages::WebPageProxy::GetStatusBarIsVisible::Reply(statusBarIsVisible), m_page->pageID()))
257 return statusBarIsVisible;
260 void WebChromeClient::setScrollbarsVisible(bool)
265 bool WebChromeClient::scrollbarsVisible()
271 void WebChromeClient::setMenubarVisible(bool menuBarVisible)
273 m_page->send(Messages::WebPageProxy::SetMenuBarIsVisible(menuBarVisible));
276 bool WebChromeClient::menubarVisible()
278 WKBundlePageUIElementVisibility menubarVisibility = m_page->injectedBundleUIClient().menuBarIsVisible(m_page);
279 if (menubarVisibility != WKBundlePageUIElementVisibilityUnknown)
280 return menubarVisibility == WKBundlePageUIElementVisible;
282 bool menuBarIsVisible = true;
283 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetMenuBarIsVisible(), Messages::WebPageProxy::GetMenuBarIsVisible::Reply(menuBarIsVisible), m_page->pageID()))
286 return menuBarIsVisible;
289 void WebChromeClient::setResizable(bool resizable)
291 m_page->send(Messages::WebPageProxy::SetIsResizable(resizable));
294 #if ENABLE(TIZEN_DISPLAY_MESSAGE_TO_CONSOLE)
295 void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel level, const String& message, unsigned int lineNumber, const String& sourceID)
297 void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID)
300 #if ENABLE(TIZEN_DISPLAY_MESSAGE_TO_CONSOLE) // Request for WAC SDK
303 newMessage = String::format("%s:%d:%s", sourceID.utf8().data(), lineNumber, message.utf8().data());
305 newMessage = message;
308 case WarningMessageLevel:
309 TIZEN_CONSOLEW("%s", newMessage.utf8().data());
311 case ErrorMessageLevel:
312 TIZEN_CONSOLEE("%s", newMessage.utf8().data());
314 case LogMessageLevel:
315 TIZEN_CONSOLED("%s", newMessage.utf8().data());
318 TIZEN_CONSOLEI("%s", newMessage.utf8().data());
322 // Notify the bundle client.
323 m_page->injectedBundleUIClient().willAddMessageToConsole(m_page, message, lineNumber);
328 bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
330 return m_page->canRunBeforeUnloadConfirmPanel();
333 bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
335 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
336 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
338 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
339 bool shouldClose = false;
340 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
341 WebProcess::WaitForJavaScriptPopupFinished waiting;
343 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
348 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
350 bool shouldClose = false;
351 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID()))
358 void WebChromeClient::closeWindowSoon()
360 // FIXME: This code assumes that the client will respond to a close page
361 // message by actually closing the page. Safari does this, but there is
362 // no guarantee that other applications will, which will leave this page
363 // half detached. This approach is an inherent limitation making parts of
364 // a close execute synchronously as part of window.close, but other parts
367 m_page->corePage()->setGroupName(String());
369 if (WebFrame* frame = m_page->mainWebFrame()) {
370 if (Frame* coreFrame = frame->coreFrame())
371 coreFrame->loader()->stopForUserCancel();
377 void WebChromeClient::runJavaScriptAlert(Frame* frame, const String& alertText)
379 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
381 // Notify the bundle client.
382 m_page->injectedBundleUIClient().willRunJavaScriptAlert(m_page, alertText, webFrame);
384 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
385 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
386 WebProcess::WaitForJavaScriptPopupFinished waiting;
388 WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags);
391 bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message)
393 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
395 // Notify the bundle client.
396 m_page->injectedBundleUIClient().willRunJavaScriptConfirm(m_page, message, webFrame);
398 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
400 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
401 WebProcess::WaitForJavaScriptPopupFinished waiting;
403 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
409 bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
411 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
413 // Notify the bundle client.
414 m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame);
416 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
417 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
418 WebProcess::WaitForJavaScriptPopupFinished waiting;
420 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
423 return !result.isNull();
426 void WebChromeClient::setStatusbarText(const String& statusbarText)
428 // Notify the bundle client.
429 m_page->injectedBundleUIClient().willSetStatusbarText(m_page, statusbarText);
431 m_page->send(Messages::WebPageProxy::SetStatusText(statusbarText));
434 bool WebChromeClient::shouldInterruptJavaScript()
436 bool shouldInterrupt = false;
437 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ShouldInterruptJavaScript(), Messages::WebPageProxy::ShouldInterruptJavaScript::Reply(shouldInterrupt), m_page->pageID()))
440 return shouldInterrupt;
443 KeyboardUIMode WebChromeClient::keyboardUIMode()
445 return m_page->keyboardUIMode();
448 IntRect WebChromeClient::windowResizerRect() const
450 return m_page->windowResizerRect();
453 void WebChromeClient::invalidateRootView(const IntRect&, bool)
455 // Do nothing here, there's no concept of invalidating the window in the web process.
458 void WebChromeClient::invalidateContentsAndRootView(const IntRect& rect, bool)
460 if (Document* document = m_page->corePage()->mainFrame()->document()) {
461 if (document->printing())
465 m_page->drawingArea()->setNeedsDisplay(rect);
468 void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool)
470 if (Document* document = m_page->corePage()->mainFrame()->document()) {
471 if (document->printing())
475 m_page->pageDidScroll();
476 m_page->drawingArea()->setNeedsDisplay(rect);
479 void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollRect, const IntRect& clipRect)
481 m_page->pageDidScroll();
482 m_page->drawingArea()->scroll(intersection(scrollRect, clipRect), scrollOffset);
485 #if USE(TILED_BACKING_STORE)
486 void WebChromeClient::delegatedScrollRequested(const IntPoint& scrollOffset)
488 m_page->pageDidRequestScroll(scrollOffset);
492 IntPoint WebChromeClient::screenToRootView(const IntPoint& point) const
494 return m_page->screenToWindow(point);
497 IntRect WebChromeClient::rootViewToScreen(const IntRect& rect) const
499 return m_page->windowToScreen(rect);
502 PlatformPageClient WebChromeClient::platformPageClient() const
508 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
509 bool WebChromeClient::canContentsSizeChange(Frame* frame, const IntSize& size) const
511 // FIXME1: This patch should be removed AS SOON AS unexpected layout change problem is fixed.
512 // A page on naver isn't fitted when device is moved from landscape to portrait.
513 String url = frame->document()->url().string();
514 if (url.startsWith("https://nid.naver.com/user"))
521 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
522 bool WebChromeClient::getStandaloneStatus()
524 bool standalone = false;
525 m_page->sendSync(Messages::WebPageProxy::GetStandaloneStatus(), Messages::WebPageProxy::GetStandaloneStatus::Reply(standalone), m_page->pageID());
530 #if ENABLE(TIZEN_SEARCH_PROVIDER)
531 void WebChromeClient::addSearchProvider(const String& baseURL, const String& engineURL)
533 m_page->send(Messages::WebPageProxy::AddSearchProvider(baseURL, engineURL));
536 unsigned long WebChromeClient::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
539 m_page->sendSync(Messages::WebPageProxy::IsSearchProviderInstalled(baseURL, engineURL), Messages::WebPageProxy::IsSearchProviderInstalled::Reply(result));
544 void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) const
546 if (!m_page->corePage()->settings()->frameFlatteningEnabled()) {
547 WebFrame* largestFrame = findLargestFrameInFrameSet(m_page);
548 if (largestFrame != m_cachedFrameSetLargestFrame.get()) {
549 m_cachedFrameSetLargestFrame = largestFrame;
550 m_page->send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0));
554 if (frame->page()->mainFrame() != frame)
557 #if PLATFORM(QT) || (PLATFORM(EFL) && USE(TILED_BACKING_STORE))
558 if (m_page->useFixedLayout()) {
559 // The below method updates the size().
560 m_page->resizeToContentsIfNeeded();
561 m_page->drawingArea()->layerTreeHost()->sizeDidChange(m_page->size());
564 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
565 // FIXME: Logic to calculate the node's position is inefficient.
566 Frame* focusedFrame = m_page->corePage()->focusController()->focusedFrame();
567 if(focusedFrame && focusedFrame->document() && focusedFrame->document()->focusedNode()) {
568 Node* node = focusedFrame->document()->focusedNode();
569 IntRect nodeRect = IntRect(0, 0, 0, 0);
571 nodeRect = WebCore::pixelSnappedIntRect(node->getRect());
572 Frame* mainFrame = m_page->corePage()->mainFrame();
573 Frame* frame = node->document()->frame();
575 while (frame && frame != mainFrame) {
576 owner = frame->ownerElement();
580 nodeRect.setX(nodeRect.x() + owner->getRect().x());
581 nodeRect.setY(nodeRect.y() + owner->getRect().y());
582 frame = owner->document()->frame();
584 // we have to divide (x, y) with pageZoomFactor because pageZoomFactor was applied to them.
585 nodeRect.setX(nodeRect.x() / m_page->pageScaleFactor());
586 nodeRect.setY(nodeRect.y() / m_page->pageScaleFactor());
588 m_page->send(Messages::WebPageProxy::FocusedNodeChanged(nodeRect));
592 m_page->send(Messages::WebPageProxy::DidChangeContentsSize(m_page->size()));
595 FrameView* frameView = frame->view();
596 if (frameView && !frameView->delegatesScrolling()) {
597 bool hasHorizontalScrollbar = frameView->horizontalScrollbar();
598 bool hasVerticalScrollbar = frameView->verticalScrollbar();
600 if (hasHorizontalScrollbar != m_cachedMainFrameHasHorizontalScrollbar || hasVerticalScrollbar != m_cachedMainFrameHasVerticalScrollbar) {
601 m_page->send(Messages::WebPageProxy::DidChangeScrollbarsForMainFrame(hasHorizontalScrollbar, hasVerticalScrollbar));
603 m_cachedMainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
604 m_cachedMainFrameHasVerticalScrollbar = hasVerticalScrollbar;
609 void WebChromeClient::scrollRectIntoView(const IntRect&) const
614 bool WebChromeClient::shouldUnavailablePluginMessageBeButton(RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
616 if (pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion) {
617 // FIXME: <rdar://problem/8794397> We should only return true when there is a
618 // missingPluginButtonClicked callback defined on the Page UI client.
625 void WebChromeClient::unavailablePluginButtonClicked(Element* element, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
627 ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag) || element->hasTagName(appletTag));
628 ASSERT(pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion);
630 HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element);
632 m_page->send(Messages::WebPageProxy::UnavailablePluginButtonClicked(pluginUnavailabilityReason, pluginElement->serviceType(), pluginElement->url(), pluginElement->getAttribute(pluginspageAttr)));
635 void WebChromeClient::scrollbarsModeDidChange() const
640 void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult, unsigned modifierFlags)
642 RefPtr<APIObject> userData;
644 // Notify the bundle client.
645 m_page->injectedBundleUIClient().mouseDidMoveOverElement(m_page, hitTestResult, static_cast<WebEvent::Modifiers>(modifierFlags), userData);
647 // Notify the UIProcess.
648 WebHitTestResult::Data webHitTestResultData(hitTestResult);
649 m_page->send(Messages::WebPageProxy::MouseDidMoveOverElement(webHitTestResultData, modifierFlags, InjectedBundleUserMessageEncoder(userData.get())));
652 void WebChromeClient::setToolTip(const String& toolTip, TextDirection)
654 // Only send a tool tip to the WebProcess if it has changed since the last time this function was called.
656 if (toolTip == m_cachedToolTip)
658 m_cachedToolTip = toolTip;
660 m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip));
663 void WebChromeClient::print(Frame* frame)
665 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
666 m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply());
669 #if ENABLE(SQL_DATABASE)
670 void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName)
672 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
673 SecurityOrigin* origin = frame->document()->securityOrigin();
675 DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseName, origin);
676 uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin);
678 #if ENABLE(TIZEN_SQL_DATABASE)
679 uint64_t newQuota = 0;
680 const uint64_t defaultQuota = 5 * 1024 * 1024;
681 uint64_t requirement = currentQuota + details.expectedUsage();
682 if (requirement <= defaultQuota)
683 newQuota = requirement;
685 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
686 bool allowExceed = false;
687 WebProcess::shared().connection()->sendSync(
688 Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), details.displayName(), details.expectedUsage()),
689 Messages::WebPageProxy::ExceededDatabaseQuota::Reply(allowExceed), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags);
691 newQuota = currentQuota + details.expectedUsage();
693 newQuota = currentQuota;
696 uint64_t currentOriginUsage = DatabaseTracker::tracker().usageForOrigin(origin);
697 uint64_t newQuota = 0;
698 WebProcess::shared().connection()->sendSync(
699 Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
700 Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID());
703 DatabaseTracker::tracker().setQuota(origin, newQuota);
708 void WebChromeClient::reachedMaxAppCacheSize(int64_t)
713 void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t)
718 #if ENABLE(TIZEN_APPLICATION_CACHE)
719 bool WebChromeClient::requestApplicationCachePermission(Frame* frame)
721 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
722 SecurityOrigin* origin = frame->document()->securityOrigin();
724 unsigned syncSendFlags = WebCore::AXObjectCache::accessibilityEnabled() ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
726 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
727 WebProcess::WaitForJavaScriptPopupFinished waiting;
730 if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RequestApplicationCachePermission(webFrame->frameID(), origin->databaseIdentifier()), Messages::WebPageProxy::RequestApplicationCachePermission::Reply(allow), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
737 #if ENABLE(DASHBOARD_SUPPORT)
738 void WebChromeClient::dashboardRegionsChanged()
744 void WebChromeClient::populateVisitedLinks()
748 FloatRect WebChromeClient::customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect)
754 void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
755 bool behindText, bool entireLine)
760 bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
762 generatedFilename = m_page->injectedBundleUIClient().shouldGenerateFileForUpload(m_page, path);
763 return !generatedFilename.isNull();
766 String WebChromeClient::generateReplacementFile(const String& path)
768 return m_page->injectedBundleUIClient().generateFileForUpload(m_page, path);
771 bool WebChromeClient::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
773 if (!m_page->injectedBundleUIClient().shouldPaintCustomOverhangArea())
776 m_page->injectedBundleUIClient().paintCustomOverhangArea(m_page, context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
780 #if ENABLE(INPUT_TYPE_COLOR)
781 PassOwnPtr<ColorChooser> WebChromeClient::createColorChooser(ColorChooserClient* client, const Color& initialColor)
783 if (m_page->activeColorChooser())
786 return adoptPtr(new WebColorChooser(m_page, client, initialColor));
790 void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
793 if (m_page->activeOpenPanelResultListener())
794 m_page->cancelForOpenPanel();
796 if (m_page->activeOpenPanelResultListener())
800 RefPtr<FileChooser> fileChooser = prpFileChooser;
802 m_page->setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser.get()));
803 m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), fileChooser->settings()));
806 void WebChromeClient::loadIconForFiles(const Vector<String>& filenames, FileIconLoader* loader)
808 loader->notifyFinished(Icon::createIconForFiles(filenames));
811 void WebChromeClient::setCursor(const WebCore::Cursor& cursor)
813 #if USE(LAZY_NATIVE_CURSOR)
814 m_page->send(Messages::WebPageProxy::SetCursor(cursor));
818 void WebChromeClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
820 m_page->send(Messages::WebPageProxy::SetCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves));
823 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
824 void WebChromeClient::scheduleAnimation()
826 #if USE(UI_SIDE_COMPOSITING)
827 m_page->drawingArea()->layerTreeHost()->scheduleAnimation();
832 void WebChromeClient::formStateDidChange(const Node*)
837 bool WebChromeClient::selectItemWritingDirectionIsNatural()
846 bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
855 bool WebChromeClient::hasOpenedPopup() const
861 PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
863 return WebPopupMenu::create(m_page, client);
866 PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
868 return WebSearchPopupMenu::create(m_page, client);
871 #if USE(ACCELERATED_COMPOSITING)
872 void WebChromeClient::attachRootGraphicsLayer(Frame*, GraphicsLayer* layer)
875 m_page->enterAcceleratedCompositingMode(layer);
877 m_page->exitAcceleratedCompositingMode();
880 void WebChromeClient::setNeedsOneShotDrawingSynchronization()
882 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
883 if (m_page->drawingArea())
884 m_page->drawingArea()->setNeedsOneShotDrawingSynchronization();
890 void WebChromeClient::scheduleCompositingLayerSync()
892 if (m_page->drawingArea())
893 m_page->drawingArea()->scheduleCompositingLayerSync();
896 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
897 void WebChromeClient::addOrUpdateScrollingLayer(WebCore::Node*, WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer, const WebCore::IntSize& scrollSize)
899 if (!m_page->drawingArea())
901 m_page->drawingArea()->addOrUpdateScrollingLayer(scrollingLayer, contentsLayer, scrollSize);
904 void WebChromeClient::removeScrollingLayer(WebCore::Node*, WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer)
906 if (!m_page->drawingArea())
908 m_page->drawingArea()->removeScrollingLayer(scrollingLayer, contentsLayer);
910 #endif // ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
911 #endif // USE(ACCELERATED_COMPOSITING)
913 #if PLATFORM(WIN) && USE(AVFOUNDATION)
914 WebCore::GraphicsDeviceAdapter* WebChromeClient::graphicsDeviceAdapter() const
916 if (!m_page->drawingArea())
918 return m_page->drawingArea()->layerTreeHost()->graphicsDeviceAdapter();
922 #if ENABLE(TOUCH_EVENTS)
923 void WebChromeClient::needTouchEvents(bool needTouchEvents)
925 m_page->send(Messages::WebPageProxy::NeedTouchEvents(needTouchEvents));
930 void WebChromeClient::setLastSetCursorToCurrentCursor()
935 #if ENABLE(FULLSCREEN_API)
936 bool WebChromeClient::supportsFullScreenForElement(const WebCore::Element* element, bool withKeyboard)
938 return m_page->fullScreenManager()->supportsFullScreen(withKeyboard);
941 void WebChromeClient::enterFullScreenForElement(WebCore::Element* element)
943 m_page->fullScreenManager()->enterFullScreenForElement(element);
946 void WebChromeClient::exitFullScreenForElement(WebCore::Element* element)
948 m_page->fullScreenManager()->exitFullScreenForElement(element);
952 void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments&) const
954 #if USE(TILED_BACKING_STORE)
955 if (!m_page->useFixedLayout())
958 m_page->sendViewportAttributesChanged();
962 void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
964 m_page->send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
967 void WebChromeClient::recommendedScrollbarStyleDidChange(int32_t newStyle)
969 m_page->send(Messages::WebPageProxy::RecommendedScrollbarStyleDidChange(newStyle));
972 bool WebChromeClient::shouldRubberBandInDirection(WebCore::ScrollDirection direction) const
974 ASSERT(direction != WebCore::ScrollUp && direction != WebCore::ScrollDown);
976 if (direction == WebCore::ScrollLeft)
977 return m_page->injectedBundleUIClient().shouldRubberBandInDirection(m_page, WKScrollDirectionLeft);
978 if (direction == WebCore::ScrollRight)
979 return m_page->injectedBundleUIClient().shouldRubberBandInDirection(m_page, WKScrollDirectionRight);
981 ASSERT_NOT_REACHED();
985 void WebChromeClient::numWheelEventHandlersChanged(unsigned count)
987 m_page->numWheelEventHandlersChanged(count);
990 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
991 bool WebChromeClient::lockOrientation(int willLockOrientation)
994 m_page->sendSync(Messages::WebPageProxy::LockOrientation(willLockOrientation), Messages::WebPageProxy::LockOrientation::Reply(result));
997 void WebChromeClient::unlockOrientation()
999 m_page->send(Messages::WebPageProxy::UnlockOrientation());
1003 void WebChromeClient::logDiagnosticMessage(const String& message, const String& description, const String& success)
1005 if (!m_page->corePage()->settings()->diagnosticLoggingEnabled())
1008 m_page->injectedBundleDiagnosticLoggingClient().logDiagnosticMessage(m_page, message, description, success);
1011 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
1012 void WebChromeClient::requestVisibleContentRectRestore(const IntPoint& scrollOffset, float scale)
1014 m_page->pageDidRequestRestoreVisibleContentRect(scrollOffset, scale);
1017 float WebChromeClient::contentsScaleFactor() const
1019 if (!m_page->drawingArea())
1021 return m_page->drawingArea()->layerTreeHost()->contentsScaleFactor();
1026 void WebChromeClient::rendererWillBeDestroyed(RenderObject* object)
1028 #if ENABLE(TIZEN_SCREEN_READER)
1029 m_page->updateScreenReaderFocus(object);
1032 #if ENABLE(TIZEN_ISF_PORT)
1033 if (object->node() && object->node()->isRootEditableElement())
1034 m_page->send(Messages::WebPageProxy::RemoveInputMethodContext(reinterpret_cast<uintptr_t>(object->node())));
1039 #if ENABLE(TIZEN_INDEXED_DATABASE)
1040 bool WebChromeClient::exceededIndexedDatabaseQuota(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;
1047 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
1048 WebProcess::WaitForJavaScriptPopupFinished waiting;
1050 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))
1057 #if ENABLE(TIZEN_FILE_SYSTEM)
1058 bool WebChromeClient::exceededLocalFileSystemQuota(Frame* frame, int64_t currentQuota)
1060 WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
1061 SecurityOrigin* origin = frame->document()->securityOrigin();
1063 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
1064 bool result = false;
1065 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
1066 WebProcess::WaitForJavaScriptPopupFinished waiting;
1068 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))
1075 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_SUSPEND_BY_REMOTE_WEB_INSPECTOR)
1076 void WebChromeClient::setContentSuspendedByInspector(bool isSuspended)
1078 m_page->send(Messages::WebPageProxy::setContentSuspendedByInspector(isSuspended));
1081 } // namespace WebKit