| 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 |
| 11 * APIs. Instead, it notifies the background page of the entries it creates, | 11 * APIs. Instead, it notifies the background page of the entries it creates, |
| 12 * and the background pages deletes them when the window is closed. | 12 * and the background pages deletes them when the window is closed. |
| 13 * | 13 * |
| 14 * @type {!Object} | 14 * @type {!Object} |
| 15 */ | 15 */ |
| 16 var contextMenuIds = {}; | 16 var contextMenuIds = {}; |
| 17 | 17 |
| 18 /** @param {chrome.app.runtime.LaunchData=} opt_launchData */ | 18 /** @param {Object=} opt_launchData */ |
| 19 function createWindow(opt_launchData) { | 19 function createWindow(opt_launchData) { |
| 20 // If there is already a window, give it focus. | 20 // If there is already a window, give it focus. |
| 21 if (mainWindow) { | 21 if (mainWindow) { |
| 22 mainWindow.focus(); | 22 mainWindow.focus(); |
| 23 return; | 23 return; |
| 24 } | 24 } |
| 25 | 25 |
| 26 var typed_screen = /** @type {{availWidth: number, availHeight: number}} */ | 26 var typed_screen = /** @type {{availWidth: number, availHeight: number}} */ |
| 27 (screen); | 27 (screen); |
| 28 | 28 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 contextMenuIds[id] = true; | 70 contextMenuIds[id] = true; |
| 71 break; | 71 break; |
| 72 case 'removeContextMenuId': | 72 case 'removeContextMenuId': |
| 73 delete contextMenuIds[id]; | 73 delete contextMenuIds[id]; |
| 74 break; | 74 break; |
| 75 } | 75 } |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 chrome.app.runtime.onLaunched.addListener(createWindow); | 78 chrome.app.runtime.onLaunched.addListener(createWindow); |
| 79 window.addEventListener('message', onWindowMessage, false); | 79 window.addEventListener('message', onWindowMessage, false); |
| OLD | NEW |