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

Side by Side Diff: ios/web/web_state/js/resources/message_dynamic_ui.js

Issue 1132163007: Invoke JS messaging for UIWebView via window.requestAnimationFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hard code message queue send delay for iforgot.apple.com Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Scripts for the message handler for use with UIWebView. 5 // Scripts for the message handler for use with UIWebView.
6 6
7 goog.provide('__crWeb.messageDynamic'); 7 goog.provide('__crWeb.messageDynamic');
8 8
9 goog.require('__crWeb.common'); 9 goog.require('__crWeb.common');
10 10
11 /** 11 /**
12 * Namespace for this module. 12 * Namespace for this module.
13 */ 13 */
14 __gCrWeb.message_dynamic = {}; 14 __gCrWeb.message_dynamic = {};
15 15
16 /* Beginning of anonymous object. */ 16 /* Beginning of anonymous object. */
17 new function() { 17 new function() {
18 /** 18 /**
19 * Sends queued commands to the Objective-C side. 19 * Sends queued commands to the Objective-C side.
20 * @param {Object} queueObject Queue object containing messages to send. 20 * @param {Object} queueObject Queue object containing messages to send.
21 */ 21 */
22 __gCrWeb.message_dynamic.sendQueue = function(queueObject) { 22 __gCrWeb.message_dynamic.sendQueue = function(queueObject) {
23 // The technique requires the document to be present. If it is not, the 23 var send = function() {
24 // messages will be sent once the document object is created. 24 // The technique requires the document to be present. If it is not, the
25 if (!document || !document.body) { 25 // messages will be sent once the document object is created.
26 // This happens in rare occasions early in the page cycle. It is 26 if (!document || !document.body) {
27 // possible to create a body element indirectly here, but it has side 27 // This happens in rare occasions early in the page cycle. It is
28 // effects such as blocking page redirection. The safest solution is to 28 // possible to create a body element indirectly here, but it has side
29 // try again in 1/10th of a second. 29 // effects such as blocking page redirection. The safest solution is to
30 window.setTimeout(__gCrWeb.message.invokeQueues, 100); 30 // try again in 1/10th of a second.
31 return; 31 window.setTimeout(__gCrWeb.message.invokeQueues, 100);
32 return;
33 }
34
35 var frame = document.createElement('iframe');
36 frame.style.display = 'none';
37 frame.src = queueObject.scheme + '://' + __gCrWeb.windowId + '#' +
38 encodeURIComponent(__gCrWeb.common.JSONStringify(queueObject.queue));
39 queueObject.reset();
40 document.body.appendChild(frame);
41 document.body.removeChild(frame);
42 };
43
44 // The Apple mobile password recovery page does not interact well with
45 // iframes, so on pages with the 'iforgot.apple.com' domain, delay sending
46 // the queue.
47 if (window.location.origin === "https://iforgot.apple.com") {
stuartmorgan 2015/05/18 19:57:08 Let's do a bit of combination self-documentation a
Jackie Quinn 2015/05/18 20:36:42 Done.
48 window.setTimeout(send, 150);
49 } else {
50 send();
32 } 51 }
33
34 var frame = document.createElement('iframe');
35 frame.style.display = 'none';
36 frame.src = queueObject.scheme + '://' + __gCrWeb.windowId + '#' +
37 encodeURIComponent(__gCrWeb.common.JSONStringify(queueObject.queue));
38 queueObject.reset();
39 document.body.appendChild(frame);
40 document.body.removeChild(frame);
41 }; 52 };
42 } 53 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698