]> git.saurik.com Git - cydia.git/commitdiff
Apply custom useragent after loadView.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 9 Mar 2011 10:50:18 +0000 (02:50 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 9 Mar 2011 10:50:18 +0000 (02:50 -0800)
CyteKit/WebViewController.mm
MobileCydia.mm

index 964e5237e6e28adb6953ee4b224dfef3feace71f..76379fb61f9ac1f2ea17289196f87a04d78d4710 100644 (file)
@@ -775,6 +775,10 @@ float CYScrollViewDecelerationRateNormal;
     } return self;
 }
 
+- (NSString *) applicationNameForUserAgent {
+    return nil;
+}
+
 - (void) loadView {
     CGRect bounds([[UIScreen mainScreen] applicationFrame]);
 
@@ -812,6 +816,9 @@ float CYScrollViewDecelerationRateNormal;
     [preferences setJavaScriptCanOpenWindowsAutomatically:YES];
     [preferences setOfflineWebApplicationCacheEnabled:YES];
 
+    if (NSString *agent = [self applicationNameForUserAgent])
+        [webview setApplicationNameForUserAgent:agent];
+
     if ([webview respondsToSelector:@selector(setShouldUpdateWhileOffscreen:)])
         [webview setShouldUpdateWhileOffscreen:NO];
 
index 11127ac4483e9bd02f635198455c3fceb981f2ac..3d92930fa7d7ece3b40aab128226f8ffac49fe00 100644 (file)
@@ -4279,22 +4279,22 @@ static _H<NSMutableSet> Diversions_;
     [cydia_ setDelegate:delegate];
 }
 
-- (id) init {
-    if ((self = [super initWithWidth:0 ofClass:[CydiaWebViewController class]]) != nil) {
-        cydia_ = [[[CydiaObject alloc] initWithDelegate:indirect_] autorelease];
-
-        WebView *webview([[webview_ _documentView] webView]);
+- (NSString *) applicationNameForUserAgent {
+    NSString *application([NSString stringWithFormat:@"Cydia/%@", @ Cydia_]);
 
-        NSString *application([NSString stringWithFormat:@"Cydia/%@", @ Cydia_]);
+    if (Safari_ != nil)
+        application = [NSString stringWithFormat:@"Safari/%@ %@", Safari_, application];
+    if (Build_ != nil)
+        application = [NSString stringWithFormat:@"Mobile/%@ %@", Build_, application];
+    if (Product_ != nil)
+        application = [NSString stringWithFormat:@"Version/%@ %@", Product_, application];
 
-        if (Safari_ != nil)
-            application = [NSString stringWithFormat:@"Safari/%@ %@", Safari_, application];
-        if (Build_ != nil)
-            application = [NSString stringWithFormat:@"Mobile/%@ %@", Build_, application];
-        if (Product_ != nil)
-            application = [NSString stringWithFormat:@"Version/%@ %@", Product_, application];
+    return application;
+}
 
-        [webview setApplicationNameForUserAgent:application];
+- (id) init {
+    if ((self = [super initWithWidth:0 ofClass:[CydiaWebViewController class]]) != nil) {
+        cydia_ = [[[CydiaObject alloc] initWithDelegate:indirect_] autorelease];
     } return self;
 }