简体   繁体   中英

Cocoa: Unable to access local DB of HTML5 web app when executed in webkit

Please help me in this what I am trying to do is I have

  1. a Cocoa application with webkit in it.
  2. an HTML5 based web application with local database.

I am trying to run this HTML5 application in cocoa application and get this error "Error: Unknown error Error: SECURITY_ERR: DOM Exception 18." same application is working fine in

  1. Safari
  2. iphone safari
  3. UIWebkit

I have tried following things

@interface WebPreferences (WebPreferencesPrivate)
- (void) _setLocalStorageDatabasePath:(NSString *)path;
- (void) setDatabasesEnabled: (BOOL) databaseEnabled;
- (void) setLocalStorageEnabled: (BOOL) localStorageEnabled;
@end

WebPreferences* prefs = [self.mainWebVEW preferences];
[prefs _setLocalStorageDatabasePath:appdir];
[prefs setDatabasesEnabled:YES];
[prefs setLocalStorageEnabled:YES];
[prefs setDefaultFontSize:20];

only preference that seem working is font size.

Can anybody help me how to get over this?

Thanks in advance

Regards

Ankit

ok so finally resolved it all you have to do is use one more private API

@interface WebView(WebViewPrivate)
- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(id) origin database:(NSString *)databaseIdentifier;
@end

- (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 performSelector:@selector(setQuota:) withObject:[NSNumber numberWithLongLong: defaultQuota]];
} else { 
    NSLog(@"could not increase quota for %@", defaultQuota); 
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM