void WebFrameLoaderClient::dispatchDecidePolicyForResponse(FramePolicyFunction function, const ResourceResponse& response, const ResourceRequest& request) { WebPage* webPage = m_frame->page(); if (!webPage) return; if (!request.url().string()) { (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse); return; } RefPtr<APIObject> userData; // Notify the bundle client. WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForResponse(webPage, m_frame, response, request, userData); if (policy == WKBundlePagePolicyActionUse) { (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse); return; } uint64_t listenerID = m_frame->setUpPolicyListener(function); bool receivedPolicyAction; uint64_t policyAction; uint64_t downloadID; // Notify the UIProcess. if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForResponse(m_frame->frameID(), response, request, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForResponse::Reply(receivedPolicyAction, policyAction, downloadID))) return; // We call this synchronously because CFNetwork can only convert a loading connection to a download from its didReceiveResponse callback. if (receivedPolicyAction) m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID); }
void CompositingManager::establishConnection(WebPage& webPage) { IPC::Attachment connectionHandle; webPage.sendSync(Messages::CompositingManagerProxy::EstablishConnection(), Messages::CompositingManagerProxy::EstablishConnection::Reply(connectionHandle)); m_connectionFd = connectionHandle.releaseFileDescriptor(); }
void CompositingManager::establishConnection(WebPage& webPage, WTF::RunLoop& runLoop) { IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection(); IPC::Connection::Identifier connectionIdentifier(socketPair.server); IPC::Attachment connectionClientPort(socketPair.client); m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this, runLoop); m_connection->open(); webPage.sendSync(Messages::CompositingManagerProxy::EstablishConnection(connectionClientPort), Messages::CompositingManagerProxy::EstablishConnection::Reply(), webPage.pageID()); }
bool WebFrameLoaderClient::canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long, const ProtectionSpace& protectionSpace) { // FIXME: Authentication is a per-resource concept, but we don't do per-resource handling in the UIProcess at the API level quite yet. // Once we do, we might need to make sure authentication fits with our solution. WebPage* webPage = m_frame->page(); if (!webPage) return false; bool canAuthenticate; if (!webPage->sendSync(Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame(m_frame->frameID(), protectionSpace), Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame::Reply(canAuthenticate))) return false; return canAuthenticate; }
bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem* item) const { WebPage* webPage = m_frame->page(); if (!webPage) return false; uint64_t itemID = WebBackForwardListProxy::idForItem(item); if (!itemID) { // We should never be considering navigating to an item that is not actually in the back/forward list. ASSERT_NOT_REACHED(); return false; } bool shouldGoToBackForwardListItem; if (!webPage->sendSync(Messages::WebPageProxy::ShouldGoToBackForwardListItem(itemID), Messages::WebPageProxy::ShouldGoToBackForwardListItem::Reply(shouldGoToBackForwardListItem))) return false; return shouldGoToBackForwardListItem; }
void QtNetworkAccessManager::onSslErrors(QNetworkReply* reply, const QList<QSslError>& qSslErrors) { #ifndef QT_NO_SSL WebPage* webPage = obtainOriginatingWebPage(reply->request()); // FIXME: This check can go away once our Qt version is up-to-date. See: QTBUG-23512. if (!webPage) return; String hostname = reply->url().host(); bool ignoreErrors = false; if (webPage->sendSync( Messages::WebPageProxy::CertificateVerificationRequest(hostname), Messages::WebPageProxy::CertificateVerificationRequest::Reply(ignoreErrors))) { if (ignoreErrors) reply->ignoreSslErrors(qSslErrors); } #endif }
void QtNetworkAccessManager::onAuthenticationRequired(QNetworkReply* reply, QAuthenticator* authenticator) { WebPage* webPage = obtainOriginatingWebPage(reply->request()); // FIXME: This check can go away once our Qt version is up-to-date. See: QTBUG-23512. if (!webPage) return; String hostname = reply->url().toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment | QUrl::StripTrailingSlash); String realm = authenticator->realm(); String prefilledUsername = authenticator->user(); String username; String password; if (webPage->sendSync( Messages::WebPageProxy::AuthenticationRequiredRequest(hostname, realm, prefilledUsername), Messages::WebPageProxy::AuthenticationRequiredRequest::Reply(username, password))) { if (!username.isEmpty()) authenticator->setUser(username); if (!password.isEmpty()) authenticator->setPassword(password); } }
void QtNetworkAccessManager::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* authenticator) { // FIXME: Check if there is a better way to get a reference to the page. WebPage* webPage = m_webProcess->focusedWebPage(); if (!webPage) return; String hostname = proxy.hostName(); uint16_t port = static_cast<uint16_t>(proxy.port()); String prefilledUsername = authenticator->user(); String username; String password; if (webPage->sendSync( Messages::WebPageProxy::ProxyAuthenticationRequiredRequest(hostname, port, prefilledUsername), Messages::WebPageProxy::ProxyAuthenticationRequiredRequest::Reply(username, password))) { if (!username.isEmpty()) authenticator->setUser(username); if (!password.isEmpty()) authenticator->setPassword(password); } }
void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> formState) { WebPage* webPage = m_frame->page(); if (!webPage) return; // Always ignore requests with empty URLs. if (request.isEmpty()) { (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyIgnore); return; } RefPtr<APIObject> userData; RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState); // Notify the bundle client. WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame, action.get(), request, userData); if (policy == WKBundlePagePolicyActionUse) { (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse); return; } uint64_t listenerID = m_frame->setUpPolicyListener(function); bool receivedPolicyAction; uint64_t policyAction; uint64_t downloadID; // Notify the UIProcess. if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), action->navigationType(), action->modifiers(), action->mouseButton(), request, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForNavigationAction::Reply(receivedPolicyAction, policyAction, downloadID))) return; // We call this synchronously because WebCore cannot gracefully handle a frame load without a synchronous navigation policy reply. if (receivedPolicyAction) m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID); }