Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: chrome/test/data/extensions/context_menus/test.js

Issue 2840038: Move context menu module out of experimental. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: kathy changes Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/data/extensions/context_menus/manifest.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // Checks that there is only one window and one tab, and calls back |callback| 5 // Checks that there is only one window and one tab, and calls back |callback|
6 // with its id (or -1 if there is more than 1 window or more than 1 tab). 6 // with its id (or -1 if there is more than 1 window or more than 1 tab).
7 function getCurrentSingleTabId(callback) { 7 function getCurrentSingleTabId(callback) {
8 chrome.windows.getAll({"populate":true}, function(windows) { 8 chrome.windows.getAll({"populate":true}, function(windows) {
9 if (windows.length != 1 || windows[0].tabs.length != 1) { 9 if (windows.length != 1 || windows[0].tabs.length != 1) {
10 callback(-1); 10 callback(-1);
11 } else { 11 } else {
12 callback(windows[0].tabs[0].id); 12 callback(windows[0].tabs[0].id);
13 } 13 }
14 }); 14 });
15 } 15 }
16 16
17 function navigateCurrentTab(url) { 17 function navigateCurrentTab(url) {
18 getCurrentSingleTabId(function(tabid) { 18 getCurrentSingleTabId(function(tabid) {
19 chrome.tabs.update(tabid, {"url": url}); 19 chrome.tabs.update(tabid, {"url": url});
20 }); 20 });
21 } 21 }
22 22
23 function onclick(info) { 23 function onclick(info) {
24 navigateCurrentTab(chrome.extension.getURL("test2.html")); 24 navigateCurrentTab(chrome.extension.getURL("test2.html"));
25 } 25 }
26 26
27 window.onload = function() { 27 window.onload = function() {
28 chrome.experimental.contextMenus.create({"title":"Extension Item 1", 28 chrome.contextMenus.create({"title":"Extension Item 1",
29 "onclick": onclick}, function() { 29 "onclick": onclick}, function() {
30 if (!chrome.extension.lastError) { 30 if (!chrome.extension.lastError) {
31 navigateCurrentTab(chrome.extension.getURL("test.html")); 31 navigateCurrentTab(chrome.extension.getURL("test.html"));
32 } 32 }
33 }); 33 });
34 }; 34 };
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/context_menus/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698