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

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

Issue 1107083002: Upstream more leaf files in ios/web/web_state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-resync
Patch Set: Created 5 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/web/web_state/js/crw_js_plugin_placeholder_manager.h"
6
7 #include "base/logging.h"
8 #include "base/strings/sys_string_conversions.h"
9 #include "ios/web/public/web_client.h"
10
11 @implementation CRWJSPluginPlaceholderManager
12
13 namespace {
14
15 // Returns a string with \ and ' escaped, and wrapped in '.
16 // This is used instead of GetQuotedJSONString because that will convert
17 // UTF-16 to UTF-8, which can cause problems when injecting scripts depending
18 // on the page encoding (see crbug.com/302741).
19 NSString* EscapedQuotedString(NSString* string) {
20 string = [string stringByReplacingOccurrencesOfString:@"\\"
21 withString:@"\\\\"];
22 string = [string stringByReplacingOccurrencesOfString:@"'"
23 withString:@"\\'"];
24 return [NSString stringWithFormat:@"'%@'", string];
25 }
26
27 }
28
29 #pragma mark -
30 #pragma mark ProtectedMethods
31
32 - (NSString*)scriptPath {
33 return @"plugin_placeholder";
34 }
35
36 - (NSString*)presenceBeacon {
37 return @"__gCrWeb.plugin";
38 }
39
40 - (NSString*)staticInjectionContent {
41 NSString* baseContent = [super staticInjectionContent];
42 DCHECK(web::GetWebClient());
43 NSString* pluginNotSupportedText = base::SysUTF16ToNSString(
44 web::GetWebClient()->GetPluginNotSupportedText());
45 NSString* placeholderCall = [NSString stringWithFormat:
46 @"__gCrWeb.plugin.addPluginPlaceholders(%@);",
47 EscapedQuotedString(pluginNotSupportedText)];
48 return [baseContent stringByAppendingString:placeholderCall];
49 }
50
51 @end
OLDNEW
« no previous file with comments | « ios/web/web_state/js/crw_js_plugin_placeholder_manager.h ('k') | ios/web/web_state/js/crw_js_window_id_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698