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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/web_state/js/crw_js_plugin_placeholder_manager.mm
diff --git a/ios/web/web_state/js/crw_js_plugin_placeholder_manager.mm b/ios/web/web_state/js/crw_js_plugin_placeholder_manager.mm
new file mode 100644
index 0000000000000000000000000000000000000000..6378d87b55f375b7d480c20e9da5dff83ad242b2
--- /dev/null
+++ b/ios/web/web_state/js/crw_js_plugin_placeholder_manager.mm
@@ -0,0 +1,51 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/web/web_state/js/crw_js_plugin_placeholder_manager.h"
+
+#include "base/logging.h"
+#include "base/strings/sys_string_conversions.h"
+#include "ios/web/public/web_client.h"
+
+@implementation CRWJSPluginPlaceholderManager
+
+namespace {
+
+// Returns a string with \ and ' escaped, and wrapped in '.
+// This is used instead of GetQuotedJSONString because that will convert
+// UTF-16 to UTF-8, which can cause problems when injecting scripts depending
+// on the page encoding (see crbug.com/302741).
+NSString* EscapedQuotedString(NSString* string) {
+ string = [string stringByReplacingOccurrencesOfString:@"\\"
+ withString:@"\\\\"];
+ string = [string stringByReplacingOccurrencesOfString:@"'"
+ withString:@"\\'"];
+ return [NSString stringWithFormat:@"'%@'", string];
+}
+
+}
+
+#pragma mark -
+#pragma mark ProtectedMethods
+
+- (NSString*)scriptPath {
+ return @"plugin_placeholder";
+}
+
+- (NSString*)presenceBeacon {
+ return @"__gCrWeb.plugin";
+}
+
+- (NSString*)staticInjectionContent {
+ NSString* baseContent = [super staticInjectionContent];
+ DCHECK(web::GetWebClient());
+ NSString* pluginNotSupportedText = base::SysUTF16ToNSString(
+ web::GetWebClient()->GetPluginNotSupportedText());
+ NSString* placeholderCall = [NSString stringWithFormat:
+ @"__gCrWeb.plugin.addPluginPlaceholders(%@);",
+ EscapedQuotedString(pluginNotSupportedText)];
+ return [baseContent stringByAppendingString:placeholderCall];
+}
+
+@end
« 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