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); }
// Callback for the old-style synchronous IconDatabase interface. void IconController::loadDecisionReceived(IconLoadDecision iconLoadDecision) { if (!m_waitingForLoadDecision) return; LOG(IconDatabase, "IconController %p was told a load decision is available for its icon", this); continueLoadWithDecision(iconLoadDecision); m_waitingForLoadDecision = false; }