예제 #1
0
void IconController::startLoader()
{
    // FIXME: We kick off the icon loader when the frame is done receiving its main resource.
    // But we should instead do it when we're done parsing the head element.
    if (!m_frame->loader()->isLoadingMainFrame())
        return;

    if (!iconDatabase().isEnabled())
        return;

    ASSERT(!m_frame->tree()->parent());
    if (!documentCanHaveIcon(m_frame->document()->url()))
        return;

    KURL iconURL(url());
    String urlString(iconURL.string());
    if (urlString.isEmpty())
        return;

    // People who want to avoid loading images generally want to avoid loading all images, unless an exception has been made for site icons.
    // Now that we've accounted for URL mapping, avoid starting the network load if images aren't set to display automatically.
    Settings* settings = m_frame->settings();
    if (settings && !settings->loadsImagesAutomatically() && !settings->loadsSiteIconsIgnoringImageLoadingSetting())
        return;

    // If we're reloading the page, always start the icon load now.
    // FIXME: How can this condition ever be true?
    if (m_frame->loader()->loadType() == FrameLoadTypeReload && m_frame->loader()->loadType() == FrameLoadTypeReloadFromOrigin) {
        continueLoadWithDecision(IconLoadYes);
        return;
    }

    if (iconDatabase().supportsAsynchronousMode()) {
        //  FIXME (<rdar://problem/9168605>) - We should support in-memory-only private browsing icons in asynchronous icon database mode.
        if (iconDatabase().supportsAsynchronousMode() && m_frame->page()->settings()->privateBrowsingEnabled())
            return;

        m_frame->loader()->documentLoader()->getIconLoadDecisionForIconURL(urlString);
        // Commit the icon url mapping to the database just in case we don't end up loading later.
        commitToDatabase(iconURL);
        return;
    }

    IconLoadDecision decision = iconDatabase().synchronousLoadDecisionForIconURL(urlString, m_frame->loader()->documentLoader());

    if (decision == IconLoadUnknown) {
        // In this case, we may end up loading the icon later, but we still want to commit the icon url mapping to the database
        // just in case we don't end up loading later - if we commit the mapping a second time after the load, that's no big deal
        // We also tell the client to register for the notification that the icon is received now so it isn't missed in case the 
        // icon is later read in from disk
        LOG(IconDatabase, "IconController %p might load icon %s later", this, urlString.ascii().data());
        m_waitingForLoadDecision = true;    
        m_frame->loader()->client()->registerForIconNotification();
        commitToDatabase(iconURL);
        return;
    }

    continueLoadWithDecision(decision);
}
bool IconController::appendToIconURLs(IconType iconType, IconURLs* iconURLs)
{
    IconURL faviconURL = iconURL(iconType);
    if (faviconURL.m_iconURL.isEmpty())
        return false;

    iconURLs->append(faviconURL);
    return true;
}
예제 #3
0
void DocumentLoader::setIconURL(const IconURL& url)
{
    if (url.m_iconURL.isEmpty())
        return;

    if (iconURL(url.m_iconType).m_iconURL != url.m_iconURL) {
        m_iconURLs[toIconIndex(url.m_iconType)] = url;
        frameLoader()->didChangeIcons(this, url.m_iconType);
    }
}
예제 #4
0
void Notification::show() 
{
#if PLATFORM(QT)
    if (iconURL().isEmpty()) {
        // Set the state before actually showing, because
        // handling of ondisplay may rely on that.
        if (m_state == Idle) {
            m_state = Showing;
            if (m_notificationCenter->presenter())
                m_notificationCenter->presenter()->show(this);
        }
    } else
        startLoading();
#else
    // prevent double-showing
    if (m_state == Idle && m_notificationCenter->presenter() && m_notificationCenter->presenter()->show(this))
        m_state = Showing;
#endif
}
void IconController::continueLoadWithDecision(IconLoadDecision iconLoadDecision)
{
    ASSERT(iconLoadDecision != IconLoadUnknown);

    //  FIXME (<rdar://problem/9168605>) - We should support in-memory-only private browsing icons in asynchronous icon database mode.
    if (iconDatabase().supportsAsynchronousMode() && m_frame->page()->settings()->privateBrowsingEnabled())
        return;

    if (iconLoadDecision == IconLoadNo) {
        KURL iconURL(url());
        String urlString(iconURL.string());
        if (urlString.isEmpty())
            return;

        LOG(IconDatabase, "IconController::startLoader() - Told not to load this icon, committing iconURL %s to database for pageURL mapping", urlString.ascii().data());
        commitToDatabase(iconURL);

        if (iconDatabase().supportsAsynchronousMode()) {
            m_frame->loader()->documentLoader()->getIconDataForIconURL(urlString);
            return;
        }

        // We were told not to load this icon - that means this icon is already known by the database
        // If the icon data hasn't been read in from disk yet, kick off the read of the icon from the database to make sure someone
        // has done it. This is after registering for the notification so the WebView can call the appropriate delegate method.
        // Otherwise if the icon data *is* available, notify the delegate
        if (!iconDatabase().synchronousIconDataKnownForIconURL(urlString)) {
            LOG(IconDatabase, "Told not to load icon %s but icon data is not yet available - registering for notification and requesting load from disk", urlString.ascii().data());
            m_frame->loader()->client()->registerForIconNotification();
            iconDatabase().synchronousIconForPageURL(m_frame->document()->url().string(), IntSize(0, 0));
            iconDatabase().synchronousIconForPageURL(m_frame->loader()->initialRequest().url().string(), IntSize(0, 0));
        } else
            m_frame->loader()->client()->dispatchDidReceiveIcon();

        return;
    } 

    if (!m_iconLoader)
        m_iconLoader = IconLoader::create(m_frame);

    m_iconLoader->startLoading();
}
예제 #6
0
void Notification::startLoading()
{
    if (m_state != Idle)
        return;
    setPendingActivity(this);
    m_state = Loading;
    ThreadableLoaderOptions options;
    options.sendLoadCallbacks = false;
    options.sniffContent = false;
    options.forcePreflight = false;
    options.allowCredentials = AllowStoredCredentials;
    options.crossOriginRequestPolicy = AllowCrossOriginRequests;
    m_loader = ThreadableLoader::create(scriptExecutionContext(), this, ResourceRequest(iconURL()), options);
}