Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(703)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2161463002: [ios] Retry injection of windowID if it has failed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/web/web_state/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #import <objc/runtime.h> 9 #import <objc/runtime.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 - (BOOL)scriptHasBeenInjectedForClass:(Class)JSInjectionManagerClass 2516 - (BOOL)scriptHasBeenInjectedForClass:(Class)JSInjectionManagerClass
2517 presenceBeacon:(NSString*)beacon { 2517 presenceBeacon:(NSString*)beacon {
2518 return [_injectedScriptManagers containsObject:JSInjectionManagerClass]; 2518 return [_injectedScriptManagers containsObject:JSInjectionManagerClass];
2519 } 2519 }
2520 2520
2521 - (void)injectScript:(NSString*)script forClass:(Class)JSInjectionManagerClass { 2521 - (void)injectScript:(NSString*)script forClass:(Class)JSInjectionManagerClass {
2522 // Skip evaluation if there's no content (e.g., if what's being injected is 2522 // Skip evaluation if there's no content (e.g., if what's being injected is
2523 // an umbrella manager). 2523 // an umbrella manager).
2524 if ([script length]) { 2524 if ([script length]) {
2525 // Every injection except windowID requires windowID check. 2525 // Every injection except windowID requires windowID check.
2526 if (JSInjectionManagerClass != [CRWJSWindowIdManager class]) 2526 if (JSInjectionManagerClass != [CRWJSWindowIdManager class]) {
2527 script = [self scriptByAddingWindowIDCheckForScript:script]; 2527 script = [self scriptByAddingWindowIDCheckForScript:script];
2528 web::ExecuteJavaScript(_webView, script, nil); 2528 web::ExecuteJavaScript(_webView, script, nil);
2529 } else {
2530 web::ExecuteJavaScript(_webView, script, ^(id, NSError* error) {
2531 // TODO(crbug.com/628832): Refactor retry logic.
2532 if (error.code == WKErrorJavaScriptExceptionOccurred) {
2533 // This can happen if WKUserScript has not been injected yet.
kkhorimoto 2016/07/18 18:29:36 There are other reasons why we can get an exceptio
Eugene But (OOO till 7-30) 2016/07/18 18:43:09 The other reason is a bug inside window_id.js, but
2534 // Retry if that's the case, because windowID injection is critical
2535 // for the system to function.
2536 [_injectedScriptManagers removeObject:JSInjectionManagerClass];
2537 [self injectWindowID];
2538 }
2539 });
2540 }
2529 } 2541 }
2530 [_injectedScriptManagers addObject:JSInjectionManagerClass]; 2542 [_injectedScriptManagers addObject:JSInjectionManagerClass];
2531 } 2543 }
2532 2544
2533 #pragma mark - 2545 #pragma mark -
2534 2546
2535 - (void)evaluateUserJavaScript:(NSString*)script { 2547 - (void)evaluateUserJavaScript:(NSString*)script {
2536 [self setUserInteractionRegistered:YES]; 2548 [self setUserInteractionRegistered:YES];
2537 web::ExecuteJavaScript(_webView, script, nil); 2549 web::ExecuteJavaScript(_webView, script, nil);
2538 } 2550 }
(...skipping 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after
5662 } 5674 }
5663 5675
5664 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 5676 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
5665 } 5677 }
5666 5678
5667 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { 5679 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action {
5668 return [action.request valueForHTTPHeaderField:@"Referer"]; 5680 return [action.request valueForHTTPHeaderField:@"Referer"];
5669 } 5681 }
5670 5682
5671 @end 5683 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698