summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 22:20:00 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 22:20:00 +0000
commit434c21e053a20e5d417125a62f6f9de31258a8ce (patch)
tree67e26ed41a65e474c7e5fa45bddf791e1897f492 /chrome/browser
parent44b4b0ccfdfc1ca2a8a56094d86a554b79f43ce7 (diff)
downloadchromium_src-434c21e053a20e5d417125a62f6f9de31258a8ce.zip
chromium_src-434c21e053a20e5d417125a62f6f9de31258a8ce.tar.gz
chromium_src-434c21e053a20e5d417125a62f6f9de31258a8ce.tar.bz2
First step in abstracting extension api to common/shared "IDL" files (jsonschema).
In this step, All "normal" api calls and events (those that arrive or originate from the browser process) are routed through a single v8::Extension API Call ("StartRequest"). Additionally, internal string names for methods and events now match the js namespace (i.e. "RemoveTab" -> "tabs.remove"), in anticipation of having names be implicit from their api module & name in the api "IDL". TBR=aa,mpcomplete Review URL: http://codereview.chromium.org/149730 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20910 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module_constants.cc27
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module_constants.h1
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.cc2
-rw-r--r--chrome/browser/extensions/extension_event_names.cc20
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc2
-rw-r--r--chrome/browser/extensions/extension_page_actions_module_constants.cc4
-rw-r--r--chrome/browser/extensions/extension_tabs_module_constants.cc32
-rw-r--r--chrome/browser/extensions/extension_uitest.cc38
8 files changed, 65 insertions, 61 deletions
diff --git a/chrome/browser/extensions/extension_bookmarks_module_constants.cc b/chrome/browser/extensions/extension_bookmarks_module_constants.cc
index 24d7c92..222728b 100644
--- a/chrome/browser/extensions/extension_bookmarks_module_constants.cc
+++ b/chrome/browser/extensions/extension_bookmarks_module_constants.cc
@@ -27,19 +27,20 @@ const char kInvalidIndexError[] = "Index out of bounds.";
const char kInvalidUrlError[] = "Invalid URL.";
const char kModifySpecialError[] = "Can't modify the root bookmark folders.";
-const char kOnBookmarkAdded[] = "bookmark-added";
-const char kOnBookmarkRemoved[] = "bookmark-removed";
-const char kOnBookmarkChanged[] = "bookmark-changed";
-const char kOnBookmarkMoved[] = "bookmark-moved";
-const char kOnBookmarkChildrenReordered[] = "bookmark-children-reordered";
+const char kOnBookmarkAdded[] = "bookmarks.onAdded";
+const char kOnBookmarkRemoved[] = "bookmarks.onRemoved";
+const char kOnBookmarkChanged[] = "bookmarks.onChanged";
+const char kOnBookmarkMoved[] = "bookmarks.onMoved";
+const char kOnBookmarkChildrenReordered[] = "bookmarks.onChildrenReordered";
-const char kGetBookmarksFunction[] = "GetBookmarks";
-const char kGetBookmarkChildrenFunction[] = "GetBookmarkChildren";
-const char kGetBookmarkTreeFunction[] = "GetBookmarkTree";
-const char kSearchBookmarksFunction[] = "SearchBookmarks";
-const char kRemoveBookmarkFunction[] = "RemoveBookmark";
-const char kCreateBookmarkFunction[] = "CreateBookmark";
-const char kMoveBookmarkFunction[] = "MoveBookmark";
-const char kSetBookmarkTitleFunction[] = "SetBookmarkTitle";
+const char kGetBookmarksFunction[] = "bookmarks.get";
+const char kGetBookmarkChildrenFunction[] = "bookmarks.getChildren";
+const char kGetBookmarkTreeFunction[] = "bookmarks.getTree";
+const char kSearchBookmarksFunction[] = "bookmarks.search";
+const char kRemoveBookmarkFunction[] = "bookmarks.remove";
+const char kRemoveBookmarkTreeFunction[] = "bookmarks.removeTree";
+const char kCreateBookmarkFunction[] = "bookmarks.create";
+const char kMoveBookmarkFunction[] = "bookmarks.move";
+const char kSetBookmarkTitleFunction[] = "bookmarks.update";
} // namespace extension_bookmarks_module_constants
diff --git a/chrome/browser/extensions/extension_bookmarks_module_constants.h b/chrome/browser/extensions/extension_bookmarks_module_constants.h
index 665747c..7c2af58 100644
--- a/chrome/browser/extensions/extension_bookmarks_module_constants.h
+++ b/chrome/browser/extensions/extension_bookmarks_module_constants.h
@@ -44,6 +44,7 @@ extern const char kGetBookmarkChildrenFunction[];
extern const char kGetBookmarkTreeFunction[];
extern const char kSearchBookmarksFunction[];
extern const char kRemoveBookmarkFunction[];
+extern const char kRemoveBookmarkTreeFunction[];
extern const char kCreateBookmarkFunction[];
extern const char kMoveBookmarkFunction[];
extern const char kSetBookmarkTitleFunction[];
diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc
index c7a5b33..a689d32 100644
--- a/chrome/browser/extensions/extension_browser_event_router.cc
+++ b/chrome/browser/extensions/extension_browser_event_router.cc
@@ -162,7 +162,7 @@ void ExtensionBrowserEventRouter::TabCreatedAt(TabContents* contents,
void ExtensionBrowserEventRouter::TabInsertedAt(TabContents* contents,
int index,
bool foreground) {
- // If tab is new, send tab-created event.
+ // If tab is new, send created event.
int tab_id = ExtensionTabUtil::GetTabId(contents);
if (tab_entries_.find(tab_id) == tab_entries_.end()) {
tab_entries_[tab_id] = TabEntry(contents);
diff --git a/chrome/browser/extensions/extension_event_names.cc b/chrome/browser/extensions/extension_event_names.cc
index 214d37b..421bab8 100644
--- a/chrome/browser/extensions/extension_event_names.cc
+++ b/chrome/browser/extensions/extension_event_names.cc
@@ -6,16 +6,16 @@
namespace extension_event_names {
-const char kOnTabAttached[] = "tab-attached";
-const char kOnTabCreated[] = "tab-created";
-const char kOnTabDetached[] = "tab-detached";
-const char kOnTabMoved[] = "tab-moved";
-const char kOnTabRemoved[] = "tab-removed";
-const char kOnTabSelectionChanged[] = "tab-selection-changed";
-const char kOnTabUpdated[] = "tab-updated";
-const char kOnWindowCreated[] = "window-created";
-const char kOnWindowFocusedChanged[] = "window-focus-changed";
-const char kOnWindowRemoved[] = "window-removed";
+const char kOnTabAttached[] = "tabs.onAttached";
+const char kOnTabCreated[] = "tabs.onCreated";
+const char kOnTabDetached[] = "tabs.onDetached";
+const char kOnTabMoved[] = "tabs.onMoved";
+const char kOnTabRemoved[] = "tabs.onRemoved";
+const char kOnTabSelectionChanged[] = "tabs.onSelectionChanged";
+const char kOnTabUpdated[] = "tabs.onUpdated";
+const char kOnWindowCreated[] = "windows.onCreated";
+const char kOnWindowFocusedChanged[] = "windows.onFocusChanged";
+const char kOnWindowRemoved[] = "windows.onRemoved";
} // namespace extension_event_names
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 971349b..4b13d98 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -119,6 +119,8 @@ void FactoryRegistry::ResetFunctions() {
&NewExtensionFunction<SearchBookmarksFunction>;
factories_[bookmarks::kRemoveBookmarkFunction] =
&NewExtensionFunction<RemoveBookmarkFunction>;
+ factories_[bookmarks::kRemoveBookmarkTreeFunction] =
+ &NewExtensionFunction<RemoveBookmarkFunction>;
factories_[bookmarks::kCreateBookmarkFunction] =
&NewExtensionFunction<CreateBookmarkFunction>;
factories_[bookmarks::kMoveBookmarkFunction] =
diff --git a/chrome/browser/extensions/extension_page_actions_module_constants.cc b/chrome/browser/extensions/extension_page_actions_module_constants.cc
index 2b54f1b..bda4d37 100644
--- a/chrome/browser/extensions/extension_page_actions_module_constants.cc
+++ b/chrome/browser/extensions/extension_page_actions_module_constants.cc
@@ -16,7 +16,7 @@ const char kNoTabError[] = "No tab with id: *.";
const char kNoPageActionError[] = "No PageAction with id: *.";
const char kUrlNotActiveError[] = "This url is no longer active: *.";
-const char kEnablePageActionFunction[] = "EnablePageAction";
-const char kDisablePageActionFunction[] = "DisablePageAction";
+const char kEnablePageActionFunction[] = "pageActions.enableForTab";
+const char kDisablePageActionFunction[] = "pageActions.disableForTab";
} // namespace extension_page_actions_module_constants
diff --git a/chrome/browser/extensions/extension_tabs_module_constants.cc b/chrome/browser/extensions/extension_tabs_module_constants.cc
index d4d1cf8..11e7dad 100644
--- a/chrome/browser/extensions/extension_tabs_module_constants.cc
+++ b/chrome/browser/extensions/extension_tabs_module_constants.cc
@@ -41,21 +41,21 @@ const char kTabNotFoundError[] = "No tab with id: *.";
const char kNoSelectedTabError[] = "No selected tab";
const char kInvalidUrlError[] = "Invalid url: \"*\".";
-const char kGetWindowFunction[] = "GetWindow";
-const char kGetCurrentWindowFunction[] = "GetCurrentWindow";
-const char kGetLastFocusedWindowFunction[] = "GetLastFocusedWindow";
-const char kGetAllWindowsFunction[] = "GetAllWindows";
-const char kCreateWindowFunction[] = "CreateWindow";
-const char kUpdateWindowFunction[] = "UpdateWindow";
-const char kRemoveWindowFunction[] = "RemoveWindow";
-
-const char kGetTabFunction[] = "GetTab";
-const char kGetSelectedTabFunction[] = "GetSelectedTab";
-const char kGetAllTabsInWindowFunction[] = "GetAllTabsInWindow";
-const char kCreateTabFunction[] = "CreateTab";
-const char kUpdateTabFunction[] = "UpdateTab";
-const char kMoveTabFunction[] = "MoveTab";
-const char kRemoveTabFunction[] = "RemoveTab";
-const char kDetectTabLanguageFunction[] = "DetectTabLanguage";
+const char kGetWindowFunction[] = "windows.get";
+const char kGetCurrentWindowFunction[] = "windows.getCurrent";
+const char kGetLastFocusedWindowFunction[] = "windows.getLastFocused";
+const char kGetAllWindowsFunction[] = "windows.getAll";
+const char kCreateWindowFunction[] = "windows.create";
+const char kUpdateWindowFunction[] = "windows.update";
+const char kRemoveWindowFunction[] = "windows.remove";
+
+const char kGetTabFunction[] = "tabs.get";
+const char kGetSelectedTabFunction[] = "tabs.getSelected";
+const char kGetAllTabsInWindowFunction[] = "tabs.getAllInWindow";
+const char kCreateTabFunction[] = "tabs.create";
+const char kUpdateTabFunction[] = "tabs.update";
+const char kMoveTabFunction[] = "tabs.move";
+const char kRemoveTabFunction[] = "tabs.remove";
+const char kDetectTabLanguageFunction[] = "tabs.detectLanguage";
} // namespace extension_tabs_module_constants
diff --git a/chrome/browser/extensions/extension_uitest.cc b/chrome/browser/extensions/extension_uitest.cc
index 6945446..89faa41 100644
--- a/chrome/browser/extensions/extension_uitest.cc
+++ b/chrome/browser/extensions/extension_uitest.cc
@@ -130,7 +130,7 @@ TEST_F(SimpleApiCallExtensionTest, RunTest) {
reinterpret_cast<DictionaryValue*>(message_value.get());
std::string result;
message_dict->GetString(keys::kAutomationNameKey, &result);
- EXPECT_EQ(result, "RemoveTab");
+ EXPECT_EQ(result, "tabs.remove");
result = "";
message_dict->GetString(keys::kAutomationArgsKey, &result);
@@ -224,7 +224,7 @@ class RoundtripAutomationProxy : public MultiMessageAutomationProxy {
&has_callback));
if (messages_received_ == 1) {
- EXPECT_EQ(function_name, "GetLastFocusedWindow");
+ EXPECT_EQ(function_name, "windows.getLastFocused");
EXPECT_GE(request_id, 0);
EXPECT_TRUE(has_callback);
@@ -241,7 +241,7 @@ class RoundtripAutomationProxy : public MultiMessageAutomationProxy {
keys::kAutomationOrigin,
keys::kAutomationResponseTarget);
} else if (messages_received_ == 2) {
- EXPECT_EQ(function_name, "RemoveTab");
+ EXPECT_EQ(function_name, "tabs.remove");
EXPECT_FALSE(has_callback);
std::string args;
@@ -318,25 +318,25 @@ class BrowserEventAutomationProxy : public MultiMessageAutomationProxy {
const char* BrowserEventAutomationProxy::event_names_[] = {
// Window events.
- "window-created",
- "window-removed",
- "window-focus-changed",
+ "windows.onCreated",
+ "windows.onRemoved",
+ "windows.onFocusChanged",
// Tab events.
- "tab-created",
- "tab-updated",
- "tab-moved",
- "tab-selection-changed",
- "tab-attached",
- "tab-detached",
- "tab-removed",
+ "tabs.onCreated",
+ "tabs.onUpdated",
+ "tabs.onMoved",
+ "tabs.onSelectionChanged",
+ "tabs.onAttached",
+ "tabs.onDetached",
+ "tabs.onRemoved",
// Bookmark events.
- "bookmark-added",
- "bookmark-removed",
- "bookmark-changed",
- "bookmark-moved",
- "bookmark-children-reordered",
+ "bookmarks.onAdded",
+ "bookmarks.onRemoved",
+ "bookmarks.onChanged",
+ "bookmarks.onMoved",
+ "bookmarks.onChildrenReordered",
};
void BrowserEventAutomationProxy::HandleMessageFromChrome() {
@@ -361,7 +361,7 @@ void BrowserEventAutomationProxy::HandleMessageFromChrome() {
std::string name;
message_dict->GetString(keys::kAutomationNameKey, &name);
- ASSERT_STREQ(name.c_str(), "GetCurrentWindow");
+ ASSERT_STREQ(name.c_str(), "windows.getCurrent");
// Send an OpenChannelToExtension message to chrome. Note: the JSON
// reader expects quoted property keys. See the comment in