Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 79548E91E for ; Mon, 25 Feb 2013 13:41:15 +0000 (UTC) Received: (qmail 85809 invoked by uid 500); 25 Feb 2013 13:41:15 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 85743 invoked by uid 500); 25 Feb 2013 13:41:15 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 82313 invoked by uid 99); 25 Feb 2013 13:41:02 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Feb 2013 13:41:02 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E011582FA49; Mon, 25 Feb 2013 13:41:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mmocny@apache.org To: commits@cordova.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [30/50] ios commit: [CB-2461] Distinguish sub-frame from top-level loads in InAppBrowser. Message-Id: <20130225134101.E011582FA49@tyr.zones.apache.org> Date: Mon, 25 Feb 2013 13:41:01 +0000 (UTC) [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 Authored: Wed Feb 20 15:01:34 2013 -0500 Committer: Andrew Grieve 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;