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

Unified Diff: ios/web/web_state/js/resources/message_dynamic_ui.js

Issue 788253002: Upstream injected JavaScript for the iOS web layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug reference Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/js/resources/message.js ('k') | ios/web/web_state/js/resources/message_dynamic_wk.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/js/resources/message_dynamic_ui.js
diff --git a/ios/web/web_state/js/resources/message_dynamic_ui.js b/ios/web/web_state/js/resources/message_dynamic_ui.js
new file mode 100644
index 0000000000000000000000000000000000000000..5d179541bd1ca349ce50f09fc6a7600507429369
--- /dev/null
+++ b/ios/web/web_state/js/resources/message_dynamic_ui.js
@@ -0,0 +1,38 @@
+// Copyright 2014 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.
+
+// Scripts for the message handler for use with UIWebView.
+
+/**
+ * Namespace for this module.
+ */
+__gCrWeb.message_dynamic = {};
+
+/* Beginning of anonymous object. */
+new function() {
+ /**
+ * Sends queued commands to the Objective-C side.
+ * @param {Object} queueObject Queue object containing messages to send.
+ */
+ __gCrWeb.message_dynamic.sendQueue = function(queueObject) {
+ // The technique requires the document to be present. If it is not, the
+ // messages will be sent once the document object is created.
+ if (!document || !document.body) {
+ // This happens in rare occasions early in the page cycle. It is
+ // possible to create a body element indirectly here, but it has side
+ // effects such as blocking page redirection. The safest solution is to
+ // try again in 1/10th of a second.
+ window.setTimeout(__gCrWeb.message.invokeQueues, 100);
+ return;
+ }
+
+ var frame = document.createElement('iframe');
+ frame.style.display = 'none';
+ frame.src = queueObject.scheme + '://' + __gCrWeb.windowId + '#' +
+ encodeURIComponent(__gCrWeb.common.JSONStringify(queueObject.queue));
+ queueObject.reset();
+ document.body.appendChild(frame);
+ document.body.removeChild(frame);
+ };
+}
« no previous file with comments | « ios/web/web_state/js/resources/message.js ('k') | ios/web/web_state/js/resources/message_dynamic_wk.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698