Commit cd4e8086 authored by finnur@chromium.org's avatar finnur@chromium.org

Renaming the 'keybinding' permission to 'commands'.

BUG=135562
TEST=Covered by automated tests.
Review URL: https://chromiumcodereview.appspot.com/10833071

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149147 0039d316-1c4b-4281-b951-d872f2087c98
parent a285e429
......@@ -37,7 +37,7 @@ namespace extensions {
// static
void CommandService::RegisterUserPrefs(
PrefService* user_prefs) {
user_prefs->RegisterDictionaryPref(prefs::kExtensionKeybindings,
user_prefs->RegisterDictionaryPref(prefs::kExtensionCommands,
PrefService::SYNCABLE_PREF);
}
......@@ -108,7 +108,7 @@ bool CommandService::AddKeybindingPref(
return false;
DictionaryPrefUpdate updater(profile_->GetPrefs(),
prefs::kExtensionKeybindings);
prefs::kExtensionCommands);
DictionaryValue* bindings = updater.Get();
std::string key = GetPlatformKeybindingKeyForAccelerator(accelerator);
......@@ -167,7 +167,7 @@ void CommandService::UpdateKeybindingPrefs(const std::string& extension_id,
ui::Accelerator CommandService::FindShortcutForCommand(
const std::string& extension_id, const std::string& command) {
const DictionaryValue* bindings =
profile_->GetPrefs()->GetDictionary(prefs::kExtensionKeybindings);
profile_->GetPrefs()->GetDictionary(prefs::kExtensionCommands);
for (DictionaryValue::key_iterator it = bindings->begin_keys();
it != bindings->end_keys(); ++it) {
const DictionaryValue* item = NULL;
......@@ -224,7 +224,7 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) {
void CommandService::RemoveKeybindingPrefs(const std::string& extension_id,
const std::string& command_name) {
DictionaryPrefUpdate updater(profile_->GetPrefs(),
prefs::kExtensionKeybindings);
prefs::kExtensionCommands);
DictionaryValue* bindings = updater.Get();
typedef std::vector<std::string> KeysToRemove;
......
......@@ -569,7 +569,7 @@ void BrowserEventRouter::CommandExecuted(Profile* profile,
DispatchEventToExtension(profile,
extension_id,
"experimental.keybinding.onCommand",
"experimental.commands.onCommand",
json_args);
}
......
......@@ -75,6 +75,10 @@
"extension", "packaged_app", "hosted_app", "platform_app"
]
},
"commands": {
"channel": "stable",
"extension_types": ["extension", "packaged_app"]
},
"contentSettings": {
"channel": "stable",
"extension_types": ["extension", "packaged_app"]
......@@ -166,10 +170,6 @@
"okddffdblfhhnmhodogpojmfkjmhinfp" // HTerm dev
]
},
"keybinding": {
"channel": "stable",
"extension_types": ["extension", "packaged_app"]
},
"managedModePrivate": {
"channel": "dev",
"extension_types": ["extension", "packaged_app"],
......
......@@ -4,7 +4,7 @@
[
{
"namespace": "experimental.keybinding",
"namespace": "experimental.commands",
"events": [
{
"name": "onCommand",
......
......@@ -373,12 +373,12 @@ void ExtensionAPI::InitDefaultConfiguration() {
IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP));
RegisterSchema("experimental.bookmarkManager", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_BOOKMARKMANAGER));
RegisterSchema("experimental.commands", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_COMMANDS));
RegisterSchema("experimental.infobars", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_INFOBARS));
RegisterSchema("experimental.input.virtualKeyboard", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_VIRTUALKEYBOARD));
RegisterSchema("experimental.keybinding", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_KEYBINDING));
RegisterSchema("experimental.offscreenTabs", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_OFFSCREENTABS));
RegisterSchema("experimental.processes", ReadFromResource(
......
......@@ -40,11 +40,11 @@ var MODULE_SCHEMAS = [
'../../api/experimental_app.json',
'../../api/experimental_bluetooth.json', // autogenerated
'../../api/experimental_bookmark_manager.json',
'../../api/experimental_commands.json',
'../../api/experimental_discovery.json', // autogenerated
'../../api/experimental_identity.json', // autogenerated
'../../api/experimental_infobars.json',
'../../api/experimental_input_virtual_keyboard.json',
'../../api/experimental_keybinding.json',
'../../api/experimental_media_galleries.json', // autogenerated
'../../api/experimental_offscreen_tabs.json',
'../../api/experimental_processes.json',
......
<!-- BEGIN AUTHORED CONTENT -->
<p>
The keybinding API allows you to add keyboard shortcuts that trigger actions in
The commands API allows you to add keyboard shortcuts that trigger actions in
your extension. An action can be opening the browser action or page action popup
or sending a command to the extension.
</p>
<h2 id="manifest">Manifest</h2>
<p>
In addition to the "experimental" permission you must declare the "keybinding"
In addition to the "experimental" permission you must declare the "commands"
permission in your extension's manifest to use this API and set manifest_version
to (at least) 2.
</p>
......@@ -17,13 +17,13 @@ to (at least) 2.
...
<b> "permissions": [
"experimental",
"keybinding",
"commands",
]</b>,
...
}</pre>
<h2 id="usage">Usage</h2>
<p>The keybinding API allows you to define specific commands, and bind them to a
<p>The commands API allows you to define specific commands, and bind them to a
default key combination. Each command your extension accepts must be listed in
the manifest as an attribute of the 'commands' manifest key. Note: Combinations
that involve Ctrl+Alt are not permitted in order to avoid conflicts with the
......@@ -64,7 +64,7 @@ defined in the manifest (except for '_execute_browser_action' and
'_execute_page_action') via onCommand.addListener. For example:</p>
<pre>
chrome.experimental.keybinding.onCommand.addListener(function(command) {
chrome.experimental.commands.onCommand.addListener(function(command) {
console.log('Command:', command);
});
</pre>
......
......@@ -80,6 +80,7 @@ void APIPermission::RegisterAllPermissions(
PermissionMessage::kBookmarks },
{ kBrowserTag, "browserTag", kFlagCannotBeOptional },
{ kBrowsingData, "browsingData" },
{ kCommands, "commands" },
{ kContentSettings, "contentSettings", kFlagNone,
IDS_EXTENSION_PROMPT_WARNING_CONTENT_SETTINGS,
PermissionMessage::kContentSettings },
......@@ -90,7 +91,6 @@ void APIPermission::RegisterAllPermissions(
{ kHistory, "history", kFlagNone,
IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY,
PermissionMessage::kBrowsingHistory },
{ kKeybinding, "keybinding" },
{ kIdle, "idle" },
{ kInput, "input", kFlagNone,
IDS_EXTENSION_PROMPT_WARNING_INPUT,
......
......@@ -36,6 +36,7 @@ class APIPermission {
kChromeosInfoPrivate,
kClipboardRead,
kClipboardWrite,
kCommands,
kContentSettings,
kContextMenus,
kCookie,
......@@ -57,7 +58,6 @@ class APIPermission {
kIdle,
kInput,
kInputMethodPrivate,
kKeybinding,
kManagedModePrivate,
kManagement,
kMediaGalleries,
......
......@@ -575,7 +575,7 @@ TEST(PermissionsTest, PermissionMessages) {
// This permission requires explicit user action (shortcut) so we don't
// prompt for it.
skip.insert(APIPermission::kKeybinding);
skip.insert(APIPermission::kCommands);
// These permissions require explicit user action (configuration dialog)
// so we don't prompt for them at install time.
......
......@@ -26,9 +26,9 @@
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY" file="extensions\api\experimental_accessibility.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP" file="extensions\api\experimental_app.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_BOOKMARKMANAGER" file="extensions\api\experimental_bookmark_manager.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_COMMANDS" file="extensions\api\experimental_commands.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_INFOBARS" file="extensions\api\experimental_infobars.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_VIRTUALKEYBOARD" file="extensions\api\experimental_input_virtual_keyboard.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_KEYBINDING" file="extensions\api\experimental_keybinding.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_OFFSCREENTABS" file="extensions\api\experimental_offscreen_tabs.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_PROCESSES" file="extensions\api\experimental_processes.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_RECORD" file="extensions\api\experimental_record.json" type="BINDATA" />
......
......@@ -807,9 +807,9 @@ const char kExtensionsUIDeveloperMode[] = "extensions.ui.developer_mode";
// actions toolbar.
const char kExtensionToolbarSize[] = "extensions.toolbarsize";
// Dictionary pref that tracks which keybinding belongs to which
// Dictionary pref that tracks which command belongs to which
// extension + named command pair.
const char kExtensionKeybindings[] = "extensions.keybindings";
const char kExtensionCommands[] = "extensions.commands";
// Pref containing the directory for internal plugins as written to the plugins
// list (below).
......
......@@ -297,7 +297,7 @@ extern const char kCurrentThemeTints[];
extern const char kCurrentThemeDisplayProperties[];
extern const char kExtensionsUIDeveloperMode[];
extern const char kExtensionToolbarSize[];
extern const char kExtensionKeybindings[];
extern const char kExtensionCommands[];
extern const char kPluginsLastInternalDirectory[];
extern const char kPluginsPluginsList[];
extern const char kPluginsDisabledPlugins[];
......
......@@ -8,7 +8,7 @@ chrome.browserAction.onClicked.addListener(function(windowId) {
});
// Called when the user activates the command.
chrome.experimental.keybinding.onCommand.addListener(function(command) {
chrome.experimental.commands.onCommand.addListener(function(command) {
chrome.tabs.executeScript(null, { code: "document.body.bgColor='blue'" });
});
......
......@@ -6,7 +6,7 @@
"scripts": ["background.js"]
},
"permissions": [
"tabs", "http://*/*", "experimental", "keybinding"
"tabs", "http://*/*", "experimental", "commands"
],
"browser_action": {
"default_title": "Make this page red",
......
......@@ -8,7 +8,7 @@ chrome.browserAction.onClicked.addListener(function(windowId) {
});
// Called when the user activates the command.
chrome.experimental.keybinding.onCommand.addListener(function(command) {
chrome.experimental.commands.onCommand.addListener(function(command) {
chrome.tabs.executeScript(null, { code: "document.body.bgColor='yellow'" });
});
......
......@@ -6,7 +6,7 @@
"scripts": ["background.js"]
},
"permissions": [
"tabs", "http://*/*", "experimental", "keybinding"
"tabs", "http://*/*", "experimental", "commands"
],
"browser_action": {
"default_title": "Make this page green"
......
......@@ -6,7 +6,7 @@
"scripts": ["background.js"]
},
"permissions": [
"tabs", "http://*/*", "experimental", "keybinding"
"tabs", "http://*/*", "experimental", "commands"
],
"page_action": {
"default_title": "Make this page red",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment