| OLD | NEW |
| 1 /* Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 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 var ariaDescribedAt = ''; | 5 var ariaDescribedAt = ''; |
| 6 var longDesc = ''; | 6 var longDesc = ''; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * This is called when the extension is first loaded, so that it can be | 9 * This is called when the extension is first loaded, so that it can be |
| 10 * immediately used in all already-open tabs. It's not needed for any | 10 * immediately used in all already-open tabs. It's not needed for any |
| 11 * new tabs that open after that, the content script will be automatically | 11 * new tabs that open after that, the content script will be automatically |
| 12 * injected into any new tab. | 12 * injected into any new tab. |
| 13 */ | 13 */ |
| 14 chrome.windows.getAll({'populate': true}, function(windows) { | 14 chrome.windows.getAll({'populate': true}, function(windows) { |
| 15 for (var i = 0; i < windows.length; i++) { | 15 for (var i = 0; i < windows.length; i++) { |
| 16 var tabs = windows[i].tabs; | 16 var tabs = windows[i].tabs; |
| 17 for (var j = 0; j < tabs.length; j++) { | 17 for (var j = 0; j < tabs.length; j++) { |
| 18 chrome.tabs.executeScript( | 18 chrome.tabs.executeScript( |
| 19 tabs[j].id, | 19 tabs[j].id, |
| 20 {file: 'lastRightClick.js'}); | 20 {file: 'lastRightClick.js'}); |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 }); | 23 }); |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Add context menu item when the extension is installed. | 26 * Add context menu item when the extension is installed. |
| 27 */ | 27 */ |
| 28 chrome.contextMenus.create({ | 28 chrome.contextMenus.create({ |
| 29 "title": "More information...", | 29 "title": chrome.i18n.getMessage('openLongDescription'), |
| 30 "contexts": ["all"], | 30 "contexts": ["all"], |
| 31 "id": "moreInfo", | 31 "id": "moreInfo", |
| 32 "onclick": contextMenuClicked, | 32 "onclick": contextMenuClicked, |
| 33 "enabled": false | 33 "enabled": false |
| 34 }); | 34 }); |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Add listener for messages from content script. | 37 * Add listener for messages from content script. |
| 38 * Enable/disable the context menu item. | 38 * Enable/disable the context menu item. |
| 39 */ | 39 */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 * @param info | 57 * @param info |
| 58 * @param tab | 58 * @param tab |
| 59 */ | 59 */ |
| 60 function contextMenuClicked(info, tab) { | 60 function contextMenuClicked(info, tab) { |
| 61 if (ariaDescribedAt !== '') { | 61 if (ariaDescribedAt !== '') { |
| 62 chrome.tabs.create({url: ariaDescribedAt}); | 62 chrome.tabs.create({url: ariaDescribedAt}); |
| 63 } else if (longDesc !== '') { | 63 } else if (longDesc !== '') { |
| 64 chrome.tabs.create({url: longDesc}); | 64 chrome.tabs.create({url: longDesc}); |
| 65 } | 65 } |
| 66 } | 66 } |
| OLD | NEW |