unsigned WebInspectorProxy::inspectionLevel() const { auto findResult = pageLevelMap().find(inspectedPage()); if (findResult != pageLevelMap().end()) return findResult->value + 1; return 1; }
unsigned inspectorLevelForPage(WebPageProxy* page) { if (page) { auto findResult = pageLevelMap().find(page); if (findResult != pageLevelMap().end()) return findResult->value + 1; } return 1; }
void WebInspectorProxy::invalidate() { #if ENABLE(INSPECTOR_SERVER) if (m_remoteInspectionPageId) WebInspectorServer::singleton().unregisterPage(m_remoteInspectionPageId); #endif m_inspectedPage->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID()); didClose(); platformInvalidate(); pageLevelMap().remove(m_inspectedPage); m_inspectedPage = nullptr; }
void WebInspectorProxy::eagerlyCreateInspectorPage() { if (m_inspectorPage) return; m_inspectorPage = platformCreateInspectorPage(); ASSERT(m_inspectorPage); if (!m_inspectorPage) return; pageLevelMap().set(m_inspectorPage, inspectionLevel()); WKPagePolicyClientV1 policyClient = { { 1, this }, nullptr, // decidePolicyForNavigationAction_deprecatedForUseWithV0 nullptr, // decidePolicyForNewWindowAction nullptr, // decidePolicyForResponse_deprecatedForUseWithV0 nullptr, // unableToImplementPolicy decidePolicyForNavigationAction, nullptr, // decidePolicyForResponse }; WKPageLoaderClientV5 loaderClient = { { 5, this }, nullptr, // didStartProvisionalLoadForFrame nullptr, // didReceiveServerRedirectForProvisionalLoadForFrame nullptr, // didFailProvisionalLoadWithErrorForFrame nullptr, // didCommitLoadForFrame nullptr, // didFinishDocumentLoadForFrame nullptr, // didFinishLoadForFrame nullptr, // didFailLoadWithErrorForFrame nullptr, // didSameDocumentNavigationForFrame nullptr, // didReceiveTitleForFrame nullptr, // didFirstLayoutForFrame nullptr, // didFirstVisuallyNonEmptyLayoutForFrame nullptr, // didRemoveFrameFromHierarchy nullptr, // didDisplayInsecureContentForFrame nullptr, // didRunInsecureContentForFrame nullptr, // canAuthenticateAgainstProtectionSpaceInFrame nullptr, // didReceiveAuthenticationChallengeInFrame nullptr, // didStartProgress nullptr, // didChangeProgress nullptr, // didFinishProgress nullptr, // didBecomeUnresponsive nullptr, // didBecomeResponsive processDidCrash, nullptr, // didChangeBackForwardList nullptr, // shouldGoToBackForwardListItem nullptr, // didFailToInitializePlugin_deprecatedForUseWithV0 nullptr, // didDetectXSSForFrame nullptr, // didNewFirstVisuallyNonEmptyLayout_unavailable nullptr, // willGoToBackForwardListItem nullptr, // interactionOccurredWhileProcessUnresponsive nullptr, // pluginDidFail_deprecatedForUseWithV1 nullptr, // didReceiveIntentForFrame_unavailable nullptr, // registerIntentServiceForFrame_unavailable nullptr, // didLayout nullptr, // pluginLoadPolicy_deprecatedForUseWithV2 nullptr, // pluginDidFail nullptr, // pluginLoadPolicy nullptr, // webGLLoadPolicy nullptr, // resolveWebGLLoadPolicy nullptr, // shouldKeepCurrentBackForwardListItemInList }; WKPageContextMenuClientV3 contextMenuClient = { { 3, this }, 0, // getContextMenuFromProposedMenu_deprecatedForUseWithV0 0, // customContextMenuItemSelected 0, // contextMenuDismissed getContextMenuFromProposedMenu, 0, // showContextMenu 0, // hideContextMenu }; WKPageSetPagePolicyClient(toAPI(m_inspectorPage), &policyClient.base); WKPageSetPageLoaderClient(toAPI(m_inspectorPage), &loaderClient.base); WKPageSetPageContextMenuClient(toAPI(m_inspectorPage), &contextMenuClient.base); m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID(), *this); m_inspectorPage->process().assumeReadAccessToBaseURL(WebInspectorProxy::inspectorBaseURL()); }
bool WebInspectorProxy::isInspectorPage(WebPageProxy& webPage) { return pageLevelMap().contains(&webPage); }
void untrackInspectorPage(WebPageProxy* page) { pageLevelMap().remove(page); }
void trackInspectorPage(WebPageProxy* page) { pageLevelMap().set(page, inspectorLevelForPage(page)); }