summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/extension_context_menu_api.cc45
-rw-r--r--chrome/browser/extensions/extension_context_menu_api.h8
-rw-r--r--chrome/browser/extensions/extension_menu_manager.cc6
-rw-r--r--chrome/browser/extensions/extension_menu_manager.h14
-rw-r--r--chrome/browser/extensions/extension_menu_manager_unittest.cc7
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc16
-rw-r--r--chrome/common/extensions/api/extension_api.json25
-rw-r--r--chrome/common/extensions/docs/experimental.contextMenus.html (renamed from chrome/common/extensions/docs/experimental.contextMenu.html)154
-rw-r--r--chrome/common/extensions/docs/experimental.html2
-rw-r--r--chrome/common/extensions/docs/static/experimental.contextMenus.html (renamed from chrome/common/extensions/docs/static/experimental.contextMenu.html)0
-rw-r--r--chrome/renderer/resources/extension_process_bindings.js12
-rw-r--r--chrome/renderer/resources/renderer_extension_bindings.js2
-rw-r--r--chrome/test/data/extensions/api_test/context_menus/manifest.json6
-rw-r--r--chrome/test/data/extensions/api_test/context_menus/test.js39
-rw-r--r--chrome/test/data/extensions/context_menus/test.js2
15 files changed, 80 insertions, 258 deletions
diff --git a/chrome/browser/extensions/extension_context_menu_api.cc b/chrome/browser/extensions/extension_context_menu_api.cc
index 1c63dd1..f5ecca4 100644
--- a/chrome/browser/extensions/extension_context_menu_api.cc
+++ b/chrome/browser/extensions/extension_context_menu_api.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/profile.h"
-const wchar_t kEnabledContextsKey[] = L"enabledContexts";
const wchar_t kCheckedKey[] = L"checked";
const wchar_t kContextsKey[] = L"contexts";
const wchar_t kParentIdKey[] = L"parentId";
@@ -18,9 +17,9 @@ const wchar_t kTypeKey[] = L"type";
const char kTitleNeededError[] =
"All menu items except for separators must have a title";
const char kCheckedError[] =
- "Only items with type RADIO or CHECKBOX can be checked";
+ "Only items with type \"radio\" or \"checkbox\" can be checked";
const char kParentsMustBeNormalError[] =
- "Parent items must have type NORMAL";
+ "Parent items must have type \"normal\"";
bool ExtensionContextMenuFunction::ParseContexts(
const DictionaryValue& properties,
@@ -37,21 +36,21 @@ bool ExtensionContextMenuFunction::ParseContexts(
if (!list->GetString(i, &value))
return false;
- if (value == "ALL") {
+ if (value == "all") {
tmp_result.Add(ExtensionMenuItem::ALL);
- } else if (value == "PAGE") {
+ } else if (value == "page") {
tmp_result.Add(ExtensionMenuItem::PAGE);
- } else if (value == "SELECTION") {
+ } else if (value == "selection") {
tmp_result.Add(ExtensionMenuItem::SELECTION);
- } else if (value == "LINK") {
+ } else if (value == "link") {
tmp_result.Add(ExtensionMenuItem::LINK);
- } else if (value == "EDITABLE") {
+ } else if (value == "editable") {
tmp_result.Add(ExtensionMenuItem::EDITABLE);
- } else if (value == "IMAGE") {
+ } else if (value == "image") {
tmp_result.Add(ExtensionMenuItem::IMAGE);
- } else if (value == "VIDEO") {
+ } else if (value == "video") {
tmp_result.Add(ExtensionMenuItem::VIDEO);
- } else if (value == "AUDIO") {
+ } else if (value == "audio") {
tmp_result.Add(ExtensionMenuItem::AUDIO);
} else {
error_ = "Invalid value for " + WideToASCII(key);
@@ -76,13 +75,13 @@ bool ExtensionContextMenuFunction::ParseType(
if (!properties.GetString(kTypeKey, &type_string))
return false;
- if (type_string == "NORMAL") {
+ if (type_string == "normal") {
*result = ExtensionMenuItem::NORMAL;
- } else if (type_string == "CHECKBOX") {
+ } else if (type_string == "checkbox") {
*result = ExtensionMenuItem::CHECKBOX;
- } else if (type_string == "RADIO") {
+ } else if (type_string == "radio") {
*result = ExtensionMenuItem::RADIO;
- } else if (type_string == "SEPARATOR") {
+ } else if (type_string == "separator") {
*result = ExtensionMenuItem::SEPARATOR;
} else {
error_ = "Invalid type string '" + type_string + "'";
@@ -104,7 +103,7 @@ bool ExtensionContextMenuFunction::ParseChecked(
return false;
if (checked && type != ExtensionMenuItem::CHECKBOX &&
type != ExtensionMenuItem::RADIO) {
- error_ = "Only CHECKBOX and RADIO type items can be checked";
+ error_ = "Only checkbox and radio type items can be checked";
return false;
}
return true;
@@ -151,10 +150,6 @@ bool CreateContextMenuFunction::RunImpl() {
if (!ParseContexts(*properties, kContextsKey, &contexts))
return false;
- ExtensionMenuItem::ContextList enabled_contexts = contexts;
- if (!ParseContexts(*properties, kEnabledContextsKey, &enabled_contexts))
- return false;
-
ExtensionMenuItem::Type type;
if (!ParseType(*properties, ExtensionMenuItem::NORMAL, &type))
return false;
@@ -169,8 +164,7 @@ bool CreateContextMenuFunction::RunImpl() {
return false;
scoped_ptr<ExtensionMenuItem> item(
- new ExtensionMenuItem(extension_id(), title, checked, type, contexts,
- enabled_contexts));
+ new ExtensionMenuItem(extension_id(), title, checked, type, contexts));
int id = 0;
if (properties->HasKey(kParentIdKey)) {
@@ -253,13 +247,6 @@ bool UpdateContextMenuFunction::RunImpl() {
if (contexts != item->contexts())
item->set_contexts(contexts);
- // Enabled contexts.
- ExtensionMenuItem::ContextList enabled_contexts(item->contexts());
- if (!ParseContexts(*properties, kEnabledContextsKey, &enabled_contexts))
- return false;
- if (enabled_contexts != item->enabled_contexts())
- item->set_enabled_contexts(enabled_contexts);
-
// Parent id.
ExtensionMenuItem* parent = NULL;
if (!GetParent(*properties, *menu_manager, &parent))
diff --git a/chrome/browser/extensions/extension_context_menu_api.h b/chrome/browser/extensions/extension_context_menu_api.h
index c9c3380..3362aae 100644
--- a/chrome/browser/extensions/extension_context_menu_api.h
+++ b/chrome/browser/extensions/extension_context_menu_api.h
@@ -46,25 +46,25 @@ class ExtensionContextMenuFunction : public SyncExtensionFunction {
class CreateContextMenuFunction : public ExtensionContextMenuFunction {
~CreateContextMenuFunction() {}
virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.contextMenu.create")
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.contextMenus.create")
};
class UpdateContextMenuFunction : public ExtensionContextMenuFunction {
~UpdateContextMenuFunction() {}
virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.contextMenu.update")
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.contextMenus.update")
};
class RemoveContextMenuFunction : public ExtensionContextMenuFunction {
~RemoveContextMenuFunction() {}
virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.contextMenu.remove")
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.contextMenus.remove")
};
class RemoveAllContextMenusFunction : public ExtensionContextMenuFunction {
~RemoveAllContextMenusFunction() {}
virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.contextMenu.removeAll")
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.contextMenus.removeAll")
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__
diff --git a/chrome/browser/extensions/extension_menu_manager.cc b/chrome/browser/extensions/extension_menu_manager.cc
index 42e3842..fc02637 100644
--- a/chrome/browser/extensions/extension_menu_manager.cc
+++ b/chrome/browser/extensions/extension_menu_manager.cc
@@ -27,15 +27,13 @@
ExtensionMenuItem::ExtensionMenuItem(const std::string& extension_id,
std::string title,
bool checked, Type type,
- const ContextList& contexts,
- const ContextList& enabled_contexts)
+ const ContextList& contexts)
: extension_id_(extension_id),
title_(title),
id_(0),
type_(type),
checked_(checked),
contexts_(contexts),
- enabled_contexts_(enabled_contexts),
parent_id_(0) {}
ExtensionMenuItem::~ExtensionMenuItem() {
@@ -439,7 +437,7 @@ void ExtensionMenuManager::ExecuteCommand(Profile* profile,
std::string json_args;
base::JSONWriter::Write(&args, false, &json_args);
- std::string event_name = "contextMenu/" + item->extension_id();
+ std::string event_name = "contextMenus/" + item->extension_id();
service->DispatchEventToRenderers(event_name, json_args,
profile->IsOffTheRecord(), GURL());
}
diff --git a/chrome/browser/extensions/extension_menu_manager.h b/chrome/browser/extensions/extension_menu_manager.h
index c3f82c5..98752f8 100644
--- a/chrome/browser/extensions/extension_menu_manager.h
+++ b/chrome/browser/extensions/extension_menu_manager.h
@@ -32,8 +32,7 @@ class ExtensionMenuItem {
// A list of ExtensionMenuItem's.
typedef std::vector<ExtensionMenuItem*> List;
- // For context menus, these are the contexts where an item can appear and
- // potentially be enabled.
+ // For context menus, these are the contexts where an item can appear.
enum Context {
ALL = 1,
PAGE = 2,
@@ -53,7 +52,7 @@ class ExtensionMenuItem {
SEPARATOR
};
- // A list of Contexts for an item (where it should be shown/enabled).
+ // A list of Contexts for an item.
class ContextList {
public:
ContextList() : value_(0) {}
@@ -85,8 +84,7 @@ class ExtensionMenuItem {
};
ExtensionMenuItem(const std::string& extension_id, std::string title,
- bool checked, Type type, const ContextList& contexts,
- const ContextList& enabled_contexts);
+ bool checked, Type type, const ContextList& contexts);
virtual ~ExtensionMenuItem();
// Simple accessor methods.
@@ -97,14 +95,12 @@ class ExtensionMenuItem {
int parent_id() const { return parent_id_; }
int child_count() const { return children_.size(); }
ContextList contexts() const { return contexts_; }
- ContextList enabled_contexts() const { return enabled_contexts_; }
Type type() const { return type_; }
bool checked() const { return checked_; }
// Simple mutator methods.
void set_title(std::string new_title) { title_ = new_title; }
void set_contexts(ContextList contexts) { contexts_ = contexts; }
- void set_enabled_contexts(ContextList contexts) { contexts_ = contexts; }
void set_type(Type type) { type_ = type; }
// Returns the title with any instances of %s replaced by |selection|.
@@ -155,10 +151,6 @@ class ExtensionMenuItem {
// In what contexts should the item be shown?
ContextList contexts_;
- // In what contexts should the item be enabled (i.e. not greyed out). This
- // should be a subset of contexts_.
- ContextList enabled_contexts_;
-
// If this item is a child of another item, the unique id of its parent. If
// this is a top-level item with no parent, this will be 0.
int parent_id_;
diff --git a/chrome/browser/extensions/extension_menu_manager_unittest.cc b/chrome/browser/extensions/extension_menu_manager_unittest.cc
index a03702a..f0960cb 100644
--- a/chrome/browser/extensions/extension_menu_manager_unittest.cc
+++ b/chrome/browser/extensions/extension_menu_manager_unittest.cc
@@ -36,9 +36,8 @@ class ExtensionMenuManagerTest : public testing::Test {
static ExtensionMenuItem* CreateTestItem(Extension* extension) {
ExtensionMenuItem::Type type = ExtensionMenuItem::NORMAL;
ExtensionMenuItem::ContextList contexts(ExtensionMenuItem::ALL);
- ExtensionMenuItem::ContextList enabled_contexts = contexts;
- return new ExtensionMenuItem(extension->id(), "test", false, type, contexts,
- enabled_contexts);
+ return new ExtensionMenuItem(extension->id(), "test", false, type,
+ contexts);
}
// Creates and returns a test Extension. The caller does *not* own the return
@@ -363,7 +362,7 @@ TEST_F(ExtensionMenuManagerTest, ExecuteCommand) {
// Use the magic of googlemock to save a parameter to our mock's
// DispatchEventToRenderers method into event_args.
std::string event_args;
- std::string expected_event_name = "contextMenu/" + item->extension_id();
+ std::string expected_event_name = "contextMenus/" + item->extension_id();
EXPECT_CALL(*mock_message_service.get(),
DispatchEventToRenderers(expected_event_name, _,
profile.IsOffTheRecord(),
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 055bcca..06b0b46 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -11,6 +11,7 @@
#include "app/l10n_util.h"
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/autocomplete/autocomplete_classifier.h"
@@ -258,7 +259,7 @@ void RenderViewContextMenu::SetExtensionIcon(const std::string& extension_id) {
ExtensionMenuManager* menu_manager = service->menu_manager();
int index = menu_model_.GetItemCount() - 1;
- DCHECK(index >= 0);
+ DCHECK_GE(index, 0);
const SkBitmap& icon = menu_manager->GetIconForExtension(extension_id);
DCHECK(icon.width() == kFavIconSize);
@@ -698,18 +699,7 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
// Extension items.
if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
- std::map<int, int>::const_iterator i = extension_item_map_.find(id);
-
- // Unknown item.
- if (i == extension_item_map_.end())
- return false;
-
- // Auto-inserted top-level extension parent.
- if (i->second == kExtensionTopLevelItem)
- return true;
-
- return ExtensionContextMatch(params_,
- GetExtensionMenuItem(id)->enabled_contexts());
+ return ContainsKey(extension_item_map_, id);
}
switch (id) {
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 9fe34cf..438162b 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -2501,7 +2501,7 @@
"events": []
},
{
- "namespace": "experimental.contextMenu",
+ "namespace": "experimental.contextMenus",
"types": [],
"functions": [
{
@@ -2516,36 +2516,29 @@
"type": {
"type": "string",
"optional": true,
- "description": "The type of menu item - one of 'NORMAL', 'CHECKBOX', 'RADIO', or 'SEPARATOR'. Defaults to 'NORMAL' if not specified."
+ "description": "The type of menu item - one of 'normal', 'checkbox', 'radio', or 'separator'. Defaults to 'normal' if not specified."
},
"title": {
"type": "string",
"optional": "true",
- "description": "This must be specified unless type is 'SEPARATOR'."
+ "description": "This must be specified unless type is 'separator'."
},
"checked": {
"type": "boolean",
"optional": true,
- "description": " For items of type CHECKBOX or RADIO, should this be selected (RADIO) or checked (CHECKBOX)? Only one RADIO item can be selected at a time in a given group of RADIO items, with the last one to have checked == true winning."
+ "description": " For items of type checkbox or radio, should this be selected (radio) or checked (checkbox)? Only one radio item can be selected at a time in a given group of radio items, with the last one to have checked == true winning."
},
"contexts": {
"type": "array",
"items": {"type": "string"},
"minItems": 1,
"optional": true,
- "description": "List of contexts this menu item will appear in. Legal values are: 'ALL', 'PAGE', 'SELECTION', 'LINK', 'EDITABLE', 'IMAGE', 'VIDEO', and 'AUDIO'. Defaults to ['PAGE']."
- },
- "enabledContexts": {
- "type": "array",
- "optional": true,
- "items": {"type": "string"},
- "minItems": 1,
- "description": "By default the values you pass for the contexts parameter make an item both shown and selectable in those contexts. If you want to limit the contexts where an item is selectable (i.e. not greyed out), you put the ones you want selectable in enabledContexts and any not listed will be shown but disabled. So, for example, if you wanted an item to appear for links and images but only be enabled for links, you would set 'contexts' : ['LINK', 'IMAGE'] and 'enabledContexts' : ['LINK']."
+ "description": "List of contexts this menu item will appear in. Legal values are: 'all', 'page', 'selection', 'link', 'editable', 'image', 'video', and 'audio'. Defaults to ['page']."
},
"onclick": {
"type": "function",
"optional": true,
- "description": "Function to be called back when your menu item or one of its children is clicked."
+ "description": "Function to be called back when your menu item is clicked."
},
"parentId": {
"type": "integer",
@@ -2601,12 +2594,6 @@
"minItems": 1,
"optional": true
},
- "enabledContexts": {
- "type": "array",
- "optional": true,
- "items": {"type": "string"},
- "minItems": 1
- },
"onclick": {
"type": "function",
"optional": true
diff --git a/chrome/common/extensions/docs/experimental.contextMenu.html b/chrome/common/extensions/docs/experimental.contextMenus.html
index 8d8ac24..1a16d4a 100644
--- a/chrome/common/extensions/docs/experimental.contextMenu.html
+++ b/chrome/common/extensions/docs/experimental.contextMenus.html
@@ -15,7 +15,7 @@
</script>
<script type="text/javascript" src="js/api_page_generator.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
- <title>chrome.experimental.contextMenu - Google Chrome Extensions - Google Code</title></head><body> <div id="gc-container" class="labs">
+ <title>chrome.experimental.contextMenus - Google Chrome Extensions - Google Code</title></head><body> <div id="gc-container" class="labs">
<div id="devModeWarning">
You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files.
</div>
@@ -207,7 +207,7 @@
<div class="g-unit" id="gc-pagecontent">
<div id="pageTitle">
- <h1 class="page_title">chrome.experimental.contextMenu</h1>
+ <h1 class="page_title">chrome.experimental.contextMenus</h1>
</div>
<!-- TABLE OF CONTENTS -->
<div id="toc">
@@ -222,7 +222,7 @@
</ol>
</li>
<li>
- <a href="#apiReference">API reference: chrome.experimental.contextMenu</a>
+ <a href="#apiReference">API reference: chrome.experimental.contextMenus</a>
<ol>
<li style="display: none; ">
<a href="#properties">Properties</a>
@@ -281,7 +281,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<!-- API PAGE -->
<div class="apiPage">
<a name="apiReference"></a>
- <h2>API reference: chrome.experimental.contextMenu</h2>
+ <h2>API reference: chrome.experimental.contextMenus</h2>
<!-- PROPERTIES -->
<div class="apiGroup" style="display: none; ">
@@ -313,7 +313,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<div class="summary"><span style="display: none; ">void</span>
<!-- Note: intentionally longer 80 columns -->
- <span>chrome.experimental.contextMenu.create</span>(<span class="null"><span style="display: none; ">, </span><span>object</span>
+ <span>chrome.experimental.contextMenus.create</span>(<span class="null"><span style="display: none; ">, </span><span>object</span>
<var><span>createProperties</span></var></span><span class="optional"><span>, </span><span>function</span>
<var><span>callback</span></var></span>)</div>
@@ -402,7 +402,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>The type of menu item - one of 'NORMAL', 'CHECKBOX', 'RADIO', or 'SEPARATOR'. Defaults to 'NORMAL' if not specified.</dd>
+ <dd>The type of menu item - one of 'normal', 'checkbox', 'radio', or 'separator'. Defaults to 'normal' if not specified.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -454,7 +454,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>This must be specified unless type is 'SEPARATOR'.</dd>
+ <dd>This must be specified unless type is 'separator'.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -506,7 +506,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd> For items of type CHECKBOX or RADIO, should this be selected (RADIO) or checked (CHECKBOX)? Only one RADIO item can be selected at a time in a given group of RADIO items, with the last one to have checked == true winning.</dd>
+ <dd> For items of type checkbox or radio, should this be selected (radio) or checked (checkbox)? Only one radio item can be selected at a time in a given group of radio items, with the last one to have checked == true winning.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -569,70 +569,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>List of contexts this menu item will appear in. Legal values are: 'ALL', 'PAGE', 'SELECTION', 'LINK', 'EDITABLE', 'IMAGE', 'VIDEO', and 'AUDIO'. Defaults to ['PAGE'].</dd>
- <dd style="display: none; ">
- This parameter was added in version
- <b><span></span></b>.
- You must omit this parameter in earlier versions,
- and you may omit it in any version. If you require this
- parameter, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </dd>
-
- <!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
- <dl>
- <div>
- <div>
- </div>
- </div>
- </dl>
- </dd>
- </div>
- </div><div>
- <div>
- <dt>
- <var>enabledContexts</var>
- <em>
-
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span class="enum" style="display: none; ">enumerated</span>
- <span id="typeTemplate">
- <span style="display: none; ">
- <a> Type</a>
- </span>
- <span>
- <span>
- array of <span><span>
- <span style="display: none; ">
- <a> Type</a>
- </span>
- <span>
- <span style="display: none; ">
- array of <span><span></span></span>
- </span>
- <span>string</span>
- <span style="display: none; "></span>
- </span>
- </span></span>
- </span>
- <span style="display: none; ">paramType</span>
- <span style="display: none; "></span>
- </span>
- </span>
- )
- </div>
-
- </em>
- </dt>
- <dd class="todo" style="display: none; ">
- Undocumented.
- </dd>
- <dd>By default the values you pass for the contexts parameter make an item both shown and selectable in those contexts. If you want to limit the contexts where an item is selectable (i.e. not greyed out), you put the ones you want selectable in enabledContexts and any not listed will be shown but disabled. So, for example, if you wanted an item to appear for links and images but only be enabled for links, you would set 'contexts' : ['LINK', 'IMAGE'] and 'enabledContexts' : ['LINK'].</dd>
+ <dd>List of contexts this menu item will appear in. Legal values are: 'all', 'page', 'selection', 'link', 'editable', 'image', 'video', and 'audio'. Defaults to ['page'].</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -684,7 +621,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>Function to be called back when your menu item or one of its children is clicked.</dd>
+ <dd>Function to be called back when your menu item is clicked.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -915,7 +852,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<div class="summary"><span style="display: none; ">void</span>
<!-- Note: intentionally longer 80 columns -->
- <span>chrome.experimental.contextMenu.remove</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span>
+ <span>chrome.experimental.contextMenus.remove</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span>
<var><span>menuItemId</span></var></span><span class="optional"><span>, </span><span>function</span>
<var><span>callback</span></var></span>)</div>
@@ -1081,7 +1018,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<div class="summary"><span style="display: none; ">void</span>
<!-- Note: intentionally longer 80 columns -->
- <span>chrome.experimental.contextMenu.removeAll</span>(<span class="optional"><span style="display: none; ">, </span><span>function</span>
+ <span>chrome.experimental.contextMenus.removeAll</span>(<span class="optional"><span style="display: none; ">, </span><span>function</span>
<var><span>callback</span></var></span>)</div>
<div class="description">
@@ -1194,7 +1131,7 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
<div class="summary"><span style="display: none; ">void</span>
<!-- Note: intentionally longer 80 columns -->
- <span>chrome.experimental.contextMenu.update</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span>
+ <span>chrome.experimental.contextMenus.update</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span>
<var><span>id</span></var></span><span class="null"><span>, </span><span>object</span>
<var><span>updateProperties</span></var></span><span class="optional"><span>, </span><span>function</span>
<var><span>callback</span></var></span>)</div>
@@ -1533,71 +1470,6 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
</div><div>
<div>
<dt>
- <var>enabledContexts</var>
- <em>
-
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span class="enum" style="display: none; ">enumerated</span>
- <span id="typeTemplate">
- <span style="display: none; ">
- <a> Type</a>
- </span>
- <span>
- <span>
- array of <span><span>
- <span style="display: none; ">
- <a> Type</a>
- </span>
- <span>
- <span style="display: none; ">
- array of <span><span></span></span>
- </span>
- <span>string</span>
- <span style="display: none; "></span>
- </span>
- </span></span>
- </span>
- <span style="display: none; ">paramType</span>
- <span style="display: none; "></span>
- </span>
- </span>
- )
- </div>
-
- </em>
- </dt>
- <dd class="todo">
- Undocumented.
- </dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
- <dd style="display: none; ">
- This parameter was added in version
- <b><span></span></b>.
- You must omit this parameter in earlier versions,
- and you may omit it in any version. If you require this
- parameter, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </dd>
-
- <!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
- <dl>
- <div>
- <div>
- </div>
- </div>
- </dl>
- </dd>
- </div>
- </div><div>
- <div>
- <dt>
<var>onclick</var>
<em>
diff --git a/chrome/common/extensions/docs/experimental.html b/chrome/common/extensions/docs/experimental.html
index d2689fd..7962b09 100644
--- a/chrome/common/extensions/docs/experimental.html
+++ b/chrome/common/extensions/docs/experimental.html
@@ -273,7 +273,7 @@ on the following experimental APIs:
<ul>
<li>
<a href="experimental.clipboard.html">experimental.clipboard</a></li><li>
- <a href="experimental.contextMenu.html">experimental.contextMenu</a></li><li>
+ <a href="experimental.contextMenus.html">experimental.contextMenus</a></li><li>
<a href="experimental.cookies.html">experimental.cookies</a></li><li>
<a href="experimental.infobars.html">experimental.infobars</a></li><li>
<a href="experimental.omnibox.html">experimental.omnibox</a></li><li>
diff --git a/chrome/common/extensions/docs/static/experimental.contextMenu.html b/chrome/common/extensions/docs/static/experimental.contextMenus.html
index bc07cad..bc07cad 100644
--- a/chrome/common/extensions/docs/static/experimental.contextMenu.html
+++ b/chrome/common/extensions/docs/static/experimental.contextMenus.html
diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js
index 4a59dcb..4ebc848 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -263,7 +263,7 @@ var chrome = chrome || {};
}
function setupHiddenContextMenuEvent(extensionId) {
- var eventName = "contextMenu/" + extensionId;
+ var eventName = "contextMenus/" + extensionId;
chromeHidden.contextMenuEvent = new chrome.Event(eventName);
chromeHidden.contextMenuHandlers = {};
chromeHidden.contextMenuEvent.addListener(function() {
@@ -272,12 +272,6 @@ var chrome = chrome || {};
if (onclick) {
onclick.apply(onclick, arguments);
}
-
- var parentMenuItemId = arguments[0].parentMenuItemId;
- var parentOnclick = chromeHidden.contextMenuHandlers[parentMenuItemId];
- if (parentOnclick) {
- parentOnclick.apply(parentOnclick, arguments);
- }
});
}
@@ -597,7 +591,7 @@ var chrome = chrome || {};
details, this.name, this.definition.parameters, "page action");
};
- apiFunctions["experimental.contextMenu.create"].customCallback =
+ apiFunctions["experimental.contextMenus.create"].customCallback =
function(name, request, response) {
if (chrome.extension.lastError || !response) {
return;
@@ -611,7 +605,7 @@ var chrome = chrome || {};
}
};
- apiFunctions["experimental.contextMenu.remove"].customCallback =
+ apiFunctions["experimental.contextMenus.remove"].customCallback =
function(name, request, response) {
// Remove any onclick handler we had registered for this menu item.
if (request.args.length > 0) {
diff --git a/chrome/renderer/resources/renderer_extension_bindings.js b/chrome/renderer/resources/renderer_extension_bindings.js
index f274be7..e2e0e1d 100644
--- a/chrome/renderer/resources/renderer_extension_bindings.js
+++ b/chrome/renderer/resources/renderer_extension_bindings.js
@@ -247,7 +247,7 @@ var chrome = chrome || {};
"experimental.accessibility",
"experimental.bookmarkManager",
"experimental.clipboard",
- "experimental.contextMenu",
+ "experimental.contextMenus",
"experimental.cookies",
"experimental.extension",
"experimental.idle",
diff --git a/chrome/test/data/extensions/api_test/context_menus/manifest.json b/chrome/test/data/extensions/api_test/context_menus/manifest.json
index e678526..4659441 100644
--- a/chrome/test/data/extensions/api_test/context_menus/manifest.json
+++ b/chrome/test/data/extensions/api_test/context_menus/manifest.json
@@ -1,7 +1,7 @@
{
- "name": "chrome.extension.contextMenu",
+ "name": "chrome.contextMenus",
"version": "0.1",
- "description": "end-to-end browser test for chrome.contextMenu API",
+ "description": "end-to-end browser test for chrome.contextMenus API",
"background_page": "test.html",
- "permissions": ["experimental"]
+ "permissions": ["experimental", "tabs"]
}
diff --git a/chrome/test/data/extensions/api_test/context_menus/test.js b/chrome/test/data/extensions/api_test/context_menus/test.js
index 78ba095..14cc1d7 100644
--- a/chrome/test/data/extensions/api_test/context_menus/test.js
+++ b/chrome/test/data/extensions/api_test/context_menus/test.js
@@ -1,51 +1,54 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
-if (!chrome.contextMenu) {
- chrome.contextMenu = chrome.experimental.contextMenu;
+if (!chrome.contextMenus) {
+ chrome.contextMenus = chrome.experimental.contextMenus;
}
var assertNoLastError = chrome.test.assertNoLastError;
var tests = [
function simple() {
- chrome.contextMenu.create({"title":"1"}, chrome.test.callbackPass());
+ chrome.contextMenus.create({"title":"1"}, chrome.test.callbackPass());
},
function no_properties() {
- chrome.contextMenu.create({}, function(id) {
+ chrome.contextMenus.create({}, function(id) {
chrome.test.assertTrue(chrome.extension.lastError != null);
chrome.test.succeed();
});
},
function remove() {
- chrome.contextMenu.create({"title":"1"}, function(id) {
+ chrome.contextMenus.create({"title":"1"}, function(id) {
assertNoLastError();
- chrome.contextMenu.remove(id, chrome.test.callbackPass());
+ chrome.contextMenus.remove(id, chrome.test.callbackPass());
});
},
function update() {
- chrome.contextMenu.create({"title":"update test"}, function(id) {
+ chrome.contextMenus.create({"title":"update test"}, function(id) {
assertNoLastError();
- chrome.contextMenu.update(id, {"title": "test2"},
+ chrome.contextMenus.update(id, {"title": "test2"},
chrome.test.callbackPass());
});
},
function removeAll() {
- chrome.contextMenu.create({"title":"1"}, function(id) {
+ chrome.contextMenus.create({"title":"1"}, function(id) {
assertNoLastError();
- chrome.contextMenu.create({"title":"2"}, function(id2) {
+ chrome.contextMenus.create({"title":"2"}, function(id2) {
assertNoLastError();
- chrome.contextMenu.removeAll(chrome.test.callbackPass());
+ chrome.contextMenus.removeAll(chrome.test.callbackPass());
});
});
},
function hasParent() {
- chrome.contextMenu.create({"title":"parent"}, function(id) {
+ chrome.contextMenus.create({"title":"parent"}, function(id) {
assertNoLastError();
- chrome.contextMenu.create({"title":"child", "parentId":id},
+ chrome.contextMenus.create({"title":"child", "parentId":id},
function(id2) {
assertNoLastError();
chrome.test.succeed();
@@ -56,9 +59,9 @@ var tests = [
// Add tests for creating menu item with various types and contexts.
-var types = ["CHECKBOX", "RADIO", "SEPARATOR"];
-var contexts = ["ALL", "PAGE", "SELECTION", "LINK", "EDITABLE", "IMAGE",
- "VIDEO", "AUDIO"];
+var types = ["checkbox", "radio", "separator"];
+var contexts = ["all", "page", "selection", "link", "editable", "image",
+ "video", "audio"];
function makeCreateTest(type, contexts) {
var result = function() {
var title = type;
@@ -67,7 +70,7 @@ function makeCreateTest(type, contexts) {
}
var properties = {"title": title, "type": type};
- chrome.contextMenu.create(properties, chrome.test.callbackPass());
+ chrome.contextMenus.create(properties, chrome.test.callbackPass());
};
result.generatedName = "create_" + type +
(contexts ? "-" + contexts.join(",") : "");
@@ -78,7 +81,7 @@ for (var i in types) {
tests.push(makeCreateTest(types[i]));
}
for (var i in contexts) {
- tests.push(makeCreateTest("NORMAL", [ contexts[i] ]));
+ tests.push(makeCreateTest("normal", [ contexts[i] ]));
}
chrome.test.runTests(tests);
diff --git a/chrome/test/data/extensions/context_menus/test.js b/chrome/test/data/extensions/context_menus/test.js
index c6a1049..9cab126 100644
--- a/chrome/test/data/extensions/context_menus/test.js
+++ b/chrome/test/data/extensions/context_menus/test.js
@@ -25,7 +25,7 @@ function onclick(info) {
}
window.onload = function() {
- chrome.experimental.contextMenu.create({"title":"Extension Item 1",
+ chrome.experimental.contextMenus.create({"title":"Extension Item 1",
"onclick": onclick}, function(id) {
if (!chrome.extension.lastError) {
navigateCurrentTab(chrome.extension.getURL("test.html"));