Пример #1
0
PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient& pageClient, WebPageConfiguration configuration)
{
    if (!configuration.pageGroup)
        configuration.pageGroup = &m_defaultPageGroup.get();
    if (!configuration.preferences)
        configuration.preferences = &configuration.pageGroup->preferences();
    if (!configuration.visitedLinkProvider)
        configuration.visitedLinkProvider = m_visitedLinkProvider.get();
    if (!configuration.session)
        configuration.session = configuration.preferences->privateBrowsingEnabled() ? &API::Session::legacyPrivateSession() : &API::Session::defaultSession();

    RefPtr<WebProcessProxy> process;
    if (m_processModel == ProcessModelSharedSecondaryProcess) {
        process = &ensureSharedWebProcess();
    } else {
        if (m_haveInitialEmptyProcess) {
            process = m_processes.last();
            m_haveInitialEmptyProcess = false;
        } else if (configuration.relatedPage) {
            // Sharing processes, e.g. when creating the page via window.open().
            process = &configuration.relatedPage->process();
        } else
            process = &createNewWebProcessRespectingProcessCountLimit();
    }

    return process->createWebPage(pageClient, std::move(configuration));
}
Пример #2
0
Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API::PageConfiguration>&& pageConfiguration)
{
    if (!pageConfiguration->pageGroup())
        pageConfiguration->setPageGroup(m_defaultPageGroup.ptr());
    if (!pageConfiguration->preferences())
        pageConfiguration->setPreferences(&pageConfiguration->pageGroup()->preferences());
    if (!pageConfiguration->userContentController())
        pageConfiguration->setUserContentController(&pageConfiguration->pageGroup()->userContentController());
    if (!pageConfiguration->visitedLinkStore())
        pageConfiguration->setVisitedLinkStore(m_visitedLinkStore.ptr());
    if (!pageConfiguration->websiteDataStore()) {
        ASSERT(!pageConfiguration->sessionID().isValid());
        pageConfiguration->setWebsiteDataStore(m_websiteDataStore.get());
        pageConfiguration->setSessionID(pageConfiguration->preferences()->privateBrowsingEnabled() ? SessionID::legacyPrivateSessionID() : SessionID::defaultSessionID());
    }

    RefPtr<WebProcessProxy> process;
    if (m_haveInitialEmptyProcess) {
        process = m_processes.last();
        m_haveInitialEmptyProcess = false;
    } else if (pageConfiguration->relatedPage()) {
        // Sharing processes, e.g. when creating the page via window.open().
        process = &pageConfiguration->relatedPage()->process();
    } else
        process = &createNewWebProcessRespectingProcessCountLimit();

    return process->createWebPage(pageClient, WTFMove(pageConfiguration));
}