waffle

Waffle is a weblog.
The author of Waffle, some guy in Sweden, also occasionally writes stmts.net.

How To Make Safari 3’s WebKit Start Handing You Favicons (Site Icons) Again

Needless to say, when WebKit in Leopard (and, it turned out, WebKit in any system where Safari 3 exists) stopped doling out “hey, you have a favicon” delegate messages (webView:didReceiveIcon:forFrame:), and you make a search tool whose only form of distinguishing between different search engines are in many places by icon and color, you get pretty pissed.

The WebKit ticket is #16296, and it turns out that the backing icon database was disabled by default since driving WebKit into multithreading for the sake of the few apps that want to use icons was deemed unsavory. The fix in WebKit itself is to start the requisite icon database engine if the delegate method is being implemented, but until this bubbles up to Safari-level distribution, one has to call +[WebIconDatabase sharedIconDatabase] to force the database to allocate a singleton instance and thus start itself. Here’s how:

@try {
    Class webIconDatabaseClass = NSClassFromString(@"WebIconDatabase");
    // Since this is private API, it may go away; only call if the class exists.
    if (webIconDatabaseClass != Nil) {
        [webIconDatabaseClass performSelector:@selector(sharedIconDatabase)];
    }
} @catch (NSException *exc) {
#pragma unused(exc)
}

Comments

  1. […] Jesper says that, due to a bug in Web Kit, if you want your application to receive the -webView:didReceiveIcon:forFrame: delegate method, you have to start up the (private) shared icon database. […]

    By Michael Tsai - Blog - Safari 3 Favicons · 2007.12.31 16:41

Sorry, the comment form is closed at this time.