PassRefPtr<IconFetcher> IconFetcher::create(Frame* frame, IconFetcherClient* client) { Document* document = frame->document(); HTMLHeadElement* head = document->head(); if (!head) return 0; Vector<IconLinkEntry> entries; for (Node* n = head; n; n = n->traverseNextNode()) { if (!n->hasTagName(linkTag)) continue; HTMLLinkElement* link = static_cast<HTMLLinkElement*>(n); if (!link->isIcon()) continue; parseIconLink(link, entries); } if (entries.isEmpty()) return 0; // Check if any of the entries have the same type as the native icon type. // FIXME: This should be way more sophisticated, and handle conversion // of multisize formats for example. for (unsigned i = 0; i < entries.size(); i++) { const IconLinkEntry& entry = entries[i]; if (entry.type() == NativeIconType) { RefPtr<IconFetcher> iconFetcher = adoptRef(new IconFetcher(frame, client)); iconFetcher->m_entries.append(entry); iconFetcher->loadEntry(); return iconFetcher.release(); } } return 0; }