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

Side by Side Diff: ios/web/web_state/js/page_script_util.mm

Issue 2418143003: [ARC] Converts part of ios/web to ARC. (Closed)
Patch Set: compile guards Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/js/page_script_util.h" 5 #import "ios/web/web_state/js/page_script_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "ios/web/public/web_client.h" 11 #include "ios/web/public/web_client.h"
12 12
13 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support."
15 #endif
16
13 namespace web { 17 namespace web {
14 18
15 NSString* GetPageScript(NSString* script_file_name) { 19 NSString* GetPageScript(NSString* script_file_name) {
16 DCHECK(script_file_name); 20 DCHECK(script_file_name);
17 NSString* path = 21 NSString* path =
18 [base::mac::FrameworkBundle() pathForResource:script_file_name 22 [base::mac::FrameworkBundle() pathForResource:script_file_name
19 ofType:@"js"]; 23 ofType:@"js"];
20 DCHECK(path) << "Script file not found: " 24 DCHECK(path) << "Script file not found: "
21 << base::SysNSStringToUTF8(script_file_name) << ".js"; 25 << base::SysNSStringToUTF8(script_file_name) << ".js";
22 NSError* error = nil; 26 NSError* error = nil;
(...skipping 17 matching lines...) Expand all
40 // __gCrWeb.windowId variable and will break the ability to send messages from 44 // __gCrWeb.windowId variable and will break the ability to send messages from
41 // JS to the native code. Wrapping injected script into "if (!injected)" check 45 // JS to the native code. Wrapping injected script into "if (!injected)" check
42 // prevents multiple injections into the same page. 46 // prevents multiple injections into the same page.
43 NSString* kScriptTemplate = @"if (typeof __gCrWeb !== 'object') { %@; %@ }"; 47 NSString* kScriptTemplate = @"if (typeof __gCrWeb !== 'object') { %@; %@ }";
44 return [NSString stringWithFormat:kScriptTemplate, 48 return [NSString stringWithFormat:kScriptTemplate,
45 GetPageScript(@"web_bundle"), 49 GetPageScript(@"web_bundle"),
46 embedder_page_script]; 50 embedder_page_script];
47 } 51 }
48 52
49 } // namespace web 53 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/web_state/js/crw_js_window_id_manager.mm ('k') | ios/web/web_state/page_viewport_state.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698