Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ios / web / web_state / js / resources / message_dynamic_wk.js
blob9b6fc46919f5333e1a5eb272051240df5fc8c45c
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
3 // found in the LICENSE file.
5 // Scripts for the message handler for use with WKWebView.
7 goog.provide('__crWeb.messageDynamic');
9 /**
10 * Namespace for this module.
12 __gCrWeb.message_dynamic = {};
14 /* Beginning of anonymous object. */
15 (function() {
16 /**
17 * Sends queued commands to the Objective-C side.
18 * @param {Object} queueObject Queue object containing messages to send.
20 __gCrWeb.message_dynamic.sendQueue = function(queueObject) {
21 queueObject.queue.forEach(function(command) {
22 var stringifiedMessage = __gCrWeb.common.JSONStringify({
23 "crwCommand": command,
24 "crwWindowId": __gCrWeb.windowId
25 });
26 window.webkit.messageHandlers[queueObject.scheme].postMessage(
27 stringifiedMessage);
28 });
29 queueObject.reset();
31 }());