void TextFinder::flushCurrentScopingEffort(int identifier) { if (!m_ownerFrame.frame() || !m_ownerFrame.frame()->page()) return; WebLocalFrameImpl* mainFrameImpl = m_ownerFrame.viewImpl()->mainFrameImpl(); mainFrameImpl->ensureTextFinder().decrementFramesScopingCount(identifier); }
void TextFinder::findMatchRects(WebVector<WebFloatRect>& outputRects) { Vector<WebFloatRect> matchRects; for (WebLocalFrameImpl* frame = &ownerFrame(); frame; frame = toWebLocalFrameImpl(frame->traverseNext(false))) frame->ensureTextFinder().appendFindMatchRects(matchRects); outputRects = matchRects; }
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)); }
void WebRemoteFrameImpl::didStopLoading() { frame()->setIsLoading(false); if (parent() && parent()->isWebLocalFrame()) { WebLocalFrameImpl* parentFrame = toWebLocalFrameImpl(parent()->toWebLocalFrame()); parentFrame->frame()->loader().checkCompleted(); } }
// 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); } }
void ChromeClientImpl::contentsSizeChanged(LocalFrame* frame, const IntSize& size) const { m_webView->didChangeContentsSize(); WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); webframe->didChangeContentsSize(size); frame->loader().restoreScrollPositionAndViewState(); }
void WebRemoteFrameImpl::initializeFromFrame(WebLocalFrame* source) const { ASSERT(source); WebLocalFrameImpl* localFrameImpl = toWebLocalFrameImpl(source); client()->initializeChildFrame( localFrameImpl->frame()->view()->frameRect(), localFrameImpl->frame()->page()->deviceScaleFactor()); }
void ChromeClientImpl::handleKeyboardEventOnTextField( HTMLInputElement& inputElement, KeyboardEvent& event) { WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(inputElement.document().frame()); if (webframe->autofillClient()) webframe->autofillClient()->textFieldDidReceiveKeyDown( WebInputElement(&inputElement), WebKeyboardEventBuilder(event)); }
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)); }
// 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 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 ChromeClientImpl::didChangeValueInTextField( HTMLFormControlElement& element) { WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(element.document().frame()); if (webframe->autofillClient()) webframe->autofillClient()->textFieldDidChange( WebFormControlElement(&element)); m_webView->pageImportanceSignals()->setHadFormInteraction(); }
void WebSharedWorkerImpl::loadShadowPage() { WebLocalFrameImpl* webFrame = toWebLocalFrameImpl(m_webView->mainFrame()); // Construct substitute data source for the 'shadow page'. We only need it // to have same origin as the worker so the loading checks work correctly. CString content(""); RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), content.length())); webFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(m_url), SubstituteData(buffer, "text/html", "UTF-8", KURL()))); }
void ChromeClientImpl::attachRootLayer(WebLayer* rootLayer, LocalFrame* localFrame) { WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(localFrame)->localRoot(); // This method can be called while the frame is being detached. In that // case, the rootLayer is null, and the widget is already destroyed. DCHECK(webFrame->frameWidget() || !rootLayer); if (webFrame->frameWidget()) webFrame->frameWidget()->setRootLayer(rootLayer); }
void ChromeClientImpl::startDragging(LocalFrame* frame, const WebDragData& dragData, WebDragOperationsMask mask, const WebImage& dragImage, const WebPoint& dragImageOffset) { WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(frame); WebReferrerPolicy policy = webFrame->document().referrerPolicy(); m_webView->setDoingDragAndDrop(true); webFrame->localRoot()->frameWidget()->client()->startDragging( policy, dragData, mask, dragImage, dragImageOffset); }
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 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 ChromeClientImpl::attachRootGraphicsLayer(GraphicsLayer* rootLayer, LocalFrame* localFrame) { DCHECK(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(localFrame)->localRoot(); // This method can be called while the frame is being detached. In that // case, the rootLayer is null, and the widget is already destroyed. DCHECK(webFrame->frameWidget() || !rootLayer); if (webFrame->frameWidget()) webFrame->frameWidget()->setRootGraphicsLayer(rootLayer); }
// 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; }
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(); }
void ChromeClientImpl::detachCompositorAnimationTimeline( CompositorAnimationTimeline* compositorTimeline, LocalFrame* localFrame) { WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(localFrame)->localRoot(); // This method can be called when the frame is being detached, after the // widget is destroyed. if (webFrame->frameWidget()) webFrame->frameWidget()->detachCompositorAnimationTimeline( compositorTimeline); }
bool ContextFeaturesClientImpl::askIfIsEnabled(Document* document, ContextFeatures::FeatureType type, bool defaultValue) { WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(document->frame()); if (!frame || !frame->contentSettingsClient()) return defaultValue; switch (type) { case ContextFeatures::MutationEvents: return frame->contentSettingsClient()->allowMutationEvents(defaultValue); default: return defaultValue; } }
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; }
int TextFinder::ordinalOfFirstMatchForFrame(WebLocalFrameImpl* frame) const { int ordinal = 0; WebLocalFrameImpl* mainFrameImpl = m_ownerFrame.viewImpl()->mainFrameImpl(); // Iterate from the main frame up to (but not including) |frame| and // add up the number of matches found so far. for (WebLocalFrameImpl* it = mainFrameImpl; it != frame; it = toWebLocalFrameImpl(it->traverseNext(true))) { TextFinder& finder = it->ensureTextFinder(); if (finder.m_lastMatchCount > 0) ordinal += finder.m_lastMatchCount; } return ordinal; }
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; }
int TextFinder::selectFindMatch(unsigned index, WebRect* selectionRect) { ASSERT_WITH_SECURITY_IMPLICATION(index < m_findMatchesCache.size()); RefPtrWillBeRawPtr<Range> range = m_findMatchesCache[index].m_range; if (!range->boundaryPointsValid() || !range->startContainer()->inDocument()) return -1; // Check if the match is already selected. TextFinder& mainFrameTextFinder = m_ownerFrame.viewImpl()->mainFrameImpl()->ensureTextFinder(); WebLocalFrameImpl* activeMatchFrame = mainFrameTextFinder.m_currentActiveMatchFrame; if (&m_ownerFrame != activeMatchFrame || !m_activeMatch || !areRangesEqual(m_activeMatch.get(), range.get())) { if (isActiveMatchFrameValid()) activeMatchFrame->ensureTextFinder().setMatchMarkerActive(false); m_activeMatchIndexInCurrentFrame = m_findMatchesCache[index].m_ordinal - 1; // Set this frame as the active frame (the one with the active highlight). mainFrameTextFinder.m_currentActiveMatchFrame = &m_ownerFrame; m_ownerFrame.viewImpl()->setFocusedFrame(&m_ownerFrame); m_activeMatch = range.release(); setMarkerActive(m_activeMatch.get(), true); // Clear any user selection, to make sure Find Next continues on from the match we just activated. m_ownerFrame.frame()->selection().clear(); // Make sure no node is focused. See http://crbug.com/38700. m_ownerFrame.frame()->document()->setFocusedElement(nullptr); } IntRect activeMatchRect; IntRect activeMatchBoundingBox = enclosingIntRect(RenderObject::absoluteBoundingBoxRectForRange(m_activeMatch.get())); if (!activeMatchBoundingBox.isEmpty()) { if (m_activeMatch->firstNode() && m_activeMatch->firstNode()->renderer()) { m_activeMatch->firstNode()->renderer()->scrollRectToVisible( activeMatchBoundingBox, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded); } // Zoom to the active match. activeMatchRect = m_ownerFrame.frameView()->contentsToWindow(activeMatchBoundingBox); m_ownerFrame.viewImpl()->zoomToFindInPageRect(activeMatchRect); } if (selectionRect) *selectionRect = activeMatchRect; return ordinalOfFirstMatch() + m_activeMatchIndexInCurrentFrame + 1; }
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)); }
bool DatabaseClientImpl::allowDatabase(ExecutionContext* executionContext, const String& name, const String& displayName, unsigned estimatedSize) { DCHECK(executionContext->isContextThread()); Document* document = toDocument(executionContext); WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()); if (!webFrame) return false; if (webFrame->contentSettingsClient()) return webFrame->contentSettingsClient()->allowDatabase(name, displayName, estimatedSize); return true; }