cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject [30/50] ios commit: [CB-2461] Distinguish sub-frame from top-level loads in InAppBrowser.
Date Mon, 25 Feb 2013 13:41:01 GMT
[CB-2461] Distinguish sub-frame from top-level loads in InAppBrowser.


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/bfdb287c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/bfdb287c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/bfdb287c

Branch: refs/heads/multipart_plugin_result
Commit: bfdb287c5b9d4dc48db5953a1ef8ea1e0d862e13
Parents: f55d0d9
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Wed Feb 20 15:01:34 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Wed Feb 20 15:01:34 2013 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVInAppBrowser.h    |    2 ++
 CordovaLib/Classes/CDVInAppBrowser.m    |    3 ++-
 CordovaLib/Classes/CDVWebViewDelegate.m |   26 ++++++++++++++++++++------
 3 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/bfdb287c/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.h b/CordovaLib/Classes/CDVInAppBrowser.h
index 9ff460a..297d946 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.h
+++ b/CordovaLib/Classes/CDVInAppBrowser.h
@@ -20,6 +20,7 @@
 #import "CDVPlugin.h"
 #import "CDVInvokedUrlCommand.h"
 #import "CDVScreenOrientationDelegate.h"
+#import "CDVWebViewDelegate.h"
 
 @class CDVInAppBrowserViewController;
 
@@ -47,6 +48,7 @@
     NSString* _userAgent;
     NSString* _prevUserAgent;
     NSInteger _userAgentLockToken;
+    CDVWebViewDelegate* _webViewDelegate;
 }
 
 @property (nonatomic, strong) IBOutlet UIWebView* webView;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/bfdb287c/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
index 14671a5..92f7124 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/CordovaLib/Classes/CDVInAppBrowser.m
@@ -209,6 +209,7 @@
     if (self != nil) {
         _userAgent = userAgent;
         _prevUserAgent = prevUserAgent;
+        _webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
         [self createViews];
     }
 
@@ -229,7 +230,7 @@
     [self.view addSubview:self.webView];
     [self.view sendSubviewToBack:self.webView];
 
-    self.webView.delegate = self;
+    self.webView.delegate = _webViewDelegate;
     self.webView.backgroundColor = [UIColor whiteColor];
 
     self.webView.clearsContextBeforeDrawing = YES;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/bfdb287c/CordovaLib/Classes/CDVWebViewDelegate.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVWebViewDelegate.m b/CordovaLib/Classes/CDVWebViewDelegate.m
index 9ee8186..ea7f752 100644
--- a/CordovaLib/Classes/CDVWebViewDelegate.m
+++ b/CordovaLib/Classes/CDVWebViewDelegate.m
@@ -68,7 +68,9 @@ typedef enum {
     if (![self isJsLoadTokenSet:webView]) {
         _state = STATE_WAITING_FOR_FINISH;
         [self setLoadToken:webView];
-        [_delegate webViewDidStartLoad:webView];
+        if ([_delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
+            [_delegate webViewDidStartLoad:webView];
+        }
         [self pollForPageLoadFinish:webView];
     }
 }
@@ -80,7 +82,9 @@ typedef enum {
     }
     if ([self isPageLoaded:webView]) {
         _state = STATE_SHOULD_LOAD_MISSING;
-        [_delegate webViewDidFinishLoad:webView];
+        if ([_delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
+            [_delegate webViewDidFinishLoad:webView];
+        }
     } else {
         [self performSelector:@selector(pollForPageLoaded) withObject:webView afterDelay:50];
     }
@@ -88,7 +92,11 @@ typedef enum {
 
 - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
 {
-    BOOL shouldLoad = [_delegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
+    BOOL shouldLoad = YES;
+
+    if ([_delegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)])
{
+        shouldLoad = [_delegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
+    }
 
     if (shouldLoad) {
         BOOL isTopLevelNavigation = [request.URL isEqual:[request mainDocumentURL]];
@@ -104,7 +112,9 @@ typedef enum {
 {
     if (_state == STATE_NORMAL) {
         if (_loadCount == 0) {
-            [_delegate webViewDidStartLoad:webView];
+            if ([_delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
+                [_delegate webViewDidStartLoad:webView];
+            }
             _loadCount += 1;
         } else if (_loadCount > 0) {
             _loadCount += 1;
@@ -128,7 +138,9 @@ typedef enum {
 {
     if (_state == STATE_NORMAL) {
         if (_loadCount == 1) {
-            [_delegate webViewDidFinishLoad:webView];
+            if ([_delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
+                [_delegate webViewDidFinishLoad:webView];
+            }
             _loadCount -= 1;
         } else if (_loadCount > 1) {
             _loadCount -= 1;
@@ -143,7 +155,9 @@ typedef enum {
 {
     if (_state == STATE_NORMAL) {
         if (_loadCount == 1) {
-            [_delegate webView:webView didFailLoadWithError:error];
+            if ([_delegate respondsToSelector:@selector(didFailLoadWithError:)]) {
+                [_delegate webView:webView didFailLoadWithError:error];
+            }
             _loadCount -= 1;
         } else if (_loadCount > 1) {
             _loadCount -= 1;


Mime
View raw message