void FullscreenController::enterFullScreenForElement(Element* element) { // We are already transitioning to fullscreen for a different element. if (m_provisionalFullScreenElement) { m_provisionalFullScreenElement = element; return; } // We are already in fullscreen mode. if (m_fullScreenFrame) { m_provisionalFullScreenElement = element; didEnterFullScreen(); return; } // We need to store these values here rather than didEnterFullScreen since // by the time the latter is called, a Resize has already occured, clamping // the scroll offset. if (!m_haveEnteredFullscreen) { m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor(); m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrollOffset(); m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffset(); } // We need to transition to fullscreen mode. WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().frame()); if (frame && frame->client()) { frame->client()->enterFullscreen(); m_provisionalFullScreenElement = element; } }
bool ChromeClientImpl::openBeforeUnloadConfirmPanelDelegate(LocalFrame* frame, bool isReload) { notifyPopupOpeningObservers(); WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); return webframe->client() && webframe->client()->runModalBeforeUnloadDialog(isReload); }
// FIXME: Remove this code once we have input routing in the browser // process. See http://crbug.com/339659. void ChromeClientImpl::forwardInputEvent( Frame* frame, Event* event) { WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(frame)); // This is only called when we have out-of-process iframes, which // need to forward input events across processes. // FIXME: Add a check for out-of-process iframes enabled. if (event->isKeyboardEvent()) { WebKeyboardEventBuilder webEvent(*static_cast<KeyboardEvent*>(event)); webFrame->client()->forwardInputEvent(&webEvent); } else if (event->isMouseEvent()) { WebMouseEventBuilder webEvent(webFrame->frameView(), 0, *static_cast<MouseEvent*>(event)); // Internal Blink events should not be forwarded. if (webEvent.type == WebInputEvent::Undefined) return; webFrame->client()->forwardInputEvent(&webEvent); } else if (event->isWheelEvent()) { WebMouseWheelEventBuilder webEvent(webFrame->frameView(), 0, *static_cast<WheelEvent*>(event)); if (webEvent.type == WebInputEvent::Undefined) return; webFrame->client()->forwardInputEvent(&webEvent); } }
static PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(WebMediaPlayerClient* client, const WebURL& url, LocalFrame* frame) { WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(frame); if (!webFrame || !webFrame->client()) return nullptr; return adoptPtr(webFrame->client()->createMediaPlayer(webFrame, url, client)); }
bool ChromeClientImpl::shouldReportDetailedMessageForSource( LocalFrame& localFrame, const String& url) { WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(localFrame.localFrameRoot()); return webframe && webframe->client() && webframe->client()->shouldReportDetailedMessageForSource(url); }
static PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(WebMediaPlayerClient* client, const WebURL& url, LocalFrame* frame, WebContentDecryptionModule* initialCdm) { WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(frame); if (!webFrame || !webFrame->client()) return nullptr; return adoptPtr(webFrame->client()->createMediaPlayer(webFrame, url, client, initialCdm)); }
void postAccessibilityNotification( AXObject* obj, AXObjectCache::AXNotification notification) override { WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame( m_popup->m_popupClient->ownerElement().document().frame()); if (obj && frame && frame->client()) frame->client()->postAccessibilityEvent( WebAXObject(obj), static_cast<WebAXEvent>(notification)); }
// Although a LocalFrame is passed in, we don't actually use it, since we // already know our own m_webView. void ChromeClientImpl::runJavaScriptAlert(LocalFrame* frame, const String& message) { WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); if (webframe->client()) { if (WebUserGestureIndicator::isProcessingUserGesture()) WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt(); webframe->client()->runModalAlertDialog(message); } }
// See comments for runJavaScriptAlert(). bool ChromeClientImpl::runJavaScriptConfirm(LocalFrame* frame, const String& message) { WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); if (webframe->client()) { if (WebUserGestureIndicator::isProcessingUserGesture()) WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt(); return webframe->client()->runModalConfirmDialog(message); } return false; }
void ChromeClientImpl::postAccessibilityNotification(AXObject* obj, AXObjectCache::AXNotification notification) { // Alert assistive technology about the accessibility object notification. if (!obj || !obj->document()) return; WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(obj->document()->axObjectCacheOwner().frame()); if (webframe && webframe->client()) webframe->client()->postAccessibilityEvent(WebAXObject(obj), toWebAXEvent(notification)); }
void ChromeClientImpl::addMessageToConsole(LocalFrame* localFrame, MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace) { WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(localFrame); if (frame && frame->client()) { frame->client()->didAddMessageToConsole( WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), message), sourceID, lineNumber, stackTrace); } }
void ContextMenuClientImpl::clearContextMenu() { HitTestResult r = m_webView->page()->contextMenuController().hitTestResult(); LocalFrame* selectedFrame = r.innerNodeFrame(); if (!selectedFrame) return; WebLocalFrameImpl* selectedWebFrame = WebLocalFrameImpl::fromFrame(selectedFrame); if (selectedWebFrame->client()) selectedWebFrame->client()->clearContextMenu(); }
void FullscreenController::exitFullScreenForElement(Element* element) { ASSERT(element); // The client is exiting full screen, so don't send a notification. if (m_isCancelingFullScreen) return; WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().frame()); if (frame && frame->client()) frame->client()->exitFullscreen(); }
// Although a LocalFrame is passed in, we don't actually use it, since we // already know our own m_webView. bool ChromeClientImpl::openJavaScriptAlertDelegate(LocalFrame* frame, const String& message) { notifyPopupOpeningObservers(); WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); if (webframe->client()) { if (WebUserGestureIndicator::isProcessingUserGesture()) WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt(); webframe->client()->runModalAlertDialog(message); return true; } return false; }
bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, LocalFrame* frame) { WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); bool isReload = false; WebDataSource* ds = webframe->provisionalDataSource(); if (ds) isReload = (ds->navigationType() == WebNavigationTypeReload); if (webframe->client()) return webframe->client()->runModalBeforeUnloadDialog(isReload, message); return false; }
WorkerGlobalScopeProxy* WorkerGlobalScopeProxyProviderImpl::createWorkerGlobalScopeProxy(Worker* worker) { if (worker->executionContext()->isDocument()) { Document* document = toDocument(worker->executionContext()); WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()); OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::create()); providePermissionClientToWorker(workerClients.get(), adoptPtr(webFrame->client()->createWorkerPermissionClientProxy(webFrame))); provideServiceWorkerContainerClientToWorker(workerClients.get(), adoptPtr(webFrame->client()->createServiceWorkerProvider(webFrame))); return new WorkerMessagingProxy(worker, workerClients.release()); } ASSERT_NOT_REACHED(); return 0; }
void ChromeClientImpl::postAccessibilityNotification(AXObject* obj, AXObjectCache::AXNotification notification) { // Alert assistive technology about the accessibility object notification. if (!obj || !obj->document()) return; WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(obj->document()->axObjectCacheOwner().frame()); if (webframe && webframe->client()) webframe->client()->postAccessibilityEvent(WebAXObject(obj), toWebAXEvent(notification)); // FIXME: delete these lines once Chrome only uses the frame client interface, above. if (m_webView->client()) m_webView->client()->postAccessibilityEvent(WebAXObject(obj), toWebAXEvent(notification)); }
// See comments for openJavaScriptAlertDelegate(). bool ChromeClientImpl::openJavaScriptPromptDelegate(LocalFrame* frame, const String& message, const String& defaultValue, String& result) { notifyPopupOpeningObservers(); WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); if (webframe->client()) { if (WebUserGestureIndicator::isProcessingUserGesture()) WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt(); WebString actualValue; bool ok = webframe->client()->runModalPromptDialog(message, defaultValue, &actualValue); if (ok) result = actualValue; return ok; } return false; }
bool ExternalPopupMenu::showInternal() { // Blink core reuses the PopupMenu of an element. For simplicity, we do // recreate the actual external popup everytime. if (m_webExternalPopupMenu) { m_webExternalPopupMenu->close(); m_webExternalPopupMenu = 0; } WebPopupMenuInfo info; getPopupMenuInfo(info, *m_ownerElement); if (info.items.isEmpty()) return false; WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(m_localFrame.get()); m_webExternalPopupMenu = webframe->client()->createExternalPopupMenu(info, this); if (m_webExternalPopupMenu) { LayoutObject* layoutObject = m_ownerElement->layoutObject(); if (!layoutObject || !layoutObject->isBox()) return false; FloatQuad quad(toLayoutBox(layoutObject)->localToAbsoluteQuad(FloatQuad(toLayoutBox(layoutObject)->borderBoundingBox()))); IntRect rect(quad.enclosingBoundingBox()); IntRect rectInViewport = m_localFrame->view()->soonToBeRemovedContentsToUnscaledViewport(rect); // TODO(tkent): If the anchor rectangle is not visible, we should not // show a popup. m_webExternalPopupMenu->show(rectInViewport); m_shownDOMTreeVersion = m_ownerElement->document().domTreeVersion(); return true; } else { // The client might refuse to create a popup (when there is already one pending to be shown for example). didCancel(); return false; } }
void ChromeClientImpl::installSupplements(LocalFrame& frame) { WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(&frame); WebFrameClient* client = webFrame->client(); DCHECK(client); providePushControllerTo(frame, client->pushClient()); provideUserMediaTo(frame, UserMediaClientImpl::create(client->userMediaClient())); provideIndexedDBClientTo(frame, IndexedDBClientImpl::create()); provideLocalFileSystemTo(frame, LocalFileSystemClient::create()); provideNavigatorContentUtilsTo( frame, NavigatorContentUtilsClientImpl::create(webFrame)); if (RuntimeEnabledFeatures::webBluetoothEnabled()) BluetoothSupplement::provideTo(frame, client->bluetooth()); ScreenOrientationController::provideTo(frame, client->webScreenOrientationClient()); if (RuntimeEnabledFeatures::presentationEnabled()) PresentationController::provideTo(frame, client->presentationClient()); if (RuntimeEnabledFeatures::audioOutputDevicesEnabled()) provideAudioOutputDeviceClientTo(frame, AudioOutputDeviceClientImpl::create()); if (RuntimeEnabledFeatures::installedAppEnabled()) InstalledAppController::provideTo(frame, client->installedAppClient()); }
void AudioOutputDeviceClientImpl::checkIfAudioSinkExistsAndIsAuthorized(ExecutionContext* context, const WebString& sinkId, std::unique_ptr<WebSetSinkIdCallbacks> callbacks) { DCHECK(context); DCHECK(context->isDocument()); Document* document = toDocument(context); WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()); webFrame->client()->checkIfAudioSinkExistsAndIsAuthorized(sinkId, WebSecurityOrigin(context->getSecurityOrigin()), callbacks.release()); }
std::unique_ptr<WebMediaPlayer> FrameLoaderClientImpl::createWebMediaPlayer( HTMLMediaElement& htmlMediaElement, const WebMediaPlayerSource& source, WebMediaPlayerClient* client) { WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(htmlMediaElement.document().frame()); if (!webFrame || !webFrame->client()) return nullptr; HTMLMediaElementEncryptedMedia& encryptedMedia = HTMLMediaElementEncryptedMedia::from(htmlMediaElement); WebString sinkId(HTMLMediaElementAudioOutputDevice::sinkId(htmlMediaElement)); return wrapUnique(webFrame->client()->createMediaPlayer( source, client, &encryptedMedia, encryptedMedia.contentDecryptionModule(), sinkId)); }
void NotificationPermissionClientImpl::requestPermission(ExecutionContext* context, NotificationPermissionCallback* callback) { ASSERT(context && context->isDocument()); Document* document = toDocument(context); WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()); webFrame->client()->requestNotificationPermission(WebSecurityOrigin(context->securityOrigin()), new WebNotificationPermissionCallbackImpl(callback)); }
void ChromeClientImpl::addMessageToConsole(LocalFrame* localFrame, MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace) { if (level == ErrorMessageLevel) printf("ERROR: %s \nSOURCE: %s:%u\n", message.utf8().data(), sourceID.utf8().data(), lineNumber); else printf("CONSOLE: %s: %s\n", messageLevelAsString(level).utf8().data(), message.utf8().data()); fflush(stdout); WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(localFrame); if (frame && frame->client()) { frame->client()->didAddMessageToConsole( WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), message), sourceID, lineNumber, stackTrace); } }
void ColorChooserUIController::openColorChooser() { DCHECK(!m_chooser); WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(m_frame); WebFrameClient* webFrameClient = frame->client(); if (!webFrameClient) return; m_chooser = WTF::wrapUnique(webFrameClient->createColorChooser( this, static_cast<WebColor>(m_client->currentColor().rgb()), m_client->suggestions())); }
void TextFinder::reportFindInPageResultToAccessibility(int identifier) { AXObjectCacheImpl* axObjectCache = toAXObjectCacheImpl(ownerFrame().frame()->document()->existingAXObjectCache()); if (!axObjectCache) return; AXObject* startObject = axObjectCache->get(m_activeMatch->startContainer()); AXObject* endObject = axObjectCache->get(m_activeMatch->endContainer()); if (!startObject || !endObject) return; WebLocalFrameImpl* mainFrameImpl = ownerFrame().viewImpl()->mainFrameImpl(); if (mainFrameImpl && mainFrameImpl->client()) { mainFrameImpl->client()->handleAccessibilityFindInPageResult( identifier, m_activeMatchIndexInCurrentFrame + 1, WebAXObject(startObject), m_activeMatch->startOffset(), WebAXObject(endObject), m_activeMatch->endOffset()); } }
void FullscreenController::enterFullScreenForElement(Element* element) { // We are already transitioning to fullscreen for a different element. if (m_provisionalFullScreenElement) { m_provisionalFullScreenElement = element; return; } // We are already in fullscreen mode. if (m_fullScreenFrame) { m_provisionalFullScreenElement = element; didEnterFullScreen(); return; } // We need to transition to fullscreen mode. WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().frame()); if (frame && frame->client()) { frame->client()->enterFullscreen(); m_provisionalFullScreenElement = element; } }
WorkerGlobalScopeProxy* WorkerGlobalScopeProxyProviderImpl::createWorkerGlobalScopeProxy(Worker* worker) { if (worker->executionContext()->isDocument()) { Document* document = toDocument(worker->executionContext()); WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()); OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::create()); provideContentSettingsClientToWorker(workerClients.get(), adoptPtr(webFrame->client()->createWorkerContentSettingsClientProxy(webFrame))); // FIXME: call provideServiceWorkerContainerClientToWorker here when we // support ServiceWorker in dedicated workers (http://crbug.com/371690) return new DedicatedWorkerMessagingProxy(worker, workerClients.release()); } ASSERT_NOT_REACHED(); return 0; }
void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, int index) { IntRect rect(controlPosition.enclosingBoundingBox()); // WebCore reuses the PopupMenu of an element. // For simplicity, we do recreate the actual external popup everytime. if (m_webExternalPopupMenu) { m_webExternalPopupMenu->close(); m_webExternalPopupMenu = 0; } WebPopupMenuInfo info; getPopupMenuInfo(info, *m_popupMenuClient); if (info.items.isEmpty()) return; WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(m_localFrame.get()); m_webExternalPopupMenu = webframe->client()->createExternalPopupMenu(info, this); if (m_webExternalPopupMenu) { // FIXME: Standardize viewport coordinate conversions. crbug.com/371902. IntRect rectInViewport = m_localFrame->view()->contentsToWindow(rect); if (m_webView.pinchVirtualViewportEnabled()) rectInViewport.moveBy(-flooredIntPoint(m_webView.page()->frameHost().pinchViewport().location())); m_webExternalPopupMenu->show(rectInViewport); #if OS(MACOSX) const WebInputEvent* currentEvent = WebViewImpl::currentInputEvent(); if (currentEvent && currentEvent->type == WebInputEvent::MouseDown) { m_syntheticEvent = adoptPtr(new WebMouseEvent); *m_syntheticEvent = *static_cast<const WebMouseEvent*>(currentEvent); m_syntheticEvent->type = WebInputEvent::MouseUp; m_dispatchEventTimer.startOneShot(0, FROM_HERE); // FIXME: show() is asynchronous. If preparing a popup is slow and // a user released the mouse button before showing the popup, // mouseup and click events are correctly dispatched. Dispatching // the synthetic mouseup event is redundant in this case. } #endif } else { // The client might refuse to create a popup (when there is already one pending to be shown for example). didCancel(); } }
InProcessWorkerMessagingProxy* DedicatedWorkerMessagingProxyProviderImpl::createWorkerMessagingProxy( Worker* worker) { if (worker->getExecutionContext()->isDocument()) { Document* document = toDocument(worker->getExecutionContext()); WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()); WorkerClients* workerClients = WorkerClients::create(); provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create()); provideLocalFileSystemToWorker(workerClients, LocalFileSystemClient::create()); provideContentSettingsClientToWorker( workerClients, wrapUnique( webFrame->client()->createWorkerContentSettingsClientProxy())); // FIXME: call provideServiceWorkerContainerClientToWorker here when we // support ServiceWorker in dedicated workers (http://crbug.com/371690) return new DedicatedWorkerMessagingProxy(worker, workerClients); } NOTREACHED(); return 0; }