OLD | NEW |
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 /** @type {chrome.app.window.AppWindow} */ | 5 /** @type {chrome.app.window.AppWindow} */ |
6 var mainWindow = null; | 6 var mainWindow = null; |
7 | 7 |
8 /** | 8 /** |
9 * The main window cannot delete its context menu entries on close because it | 9 * The main window cannot delete its context menu entries on close because it |
10 * is being torn down at that point and doesn't have access to the necessary | 10 * is being torn down at that point and doesn't have access to the necessary |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 /** @param {chrome.app.window.AppWindow} appWindow */ | 49 /** @param {chrome.app.window.AppWindow} appWindow */ |
50 function onCreate(appWindow) { | 50 function onCreate(appWindow) { |
51 // Set the global window. | 51 // Set the global window. |
52 mainWindow = appWindow; | 52 mainWindow = appWindow; |
53 | 53 |
54 // Clean up the windows sub-menu when the application quits. | 54 // Clean up the windows sub-menu when the application quits. |
55 appWindow.onClosed.addListener(onClosed); | 55 appWindow.onClosed.addListener(onClosed); |
56 }; | 56 }; |
57 | 57 |
58 // TODO(garykac) Add code to switch between dev and prod shared modules. | 58 chrome.app.window.create('main.html', windowAttributes, onCreate); |
59 chrome.app.window.create( | |
60 '_modules/koejkfhmphamcgafjmkellhnekdkopod/main.html', | |
61 windowAttributes, onCreate); | |
62 }; | 59 }; |
63 | 60 |
64 /** @param {Event} event */ | 61 /** @param {Event} event */ |
65 function onWindowMessage(event) { | 62 function onWindowMessage(event) { |
66 var method = /** @type {string} */ (event.data['method']); | 63 var method = /** @type {string} */ (event.data['method']); |
67 var id = /** @type {string} */ (event.data['id']); | 64 var id = /** @type {string} */ (event.data['id']); |
68 switch (method) { | 65 switch (method) { |
69 case 'addContextMenuId': | 66 case 'addContextMenuId': |
70 contextMenuIds[id] = true; | 67 contextMenuIds[id] = true; |
71 break; | 68 break; |
72 case 'removeContextMenuId': | 69 case 'removeContextMenuId': |
73 delete contextMenuIds[id]; | 70 delete contextMenuIds[id]; |
74 break; | 71 break; |
75 } | 72 } |
76 }; | 73 }; |
77 | 74 |
78 chrome.app.runtime.onLaunched.addListener(createWindow); | 75 chrome.app.runtime.onLaunched.addListener(createWindow); |
79 window.addEventListener('message', onWindowMessage, false); | 76 window.addEventListener('message', onWindowMessage, false); |
OLD | NEW |