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

Side by Side Diff: chrome/common/extensions/docs/server2/templates/intros/experimental_commands.html

Issue 10894049: Make links to samples and re-enable sample list for api references. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: patch'd Created 8 years, 3 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
OLDNEW
(Empty)
1 <p>
2 The commands API allows you to add keyboard shortcuts that trigger actions in
3 your extension. An action can be opening the browser action or page action popup
4 or sending a command to the extension.
5 </p>
6
7 <h2 id="manifest">Manifest</h2>
8 <p>
9 In addition to the "experimental" permission you must declare the "commands"
10 permission in your extension's manifest to use this API and set manifest_version
11 to (at least) 2.
12 </p>
13
14 <pre>{
15 "name": "My extension",
16 ...
17 <b> "permissions": [
18 "experimental",
19 "commands",
20 ]</b>,
21 ...
22 }</pre>
23
24 <h2 id="usage">Usage</h2>
25 <p>The commands API allows you to define specific commands, and bind them to a
26 default key combination. Each command your extension accepts must be listed in
27 the manifest as an attribute of the 'commands' manifest key. Note: Combinations
28 that involve Ctrl+Alt are not permitted in order to avoid conflicts with the
29 AltGr key.</p>
30
31 <pre>{
32 "name": "My extension",
33 ...
34 <b> "commands": {
35 "toggle-feature-foo": {
36 "suggested_key": {
37 "default": "Ctrl+Shift+Y",
38 "mac": "Command+Shift+Y"
39 },
40 "description": "Toggle feature foo"
41 },
42 "_execute_browser_action": {
43 "suggested_key": {
44 "windows": "Ctrl+Shift+Y",
45 "mac": "Command+Shift+Y",
46 "chromeos": "Ctrl+Shift+U",
47 "linux": "Ctrl+Shift+J"
48 }
49 },
50 "_execute_page_action": {
51 "suggested_key": {
52 "default": "Ctrl+E"
53 "windows": "Alt+P",
54 "mac": "Option+P",
55 }
56 }
57 }</b>,
58 ...
59 }</pre>
60
61 <p>In your background page, you can bind a handler to each of the commands
62 defined in the manifest (except for '_execute_browser_action' and
63 '_execute_page_action') via onCommand.addListener. For example:</p>
64
65 <pre>
66 chrome.experimental.commands.onCommand.addListener(function(command) {
67 console.log('Command:', command);
68 });
69 </pre>
70
71 <p>The '_execute_browser_action' and '_execute_page_action' commands are
72 reserved for the action of opening your extension's popups. They won't normally
73 generate events that you can handle. If you need to take action based on your
74 popup opening, consider listening for an 'onDomReady' event inside your popup's
75 code.
76 </p>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698