OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/crw_js_plugin_placeholder_manager.h" | 5 #import "ios/web/web_state/js/crw_js_plugin_placeholder_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "ios/web/public/web_client.h" | 9 #include "ios/web/public/web_client.h" |
10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
11 @implementation CRWJSPluginPlaceholderManager | 15 @implementation CRWJSPluginPlaceholderManager |
12 | 16 |
13 namespace { | 17 namespace { |
14 | 18 |
15 // Returns a string with \ and ' escaped, and wrapped in '. | 19 // Returns a string with \ and ' escaped, and wrapped in '. |
16 // This is used instead of GetQuotedJSONString because that will convert | 20 // This is used instead of GetQuotedJSONString because that will convert |
17 // UTF-16 to UTF-8, which can cause problems when injecting scripts depending | 21 // UTF-16 to UTF-8, which can cause problems when injecting scripts depending |
18 // on the page encoding (see crbug.com/302741). | 22 // on the page encoding (see crbug.com/302741). |
19 NSString* EscapedQuotedString(NSString* string) { | 23 NSString* EscapedQuotedString(NSString* string) { |
20 string = [string stringByReplacingOccurrencesOfString:@"\\" | 24 string = [string stringByReplacingOccurrencesOfString:@"\\" |
(...skipping 17 matching lines...) Expand all Loading... |
38 DCHECK(web::GetWebClient()); | 42 DCHECK(web::GetWebClient()); |
39 NSString* pluginNotSupportedText = base::SysUTF16ToNSString( | 43 NSString* pluginNotSupportedText = base::SysUTF16ToNSString( |
40 web::GetWebClient()->GetPluginNotSupportedText()); | 44 web::GetWebClient()->GetPluginNotSupportedText()); |
41 NSString* placeholderCall = [NSString stringWithFormat: | 45 NSString* placeholderCall = [NSString stringWithFormat: |
42 @"__gCrWeb.plugin.addPluginPlaceholders(%@);", | 46 @"__gCrWeb.plugin.addPluginPlaceholders(%@);", |
43 EscapedQuotedString(pluginNotSupportedText)]; | 47 EscapedQuotedString(pluginNotSupportedText)]; |
44 return [baseContent stringByAppendingString:placeholderCall]; | 48 return [baseContent stringByAppendingString:placeholderCall]; |
45 } | 49 } |
46 | 50 |
47 @end | 51 @end |
OLD | NEW |