@@ -19,10 +19,6 @@ @implementation WebViewJavascriptBridge {
1919 WVJB_WEAK id _webViewDelegate;
2020 long _uniqueId;
2121 WebViewJavascriptBridgeBase *_base;
22- #if defined WVJB_PLATFORM_IOS
23- NSUInteger _numRequestsLoading;
24- #endif
25-
2622}
2723
2824/* API
@@ -110,12 +106,6 @@ - (void)webView:(WebView *)webView didFinishLoadForFrame:(WebFrame *)frame
110106{
111107 if (webView != _webView) { return ; }
112108
113- if (![[webView stringByEvaluatingJavaScriptFromString: [_base webViewJavascriptCheckCommand ]] isEqualToString: @" true" ]) {
114- [_base injectJavascriptFile: YES ];
115- }
116-
117- [_base dispatchStartUpMessageQueue ];
118-
119109 if (_webViewDelegate && [_webViewDelegate respondsToSelector: @selector (webView:didFinishLoadForFrame: )]) {
120110 [_webViewDelegate webView: webView didFinishLoadForFrame: frame];
121111 }
@@ -135,7 +125,9 @@ - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary
135125
136126 NSURL *url = [request URL ];
137127 if ([_base isCorrectProcotocolScheme: url]) {
138- if ([_base isCorrectHost: url]) {
128+ if ([_base isBridgeLoadedURL: url]) {
129+ [_base injectJavascriptFile ];
130+ } else if ([_base isQueueMessageURL: url]) {
139131 NSString *messageQueueString = [self _evaluateJavascript: [_base webViewJavascriptFetchQueyCommand ]];
140132 [_base flushMessageQueue: messageQueueString];
141133 } else {
@@ -188,14 +180,6 @@ - (void) _platformSpecificDealloc {
188180- (void )webViewDidFinishLoad : (UIWebView *)webView {
189181 if (webView != _webView) { return ; }
190182
191- _numRequestsLoading--;
192-
193- if (_numRequestsLoading == 0 && ![[webView stringByEvaluatingJavaScriptFromString: [_base webViewJavascriptCheckCommand ]] isEqualToString: @" true" ]) {
194- [_base injectJavascriptFile: YES ];
195- }
196- [_base dispatchStartUpMessageQueue ];
197-
198-
199183 __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate;
200184 if (strongDelegate && [strongDelegate respondsToSelector: @selector (webViewDidFinishLoad: )]) {
201185 [strongDelegate webViewDidFinishLoad: webView];
@@ -205,8 +189,6 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView {
205189- (void )webView : (UIWebView *)webView didFailLoadWithError : (NSError *)error {
206190 if (webView != _webView) { return ; }
207191
208- _numRequestsLoading--;
209-
210192 __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate;
211193 if (strongDelegate && [strongDelegate respondsToSelector: @selector (webView:didFailLoadWithError: )]) {
212194 [strongDelegate webView: webView didFailLoadWithError: error];
@@ -218,7 +200,9 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
218200 NSURL *url = [request URL ];
219201 __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate;
220202 if ([_base isCorrectProcotocolScheme: url]) {
221- if ([_base isCorrectHost: url]) {
203+ if ([_base isBridgeLoadedURL: url]) {
204+ [_base injectJavascriptFile ];
205+ } else if ([_base isQueueMessageURL: url]) {
222206 NSString *messageQueueString = [self _evaluateJavascript: [_base webViewJavascriptFetchQueyCommand ]];
223207 [_base flushMessageQueue: messageQueueString];
224208 } else {
@@ -235,8 +219,6 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
235219- (void )webViewDidStartLoad : (UIWebView *)webView {
236220 if (webView != _webView) { return ; }
237221
238- _numRequestsLoading++;
239-
240222 __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate;
241223 if (strongDelegate && [strongDelegate respondsToSelector: @selector (webViewDidStartLoad: )]) {
242224 [strongDelegate webViewDidStartLoad: webView];
0 commit comments