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

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

Issue 2449333002: [ios] Pass more --jscomp_error switches to the closure Compiler. (Closed)
Patch Set: Created 4 years, 1 month 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
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. 5 // Scripts for the message handler.
6 6
7 goog.provide('__crWeb.message'); 7 goog.provide('__crWeb.message');
8 8
9 goog.require('__crWeb.common'); 9 goog.require('__crWeb.common');
10 10
(...skipping 17 matching lines...) Expand all
28 // Since the array will be JSON serialized, protect against non-standard 28 // Since the array will be JSON serialized, protect against non-standard
29 // custom versions of Array.prototype.toJSON. 29 // custom versions of Array.prototype.toJSON.
30 delete messageQueue_.queue.toJSON; 30 delete messageQueue_.queue.toJSON;
31 } 31 }
32 }; 32 };
33 messageQueue_.reset(); 33 messageQueue_.reset();
34 34
35 /** 35 /**
36 * Invokes a command on the Objective-C side. 36 * Invokes a command on the Objective-C side.
37 * @param {Object} command The command in a JavaScript object. 37 * @param {Object} command The command in a JavaScript object.
38 * @private 38 * @public
dpapad 2016/10/26 17:05:24 No need for @public. I don't even think such an an
Eugene But (OOO till 7-30) 2016/10/26 17:54:45 Done.
Justin Donnelly 2016/10/26 21:06:52 If you prefer not to use it for stylistic reasons,
Eugene But (OOO till 7-30) 2016/10/26 21:16:23 Thanks! I would prefer to use @public if it's a re
Eugene But (OOO till 7-30) 2016/10/27 23:23:21 Added @public back.
39 */ 39 */
40 __gCrWeb.message.invokeOnHost = function(command) { 40 __gCrWeb.message.invokeOnHost = function(command) {
41 messageQueue_.queue.push(command); 41 messageQueue_.queue.push(command);
42 sendQueue_(messageQueue_); 42 sendQueue_(messageQueue_);
43 }; 43 };
44 44
45 /** 45 /**
46 * Returns the message queue as a string. 46 * Returns the message queue as a string.
47 * @return {string} The current message queue as a JSON string. 47 * @return {string} The current message queue as a JSON string.
48 */ 48 */
(...skipping 18 matching lines...) Expand all
67 } 67 }
68 // Some pages/plugins implement Object.prototype.toJSON, which can result 68 // Some pages/plugins implement Object.prototype.toJSON, which can result
69 // in serializing messageQueue_ to an invalid format. 69 // in serializing messageQueue_ to an invalid format.
70 var originalObjectToJSON = Object.prototype.toJSON; 70 var originalObjectToJSON = Object.prototype.toJSON;
71 if (originalObjectToJSON) 71 if (originalObjectToJSON)
72 delete Object.prototype.toJSON; 72 delete Object.prototype.toJSON;
73 73
74 queueObject.queue.forEach(function(command) { 74 queueObject.queue.forEach(function(command) {
75 var stringifiedMessage = __gCrWeb.common.JSONStringify({ 75 var stringifiedMessage = __gCrWeb.common.JSONStringify({
76 "crwCommand": command, 76 "crwCommand": command,
77 "crwWindowId": __gCrWeb.windowId 77 "crwWindowId": __gCrWeb['windowId']
78 }); 78 });
79 // A web page can override |window.webkit| with any value. Deleting the 79 // A web page can override |window.webkit| with any value. Deleting the
80 // object ensures that original and working implementation of 80 // object ensures that original and working implementation of
81 // window.webkit is restored. 81 // window.webkit is restored.
82 var oldWebkit = window.webkit; 82 var oldWebkit = window.webkit;
83 delete window['webkit']; 83 delete window['webkit'];
84 window.webkit.messageHandlers[queueObject.scheme].postMessage( 84 window.webkit.messageHandlers[queueObject.scheme].postMessage(
85 stringifiedMessage); 85 stringifiedMessage);
86 window.webkit = oldWebkit; 86 window.webkit = oldWebkit;
87 }); 87 });
88 queueObject.reset(); 88 queueObject.reset();
89 89
90 if (originalObjectToJSON) { 90 if (originalObjectToJSON) {
91 // Restore Object.prototype.toJSON to prevent from breaking any 91 // Restore Object.prototype.toJSON to prevent from breaking any
92 // functionality on the page that depends on its custom implementation. 92 // functionality on the page that depends on its custom implementation.
93 Object.prototype.toJSON = originalObjectToJSON; 93 Object.prototype.toJSON = originalObjectToJSON;
94 } 94 }
95 }; 95 };
96 }()); 96 }());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698