2 * Copyright (C) 2009 Google 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 are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "web/ChromeClientImpl.h"
35 #include "bindings/core/v8/ScriptController.h"
36 #include "core/HTMLNames.h"
37 #include "core/accessibility/AXObject.h"
38 #include "core/accessibility/AXObjectCache.h"
39 #include "core/dom/Document.h"
40 #include "core/dom/Fullscreen.h"
41 #include "core/dom/Node.h"
42 #include "core/frame/Console.h"
43 #include "core/frame/FrameView.h"
44 #include "core/frame/Settings.h"
45 #include "core/html/HTMLInputElement.h"
46 #include "core/html/forms/ColorChooser.h"
47 #include "core/html/forms/ColorChooserClient.h"
48 #include "core/html/forms/DateTimeChooser.h"
49 #include "core/loader/DocumentLoader.h"
50 #include "core/loader/FrameLoadRequest.h"
51 #include "core/page/Page.h"
52 #include "core/page/PagePopupDriver.h"
53 #include "core/page/WindowFeatures.h"
54 #include "core/rendering/HitTestResult.h"
55 #include "core/rendering/RenderPart.h"
56 #include "core/rendering/compositing/CompositedSelectionBound.h"
57 #include "platform/Cursor.h"
58 #include "platform/FileChooser.h"
59 #include "platform/PlatformScreen.h"
60 #include "platform/RuntimeEnabledFeatures.h"
61 #include "platform/exported/WrappedResourceRequest.h"
62 #include "platform/geometry/FloatRect.h"
63 #include "platform/geometry/IntRect.h"
64 #include "platform/graphics/GraphicsLayer.h"
65 #include "platform/weborigin/SecurityOrigin.h"
66 #include "public/platform/Platform.h"
67 #include "public/platform/WebCursorInfo.h"
68 #include "public/platform/WebRect.h"
69 #include "public/platform/WebSelectionBound.h"
70 #include "public/platform/WebURLRequest.h"
71 #include "public/web/WebAXObject.h"
72 #include "public/web/WebAutofillClient.h"
73 #include "public/web/WebColorChooser.h"
74 #include "public/web/WebColorSuggestion.h"
75 #include "public/web/WebConsoleMessage.h"
76 #include "public/web/WebFrameClient.h"
77 #include "public/web/WebInputElement.h"
78 #include "public/web/WebInputEvent.h"
79 #include "public/web/WebKit.h"
80 #include "public/web/WebNode.h"
81 #include "public/web/WebPlugin.h"
82 #include "public/web/WebPopupMenuInfo.h"
83 #include "public/web/WebSettings.h"
84 #include "public/web/WebTextDirection.h"
85 #include "public/web/WebTouchAction.h"
86 #include "public/web/WebUserGestureIndicator.h"
87 #include "public/web/WebUserGestureToken.h"
88 #include "public/web/WebViewClient.h"
89 #include "public/web/WebWindowFeatures.h"
90 #include "web/ColorChooserPopupUIController.h"
91 #include "web/ColorChooserUIController.h"
92 #include "web/DateTimeChooserImpl.h"
93 #include "web/ExternalDateTimeChooser.h"
94 #include "web/ExternalPopupMenu.h"
95 #include "web/PopupMenuChromium.h"
96 #include "web/WebFileChooserCompletionImpl.h"
97 #include "web/WebInputEventConversion.h"
98 #include "web/WebLocalFrameImpl.h"
99 #include "web/WebPluginContainerImpl.h"
100 #include "web/WebPopupMenuImpl.h"
101 #include "web/WebSettingsImpl.h"
102 #include "web/WebViewImpl.h"
103 #include "wtf/text/CString.h"
104 #include "wtf/text/StringBuilder.h"
105 #include "wtf/text/StringConcatenate.h"
106 #include "wtf/unicode/CharacterNames.h"
110 // Converts a AXObjectCache::AXNotification to a WebAXEvent
111 static WebAXEvent toWebAXEvent(AXObjectCache::AXNotification notification)
113 // These enums have the same values; enforced in AssertMatchingEnums.cpp.
114 return static_cast<WebAXEvent>(notification);
117 static WebSelectionBound toWebSelectionBound(const CompositedSelectionBound& bound)
121 // These enums have the same values; enforced in AssertMatchingEnums.cpp.
122 WebSelectionBound result(static_cast<WebSelectionBound::Type>(bound.type));
123 result.layerId = bound.layer->platformLayer()->id();
124 result.edgeTopInLayer = roundedIntPoint(bound.edgeTopInLayer);
125 result.edgeBottomInLayer = roundedIntPoint(bound.edgeBottomInLayer);
129 ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView)
131 , m_toolbarsVisible(true)
132 , m_statusbarVisible(true)
133 , m_scrollbarsVisible(true)
134 , m_menubarVisible(true)
136 , m_pagePopupDriver(webView)
140 ChromeClientImpl::~ChromeClientImpl()
144 void* ChromeClientImpl::webView() const
146 return static_cast<void*>(m_webView);
149 void ChromeClientImpl::chromeDestroyed()
151 // Our lifetime is bound to the WebViewImpl.
154 void ChromeClientImpl::setWindowRect(const FloatRect& r)
156 if (m_webView->client())
157 m_webView->client()->setWindowRect(IntRect(r));
160 FloatRect ChromeClientImpl::windowRect()
163 if (m_webView->client())
164 rect = m_webView->client()->rootWindowRect();
166 // These numbers will be fairly wrong. The window's x/y coordinates will
167 // be the top left corner of the screen and the size will be the content
168 // size instead of the window size.
169 rect.width = m_webView->size().width;
170 rect.height = m_webView->size().height;
172 return FloatRect(rect);
175 FloatRect ChromeClientImpl::pageRect()
177 // We hide the details of the window's border thickness from the web page by
178 // simple re-using the window position here. So, from the point-of-view of
179 // the web page, the window has no border.
183 void ChromeClientImpl::focus()
185 if (m_webView->client())
186 m_webView->client()->didFocus();
189 bool ChromeClientImpl::canTakeFocus(FocusType)
191 // For now the browser can always take focus if we're not running layout
193 return !layoutTestMode();
196 void ChromeClientImpl::takeFocus(FocusType type)
198 if (!m_webView->client())
200 if (type == FocusTypeBackward)
201 m_webView->client()->focusPrevious();
203 m_webView->client()->focusNext();
206 void ChromeClientImpl::focusedNodeChanged(Node* node)
208 m_webView->client()->focusedNodeChanged(WebNode(node));
211 if (node && node->isElementNode() && toElement(node)->isLiveLink())
212 focusURL = toElement(node)->hrefURL();
213 m_webView->client()->setKeyboardFocusURL(focusURL);
216 void ChromeClientImpl::focusedFrameChanged(LocalFrame* frame)
218 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame);
219 if (webframe && webframe->client())
220 webframe->client()->frameFocused();
223 Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest& r, const WindowFeatures& features,
224 NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer)
226 if (!m_webView->client())
229 WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPolicy);
230 if (policy == WebNavigationPolicyIgnore)
231 policy = getNavigationPolicy();
233 ASSERT(frame->document());
234 Fullscreen::fullyExitFullscreen(*frame->document());
236 WebViewImpl* newView = toWebViewImpl(
237 m_webView->client()->createView(WebLocalFrameImpl::fromFrame(frame), WrappedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shouldSendReferrer == NeverSendReferrer));
240 return newView->page();
243 static inline void updatePolicyForEvent(const WebInputEvent* inputEvent, NavigationPolicy* policy)
245 if (!inputEvent || inputEvent->type != WebInputEvent::MouseUp)
248 const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEvent);
250 unsigned short buttonNumber;
251 switch (mouseEvent->button) {
252 case WebMouseEvent::ButtonLeft:
255 case WebMouseEvent::ButtonMiddle:
258 case WebMouseEvent::ButtonRight:
264 bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey;
265 bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey;
266 bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey;
267 bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey;
269 NavigationPolicy userPolicy = *policy;
270 navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &userPolicy);
271 // User and app agree that we want a new window; let the app override the decorations.
272 if (userPolicy == NavigationPolicyNewWindow && *policy == NavigationPolicyNewPopup)
274 *policy = userPolicy;
277 WebNavigationPolicy ChromeClientImpl::getNavigationPolicy()
279 // If our default configuration was modified by a script or wasn't
280 // created by a user gesture, then show as a popup. Else, let this
281 // new window be opened as a toplevel window.
282 bool asPopup = !m_toolbarsVisible
283 || !m_statusbarVisible
284 || !m_scrollbarsVisible
288 NavigationPolicy policy = NavigationPolicyNewForegroundTab;
290 policy = NavigationPolicyNewPopup;
291 updatePolicyForEvent(WebViewImpl::currentInputEvent(), &policy);
293 return static_cast<WebNavigationPolicy>(policy);
296 void ChromeClientImpl::show(NavigationPolicy navigationPolicy)
298 if (!m_webView->client())
301 WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPolicy);
302 if (policy == WebNavigationPolicyIgnore)
303 policy = getNavigationPolicy();
304 m_webView->client()->show(policy);
307 bool ChromeClientImpl::canRunModal()
309 return !!m_webView->client();
312 void ChromeClientImpl::runModal()
314 if (m_webView->client())
315 m_webView->client()->runModal();
318 void ChromeClientImpl::setToolbarsVisible(bool value)
320 m_toolbarsVisible = value;
323 bool ChromeClientImpl::toolbarsVisible()
325 return m_toolbarsVisible;
328 void ChromeClientImpl::setStatusbarVisible(bool value)
330 m_statusbarVisible = value;
333 bool ChromeClientImpl::statusbarVisible()
335 return m_statusbarVisible;
338 void ChromeClientImpl::setScrollbarsVisible(bool value)
340 m_scrollbarsVisible = value;
341 WebLocalFrameImpl* webFrame = toWebLocalFrameImpl(m_webView->mainFrame());
343 webFrame->setCanHaveScrollbars(value);
346 bool ChromeClientImpl::scrollbarsVisible()
348 return m_scrollbarsVisible;
351 void ChromeClientImpl::setMenubarVisible(bool value)
353 m_menubarVisible = value;
356 bool ChromeClientImpl::menubarVisible()
358 return m_menubarVisible;
361 void ChromeClientImpl::setResizable(bool value)
366 bool ChromeClientImpl::shouldReportDetailedMessageForSource(const String& url)
368 WebLocalFrameImpl* webframe = m_webView->localFrameRootTemporary();
369 return webframe->client() && webframe->client()->shouldReportDetailedMessageForSource(url);
372 void ChromeClientImpl::addMessageToConsole(LocalFrame* localFrame, MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace)
374 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(localFrame);
375 if (frame && frame->client()) {
376 frame->client()->didAddMessageToConsole(
377 WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), message),
384 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel()
386 return !!m_webView->client();
389 bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, LocalFrame* frame)
391 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame);
393 bool isReload = false;
394 WebDataSource* ds = webframe->provisionalDataSource();
396 isReload = (ds->navigationType() == WebNavigationTypeReload);
398 if (webframe->client())
399 return webframe->client()->runModalBeforeUnloadDialog(isReload, message);
403 void ChromeClientImpl::closeWindowSoon()
405 // Make sure this Page can no longer be found by JS.
406 Page::ordinaryPages().remove(m_webView->page());
408 // Make sure that all loading is stopped. Ensures that JS stops executing!
409 m_webView->mainFrame()->stopLoading();
411 if (m_webView->client())
412 m_webView->client()->closeWidgetSoon();
415 // Although a LocalFrame is passed in, we don't actually use it, since we
416 // already know our own m_webView.
417 void ChromeClientImpl::runJavaScriptAlert(LocalFrame* frame, const String& message)
419 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame);
420 if (webframe->client()) {
421 if (WebUserGestureIndicator::isProcessingUserGesture())
422 WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt();
423 webframe->client()->runModalAlertDialog(message);
427 // See comments for runJavaScriptAlert().
428 bool ChromeClientImpl::runJavaScriptConfirm(LocalFrame* frame, const String& message)
430 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame);
431 if (webframe->client()) {
432 if (WebUserGestureIndicator::isProcessingUserGesture())
433 WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt();
434 return webframe->client()->runModalConfirmDialog(message);
439 // See comments for runJavaScriptAlert().
440 bool ChromeClientImpl::runJavaScriptPrompt(LocalFrame* frame,
441 const String& message,
442 const String& defaultValue,
445 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame);
446 if (webframe->client()) {
447 if (WebUserGestureIndicator::isProcessingUserGesture())
448 WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt();
449 WebString actualValue;
450 bool ok = webframe->client()->runModalPromptDialog(
455 result = actualValue;
461 void ChromeClientImpl::setStatusbarText(const String& message)
463 if (m_webView->client())
464 m_webView->client()->setStatusText(message);
467 bool ChromeClientImpl::tabsToLinks()
469 return m_webView->tabsToLinks();
472 IntRect ChromeClientImpl::windowResizerRect() const
475 if (m_webView->client())
476 result = m_webView->client()->windowResizerRect();
480 void ChromeClientImpl::invalidateContentsAndRootView(const IntRect& updateRect)
482 if (updateRect.isEmpty())
484 m_webView->invalidateRect(updateRect);
487 void ChromeClientImpl::invalidateContentsForSlowScroll(const IntRect& updateRect)
489 invalidateContentsAndRootView(updateRect);
492 void ChromeClientImpl::scheduleAnimation()
494 m_webView->scheduleAnimation();
497 IntRect ChromeClientImpl::rootViewToScreen(const IntRect& rect) const
499 IntRect screenRect(rect);
501 if (m_webView->client()) {
502 WebRect windowRect = m_webView->client()->windowRect();
503 screenRect.move(windowRect.x, windowRect.y);
509 WebScreenInfo ChromeClientImpl::screenInfo() const
511 return m_webView->client() ? m_webView->client()->screenInfo() : WebScreenInfo();
514 void ChromeClientImpl::contentsSizeChanged(LocalFrame* frame, const IntSize& size) const
516 m_webView->didChangeContentsSize();
518 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame);
519 webframe->didChangeContentsSize(size);
521 frame->loader().restoreScrollPositionAndViewState();
524 void ChromeClientImpl::deviceOrPageScaleFactorChanged() const
526 m_webView->deviceOrPageScaleFactorChanged();
529 void ChromeClientImpl::layoutUpdated(LocalFrame* frame) const
531 m_webView->layoutUpdated(WebLocalFrameImpl::fromFrame(frame));
534 void ChromeClientImpl::mouseDidMoveOverElement(
535 const HitTestResult& result, unsigned modifierFlags)
537 if (!m_webView->client())
541 // Find out if the mouse is over a link, and if so, let our UI know...
542 if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty()) {
543 url = result.absoluteLinkURL();
544 } else if (result.innerNonSharedNode()
545 && (isHTMLObjectElement(*result.innerNonSharedNode())
546 || isHTMLEmbedElement(*result.innerNonSharedNode()))) {
547 RenderObject* object = result.innerNonSharedNode()->renderer();
548 if (object && object->isRenderPart()) {
549 Widget* widget = toRenderPart(object)->widget();
550 if (widget && widget->isPluginContainer()) {
551 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget);
552 url = plugin->plugin()->linkAtPosition(result.roundedPointInInnerNodeFrame());
557 m_webView->client()->setMouseOverURL(url);
560 void ChromeClientImpl::setToolTip(const String& tooltipText, TextDirection dir)
562 if (m_webView->client())
563 m_webView->client()->setToolTipText(tooltipText, toWebTextDirection(dir));
566 void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportDescription& description) const
568 m_webView->updatePageDefinedViewportConstraints(description);
571 void ChromeClientImpl::print(LocalFrame* frame)
573 if (m_webView->client())
574 m_webView->client()->printPage(WebLocalFrameImpl::fromFrame(frame));
577 PassOwnPtrWillBeRawPtr<ColorChooser> ChromeClientImpl::createColorChooser(LocalFrame* frame, ColorChooserClient* chooserClient, const Color&)
579 OwnPtrWillBeRawPtr<ColorChooserUIController> controller = nullptr;
580 if (RuntimeEnabledFeatures::pagePopupEnabled())
581 controller = ColorChooserPopupUIController::create(frame, this, chooserClient);
583 controller = ColorChooserUIController::create(frame, chooserClient);
584 controller->openUI();
585 return controller.release();
588 PassRefPtr<DateTimeChooser> ChromeClientImpl::openDateTimeChooser(DateTimeChooserClient* pickerClient, const DateTimeChooserParameters& parameters)
590 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
591 return DateTimeChooserImpl::create(this, pickerClient, parameters);
593 return ExternalDateTimeChooser::create(this, m_webView->client(), pickerClient, parameters);
597 void ChromeClientImpl::runOpenPanel(LocalFrame* frame, PassRefPtr<FileChooser> fileChooser)
599 WebViewClient* client = m_webView->client();
603 WebFileChooserParams params;
604 params.multiSelect = fileChooser->settings().allowsMultipleFiles;
605 params.directory = fileChooser->settings().allowsDirectoryUpload;
606 params.acceptTypes = fileChooser->settings().acceptTypes();
607 params.selectedFiles = fileChooser->settings().selectedFiles;
608 if (params.selectedFiles.size() > 0)
609 params.initialValue = params.selectedFiles[0];
610 params.useMediaCapture = fileChooser->settings().useMediaCapture;
611 params.needLocalPath = fileChooser->settings().allowsDirectoryUpload;
613 WebFileChooserCompletionImpl* chooserCompletion =
614 new WebFileChooserCompletionImpl(fileChooser);
616 if (client->runFileChooser(params, chooserCompletion))
619 // Choosing failed, so do callback with an empty list.
620 chooserCompletion->didChooseFile(WebVector<WebString>());
623 void ChromeClientImpl::enumerateChosenDirectory(FileChooser* fileChooser)
625 WebViewClient* client = m_webView->client();
629 WebFileChooserCompletionImpl* chooserCompletion =
630 new WebFileChooserCompletionImpl(fileChooser);
632 ASSERT(fileChooser && fileChooser->settings().selectedFiles.size());
634 // If the enumeration can't happen, call the callback with an empty list.
635 if (!client->enumerateChosenDirectory(fileChooser->settings().selectedFiles[0], chooserCompletion))
636 chooserCompletion->didChooseFile(WebVector<WebString>());
639 void ChromeClientImpl::setCursor(const Cursor& cursor)
641 setCursor(WebCursorInfo(cursor));
644 void ChromeClientImpl::setCursor(const WebCursorInfo& cursor)
647 // On Mac the mousemove event propagates to both the popup and main window.
648 // If a popup is open we don't want the main window to change the cursor.
649 if (m_webView->hasOpenedPopup())
652 if (m_webView->client())
653 m_webView->client()->didChangeCursor(cursor);
656 void ChromeClientImpl::setCursorForPlugin(const WebCursorInfo& cursor)
661 void ChromeClientImpl::postAccessibilityNotification(AXObject* obj, AXObjectCache::AXNotification notification)
663 // Alert assistive technology about the accessibility object notification.
664 if (!obj || !obj->document())
667 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(obj->document()->axObjectCacheOwner().frame());
668 if (webframe && webframe->client())
669 webframe->client()->postAccessibilityEvent(WebAXObject(obj), toWebAXEvent(notification));
671 // FIXME: delete these lines once Chrome only uses the frame client interface, above.
672 if (m_webView->client())
673 m_webView->client()->postAccessibilityEvent(WebAXObject(obj), toWebAXEvent(notification));
676 String ChromeClientImpl::acceptLanguages()
678 return m_webView->client()->acceptLanguages();
681 bool ChromeClientImpl::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
683 LocalFrame* frame = m_webView->mainFrameImpl()->frame();
684 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainerFromFrame(frame);
686 return pluginContainer->paintCustomOverhangArea(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
690 GraphicsLayerFactory* ChromeClientImpl::graphicsLayerFactory() const
692 return m_webView->graphicsLayerFactory();
695 void ChromeClientImpl::attachRootGraphicsLayer(GraphicsLayer* rootLayer)
697 m_webView->setRootGraphicsLayer(rootLayer);
700 void ChromeClientImpl::enterFullScreenForElement(Element* element)
702 m_webView->enterFullScreenForElement(element);
705 void ChromeClientImpl::exitFullScreenForElement(Element* element)
707 m_webView->exitFullScreenForElement(element);
710 void ChromeClientImpl::clearCompositedSelectionBounds()
712 m_webView->clearCompositedSelectionBounds();
715 void ChromeClientImpl::updateCompositedSelectionBounds(const CompositedSelectionBound& anchor, const CompositedSelectionBound& focus)
717 m_webView->updateCompositedSelectionBounds(toWebSelectionBound(anchor), toWebSelectionBound(focus));
720 bool ChromeClientImpl::hasOpenedPopup() const
722 return m_webView->hasOpenedPopup();
725 PassRefPtrWillBeRawPtr<PopupMenu> ChromeClientImpl::createPopupMenu(LocalFrame& frame, PopupMenuClient* client) const
727 if (WebViewImpl::useExternalPopupMenus())
728 return adoptRefWillBeNoop(new ExternalPopupMenu(frame, client, *m_webView));
730 return adoptRefWillBeNoop(new PopupMenuChromium(frame, client));
733 PagePopup* ChromeClientImpl::openPagePopup(PagePopupClient* client, const IntRect& originBoundsInRootView)
735 ASSERT(m_pagePopupDriver);
736 return m_pagePopupDriver->openPagePopup(client, originBoundsInRootView);
739 void ChromeClientImpl::closePagePopup(PagePopup* popup)
741 ASSERT(m_pagePopupDriver);
742 m_pagePopupDriver->closePagePopup(popup);
745 void ChromeClientImpl::setPagePopupDriver(PagePopupDriver* driver)
748 m_pagePopupDriver = driver;
751 void ChromeClientImpl::resetPagePopupDriver()
753 m_pagePopupDriver = m_webView;
756 bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType& dialogType, const String& dialogMessage, Document::PageDismissalType dismissalType) const
758 const char* kDialogs[] = {"alert", "confirm", "prompt", "showModalDialog"};
759 int dialog = static_cast<int>(dialogType);
760 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dialog && dialog < static_cast<int>(arraysize(kDialogs)));
762 const char* kDismissals[] = {"beforeunload", "pagehide", "unload"};
763 int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal.
764 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dismissal && dismissal < static_cast<int>(arraysize(kDismissals)));
766 Platform::current()->histogramEnumeration("Renderer.ModalDialogsDuringPageDismissal", dismissal * arraysize(kDialogs) + dialog, arraysize(kDialogs) * arraysize(kDismissals));
768 String message = String("Blocked ") + kDialogs[dialog] + "('" + dialogMessage + "') during " + kDismissals[dismissal] + ".";
769 m_webView->mainFrame()->addMessageToConsole(WebConsoleMessage(WebConsoleMessage::LevelError, message));
774 void ChromeClientImpl::needTouchEvents(bool needsTouchEvents)
776 m_webView->hasTouchEventHandlers(needsTouchEvents);
779 void ChromeClientImpl::setTouchAction(TouchAction touchAction)
781 if (WebViewClient* client = m_webView->client()) {
782 WebTouchAction webTouchAction = static_cast<WebTouchAction>(touchAction);
783 client->setTouchAction(webTouchAction);
787 bool ChromeClientImpl::requestPointerLock()
789 return m_webView->requestPointerLock();
792 void ChromeClientImpl::requestPointerUnlock()
794 return m_webView->requestPointerUnlock();
797 void ChromeClientImpl::annotatedRegionsChanged()
799 WebViewClient* client = m_webView->client();
801 client->draggableRegionsChanged();
804 void ChromeClientImpl::didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<Element> >& elements)
806 if (m_webView->autofillClient())
807 m_webView->autofillClient()->didAssociateFormControls(elements);
810 void ChromeClientImpl::didCancelCompositionOnSelectionChange()
812 if (m_webView->client())
813 m_webView->client()->didCancelCompositionOnSelectionChange();
816 void ChromeClientImpl::willSetInputMethodState()
818 if (m_webView->client())
819 m_webView->client()->resetInputMethod();
822 void ChromeClientImpl::didUpdateTextOfFocusedElementByNonUserInput()
824 if (m_webView->client())
825 m_webView->client()->didUpdateTextOfFocusedElementByNonUserInput();
828 void ChromeClientImpl::showImeIfNeeded()
830 if (m_webView->client())
831 m_webView->client()->showImeIfNeeded();
834 void ChromeClientImpl::handleKeyboardEventOnTextField(HTMLInputElement& inputElement, KeyboardEvent& event)
836 if (!m_webView->autofillClient())
838 m_webView->autofillClient()->textFieldDidReceiveKeyDown(WebInputElement(&inputElement), WebKeyboardEventBuilder(event));
841 void ChromeClientImpl::didChangeValueInTextField(HTMLFormControlElement& element)
843 if (!m_webView->autofillClient())
845 m_webView->autofillClient()->textFieldDidChange(WebFormControlElement(&element));
848 void ChromeClientImpl::didEndEditingOnTextField(HTMLInputElement& inputElement)
850 if (m_webView->autofillClient())
851 m_webView->autofillClient()->textFieldDidEndEditing(WebInputElement(&inputElement));
854 void ChromeClientImpl::openTextDataListChooser(HTMLInputElement& input)
856 if (m_webView->autofillClient())
857 m_webView->autofillClient()->openTextDataListChooser(WebInputElement(&input));