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

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

Issue 2526833003: [ios] Handle gracefully WK messages sent by iframes. (Closed)
Patch Set: Created 4 years 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 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 } 2678 }
2679 } 2679 }
2680 2680
2681 - (NSString*)scriptByAddingWindowIDCheckForScript:(NSString*)script { 2681 - (NSString*)scriptByAddingWindowIDCheckForScript:(NSString*)script {
2682 NSString* kTemplate = @"if (__gCrWeb['windowId'] === '%@') { %@; }"; 2682 NSString* kTemplate = @"if (__gCrWeb['windowId'] === '%@') { %@; }";
2683 return [NSString 2683 return [NSString
2684 stringWithFormat:kTemplate, [_windowIDJSManager windowID], script]; 2684 stringWithFormat:kTemplate, [_windowIDJSManager windowID], script];
2685 } 2685 }
2686 2686
2687 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage { 2687 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage {
2688 CHECK(scriptMessage.frameInfo.mainFrame); 2688 if (!scriptMessage.frameInfo.mainFrame) {
2689 // Messages from iframes are not supported yet.
Jackie Quinn 2016/11/23 19:17:40 super nit: s/not supported yet/not currently suppo
Eugene But (OOO till 7-30) 2016/11/23 19:28:39 Updated comment. The future of iframe injections i
2690 return NO;
2691 }
2692
2689 int errorCode = 0; 2693 int errorCode = 0;
2690 std::string errorMessage; 2694 std::string errorMessage;
2691 std::unique_ptr<base::Value> inputJSONData( 2695 std::unique_ptr<base::Value> inputJSONData(
2692 base::JSONReader::ReadAndReturnError( 2696 base::JSONReader::ReadAndReturnError(
2693 base::SysNSStringToUTF8(scriptMessage.body), false, &errorCode, 2697 base::SysNSStringToUTF8(scriptMessage.body), false, &errorCode,
2694 &errorMessage)); 2698 &errorMessage));
2695 if (errorCode) { 2699 if (errorCode) {
2696 DLOG(WARNING) << "JSON parse error: %s" << errorMessage.c_str(); 2700 DLOG(WARNING) << "JSON parse error: %s" << errorMessage.c_str();
2697 return NO; 2701 return NO;
2698 } 2702 }
(...skipping 3065 matching lines...) Expand 10 before | Expand all | Expand 10 after
5764 } 5768 }
5765 5769
5766 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 5770 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
5767 } 5771 }
5768 5772
5769 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { 5773 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action {
5770 return [action.request valueForHTTPHeaderField:@"Referer"]; 5774 return [action.request valueForHTTPHeaderField:@"Referer"];
5771 } 5775 }
5772 5776
5773 @end 5777 @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