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 var LOG = function(msg
) {
6 window
.console
.log(msg
);
13 touchDiv
= document
.createElement('div');
14 touchDiv
.innerText
= 'With touch';
15 document
.body
.appendChild(touchDiv
);
20 function onAppCommand(command
) {
21 LOG('onAppCommand, command = ' + command
);
23 case 'install-touch-handler':
24 touchDiv
.addEventListener('touchstart', handler
);
25 sendMessageToEmbedder('installed-touch-handler');
27 case 'uninstall-touch-handler':
28 touchDiv
.removeEventListener('touchstart', handler
);
29 sendMessageToEmbedder('uninstalled-touch-handler');
34 function sendMessageToEmbedder(message
) {
36 LOG('no embedder channel to send postMessage');
40 embedder
.postMessage(JSON
.stringify([message
]), '*');
43 window
.addEventListener('message', function(e
) {
45 var data
= JSON
.parse(e
.data
);
46 if (data
[0] == 'connect') {
47 sendMessageToEmbedder('connected');