views:

527

answers:

3

How do I implement this method (see below)? I'm new to Objective-C and I'm just not getting it right.

From: http://lists.apple.com/archives/Webkitsdk-dev/2008/Apr/msg00027.html

By default databases have a quota of 0; this quota must be increased before any database will be stored on disk.

WebKit clients should implement the WebUIDelegate method - webView:frame:exceededDatabaseQuotaForSecurityOrigin:database: and increase the quota as desired when that method is called. This method is defined in WebUIDelegatePrivate.h. It was added too late in the previous release cycle to make it into a non-private header. It would be worthwhile to file a bug about moving this call to WebUIDelegate.h so that it is part of the official API.

John

A: 

Got some help from a discussion board:

There seems to be an implementation of this method included in WebKit's WebKitTools in their public SVN. (The class is named UIDelegate). http://trac.webkit.org/browser/trunk/WebKitTools/DumpRenderTree/mac/U...

I'm assuming you've created a delegate for your WebKit view. In that delegate class, create a method with the signature:

- (void)webView:(WebView *)sender frame:(WebFrame *)frame
exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin
database:(NSString *)databaseIdentifier;

You can probably use a modified version of UIDelegate's implementation:

- (void)webView:(WebView *)sender frame:(WebFrame *)frame
exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin
database:(NSString *)databaseIdentifier
{
    static const unsigned long long defaultQuota = 5 * 1024 * 1024;
    [origin setQuota:defaultQuota];
}

I haven't tried this, so YMMV.

Jon

Jeff
+1  A: 

In whatever class you've defined as the delegate for your WebView you need to implement that method, something like this:

- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)databaseIdentifier {
    unsigned long long newQuotaBytes = 10 * 1024 * 1024;
    [origin setQuota:newQuotaBytes];

    // origin also responds to -usage method to return current size for all databases in this origin
}
Ashley Clark
A: 

Here's the final answer.

I was using the MiniBrowser sample app.

In MyDocument.m I added this function:

- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(id)origin database:(NSString *)databaseIdentifier
{
    static const unsigned long long defaultQuota = 5 * 1024 * 1024;
    if ([origin respondsToSelector: @selector(setQuota:)]) {
     [origin setQuota: defaultQuota];
    } else { 
     NSLog(@"could not increase quota for %@", defaultQuota); 
    }
}
Jeff