- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / examples / howto / sandbox / eventpage.js
1 // Copyright (c) 2012 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.
4
5 chrome.browserAction.onClicked.addListener(function() {
6   var iframe = document.getElementById('theFrame');
7   var message = {
8     command: 'render',
9     context: {thing: 'world'}
10   };
11   iframe.contentWindow.postMessage(message, '*');
12 });
13
14
15 window.addEventListener('message', function(event) {
16   if (event.data.html) {
17     var notification = webkitNotifications.createNotification(
18       'icon.png',
19       'Templated!',
20       'HTML Received for "' + event.data.name + '": `' + event.data.html + '`'
21     );
22     notification.show();
23   }
24 });