| 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 4a51fe0ab9c736797dd064c1accf28dad62ab408..bcc7afbd77b985b35613968e319d9c9ead935241 100644
|
| --- a/ios/web/web_state/ui/crw_web_controller.mm
|
| +++ b/ios/web/web_state/ui/crw_web_controller.mm
|
| @@ -2296,6 +2296,22 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
|
|
|
| - (void)executeUserJavaScript:(NSString*)script
|
| completionHandler:(web::JavaScriptResultBlock)completion {
|
| + // For security reasons, executing JavaScript on pages with app-specific URLs
|
| + // is not allowed, because those pages may have elevated privileges.
|
| + GURL lastCommittedURL = self.webState->GetLastCommittedURL();
|
| + if (web::GetWebClient()->IsAppSpecificURL(lastCommittedURL)) {
|
| + if (completion) {
|
| + dispatch_async(dispatch_get_main_queue(), ^{
|
| + base::scoped_nsobject<NSError> error([[NSError alloc]
|
| + initWithDomain:web::kJSEvaluationErrorDomain
|
| + code:web::JS_EVALUATION_ERROR_CODE_NO_WEB_VIEW
|
| + userInfo:nil]);
|
| + completion(nil, error);
|
| + });
|
| + }
|
| + return;
|
| + }
|
| +
|
| [self setUserInteractionRegistered:YES];
|
| [self executeJavaScript:script completionHandler:completion];
|
| }
|
|
|