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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index 847c3a69eda9aae9ed46f97cf7d3793afc5ef224..b48615c6ee3d71fa2b7f31a2bcfbf267bd16a05b 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -2523,9 +2523,21 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
// an umbrella manager).
if ([script length]) {
// Every injection except windowID requires windowID check.
- if (JSInjectionManagerClass != [CRWJSWindowIdManager class])
+ if (JSInjectionManagerClass != [CRWJSWindowIdManager class]) {
script = [self scriptByAddingWindowIDCheckForScript:script];
- web::ExecuteJavaScript(_webView, script, nil);
+ web::ExecuteJavaScript(_webView, script, nil);
+ } else {
+ web::ExecuteJavaScript(_webView, script, ^(id, NSError* error) {
+ // TODO(crbug.com/628832): Refactor retry logic.
+ if (error.code == WKErrorJavaScriptExceptionOccurred) {
+ // 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
+ // Retry if that's the case, because windowID injection is critical
+ // for the system to function.
+ [_injectedScriptManagers removeObject:JSInjectionManagerClass];
+ [self injectWindowID];
+ }
+ });
+ }
}
[_injectedScriptManagers addObject:JSInjectionManagerClass];
}
« 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