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

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

Issue 2576833002: Make some updates to extension iconography. (Closed)
Patch Set: devlin review Created 4 years 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 // TODO(rdevlin.cronin): This file can be improved, and was copied from public
5 // docs. Clean both up.
6
7 // A generic onclick callback function.
8 function genericOnClick(info, tab) {
9 console.log("item " + info.menuItemId + " was clicked");
10 console.log("info: " + JSON.stringify(info));
11 console.log("tab: " + JSON.stringify(tab));
12 }
13
14 // Create one test item for each context type.
15 var contexts = ["page","selection","link","editable","image","video",
16 "audio"];
17 for (var i = 0; i < contexts.length; i++) {
18 var context = contexts[i];
19 var title = "Test '" + context + "' menu item";
20 var id = chrome.contextMenus.create({"title": title, "contexts":[context],
21 "onclick": genericOnClick});
22 console.log("'" + context + "' item:" + id);
23 }
24
25
26 // Create a parent item and two children.
27 var parent = chrome.contextMenus.create({"title": "Test parent item"});
28 var child1 = chrome.contextMenus.create(
29 {"title": "Child 1", "parentId": parent, "onclick": genericOnClick});
30 var child2 = chrome.contextMenus.create(
31 {"title": "Child 2", "parentId": parent, "onclick": genericOnClick});
32 console.log("parent:" + parent + " child1:" + child1 + " child2:" + child2);
33
34
35 // Create some radio items.
36 function radioOnClick(info, tab) {
37 console.log("radio item " + info.menuItemId +
38 " was clicked (previous checked state was " +
39 info.wasChecked + ")");
40 }
41 var radio1 = chrome.contextMenus.create({"title": "Radio 1", "type": "radio",
42 "onclick":radioOnClick});
43 var radio2 = chrome.contextMenus.create({"title": "Radio 2", "type": "radio",
44 "onclick":radioOnClick});
45 console.log("radio1:" + radio1 + " radio2:" + radio2);
46
47
48 // Create some checkbox items.
49 function checkboxOnClick(info, tab) {
50 console.log(JSON.stringify(info));
51 console.log("checkbox item " + info.menuItemId +
52 " was clicked, state is now: " + info.checked +
53 "(previous state was " + info.wasChecked + ")");
54
55 }
56 var checkbox1 = chrome.contextMenus.create(
57 {"title": "Checkbox1", "type": "checkbox", "onclick":checkboxOnClick});
58 var checkbox2 = chrome.contextMenus.create(
59 {"title": "Checkbox2", "type": "checkbox", "onclick":checkboxOnClick});
60 console.log("checkbox1:" + checkbox1 + " checkbox2:" + checkbox2);
61
62
63 // Intentionally create an invalid item, to show off error checking in the
64 // create callback.
65 console.log("About to try creating an invalid item - an error about " +
66 "item 999 should show up");
67 chrome.contextMenus.create({"title": "Oops", "parentId":999}, function() {
68 if (chrome.extension.lastError) {
69 console.log("Got expected error: " + chrome.extension.lastError.message);
70 }
71 });
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/context_menus/icons/manifest.json ('k') | extensions/browser/api/management/management_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698