diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 23:14:59 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 23:14:59 +0000 |
commit | 61424c0631ac4cc5838cf6a80406fc98ca60220d (patch) | |
tree | 773f1a61d46c82b01886ff9dfff318292f67d8fb /chrome/browser/extensions | |
parent | 980656f5f9500c6a79152434652b8817dd6b7a03 (diff) | |
download | chromium_src-61424c0631ac4cc5838cf6a80406fc98ca60220d.zip chromium_src-61424c0631ac4cc5838cf6a80406fc98ca60220d.tar.gz chromium_src-61424c0631ac4cc5838cf6a80406fc98ca60220d.tar.bz2 |
Small cleanup to extension function registration to avoid scattered definitions.
BUG=no
Review URL: http://codereview.chromium.org/274059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
22 files changed, 98 insertions, 211 deletions
diff --git a/chrome/browser/extensions/execute_code_in_tab_function.cc b/chrome/browser/extensions/execute_code_in_tab_function.cc index 8827c5c..989d5f2 100755 --- a/chrome/browser/extensions/execute_code_in_tab_function.cc +++ b/chrome/browser/extensions/execute_code_in_tab_function.cc @@ -124,9 +124,9 @@ void ExecuteCodeInTabFunction::Execute(const std::string& code_string) { bool is_js_code = true; std::string function_name = name(); - if (function_name == keys::kInsertCSSFunction) { + if (function_name == TabsInsertCSSFunction::function_name()) { is_js_code = false; - } else if (function_name != keys::kExecuteScriptFunction) { + } else if (function_name != TabsExecuteScriptFunction::function_name()) { DCHECK(false); } registrar_.Add(this, NotificationType::TAB_CODE_EXECUTED, diff --git a/chrome/browser/extensions/execute_code_in_tab_function.h b/chrome/browser/extensions/execute_code_in_tab_function.h index 5ea91e6..8215fd2 100755 --- a/chrome/browser/extensions/execute_code_in_tab_function.h +++ b/chrome/browser/extensions/execute_code_in_tab_function.h @@ -46,4 +46,12 @@ class ExecuteCodeInTabFunction : public AsyncExtensionFunction, ExtensionResource resource_; }; +class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction { + DECLARE_EXTENSION_FUNCTION_NAME("tabs.executeScript") +}; + +class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { + DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS") +}; + #endif // CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index 4bef0f2..0724a5a 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.cc @@ -360,8 +360,7 @@ bool SearchBookmarksFunction::RunImpl() { bool RemoveBookmarkFunction::RunImpl() { bool recursive = false; - if (name() == - extension_bookmarks_module_constants::kRemoveBookmarkTreeFunction) + if (name() == RemoveTreeBookmarkFunction::function_name()) recursive = true; BookmarkModel* model = profile()->GetBookmarkModel(); diff --git a/chrome/browser/extensions/extension_bookmarks_module.h b/chrome/browser/extensions/extension_bookmarks_module.h index cb2cd6c..6d86bc8 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.h +++ b/chrome/browser/extensions/extension_bookmarks_module.h @@ -82,34 +82,46 @@ class BookmarksFunction : public AsyncExtensionFunction, class GetBookmarksFunction : public BookmarksFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.get") }; class GetBookmarkChildrenFunction : public BookmarksFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.getChildren") }; class GetBookmarkTreeFunction : public BookmarksFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.getTree") }; class SearchBookmarksFunction : public BookmarksFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.search") }; class RemoveBookmarkFunction : public BookmarksFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.remove") +}; + +class RemoveTreeBookmarkFunction : public RemoveBookmarkFunction { + DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.removeTree") }; class CreateBookmarkFunction : public BookmarksFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.create") }; class MoveBookmarkFunction : public BookmarksFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.move") }; class UpdateBookmarkFunction : public BookmarksFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.update") }; #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H_ diff --git a/chrome/browser/extensions/extension_bookmarks_module_constants.cc b/chrome/browser/extensions/extension_bookmarks_module_constants.cc index 769fe09..6f72669 100644 --- a/chrome/browser/extensions/extension_bookmarks_module_constants.cc +++ b/chrome/browser/extensions/extension_bookmarks_module_constants.cc @@ -34,14 +34,4 @@ const char kOnBookmarkChanged[] = "bookmarks.onChanged"; const char kOnBookmarkMoved[] = "bookmarks.onMoved"; const char kOnBookmarkChildrenReordered[] = "bookmarks.onChildrenReordered"; -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 kUpdateBookmarkFunction[] = "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 12d677d..159dc7f 100644 --- a/chrome/browser/extensions/extension_bookmarks_module_constants.h +++ b/chrome/browser/extensions/extension_bookmarks_module_constants.h @@ -39,17 +39,6 @@ extern const char kOnBookmarkChanged[]; extern const char kOnBookmarkMoved[]; extern const char kOnBookmarkChildrenReordered[]; -// Function names. -extern const char kGetBookmarksFunction[]; -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 kUpdateBookmarkFunction[]; - }; // namespace extension_bookmarks_module_constants #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_CONSTANTS_H_ diff --git a/chrome/browser/extensions/extension_browser_actions_api.cc b/chrome/browser/extensions/extension_browser_actions_api.cc index 0a94026..e671d15 100644 --- a/chrome/browser/extensions/extension_browser_actions_api.cc +++ b/chrome/browser/extensions/extension_browser_actions_api.cc @@ -9,16 +9,6 @@ #include "chrome/common/notification_service.h" #include "chrome/common/render_messages.h" -namespace extension_browser_actions_api_constants { - -const char kSetNameFunction[] = "browserAction.setName"; -const char kSetIconFunction[] = "browserAction.setIcon"; -const char kSetBadgeTextFunction[] = "browserAction.setBadgeText"; -const char kSetBadgeBackgroundColorFunction[] = - "browserAction.setBadgeBackgroundColor"; - -} // namespace extension_browser_actions_api_constants - namespace { // Errors. const char kNoBrowserActionError[] = diff --git a/chrome/browser/extensions/extension_browser_actions_api.h b/chrome/browser/extensions/extension_browser_actions_api.h index e08baa4..c5193d6 100755 --- a/chrome/browser/extensions/extension_browser_actions_api.h +++ b/chrome/browser/extensions/extension_browser_actions_api.h @@ -9,29 +9,23 @@ class BrowserActionSetNameFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setName") }; class BrowserActionSetIconFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setIcon") }; class BrowserActionSetBadgeTextFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeText") }; class BrowserActionSetBadgeBackgroundColorFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeBackgroundColor") }; -namespace extension_browser_actions_api_constants { - -// Function names. -extern const char kSetNameFunction[]; -extern const char kSetIconFunction[]; -extern const char kSetBadgeTextFunction[]; -extern const char kSetBadgeBackgroundColorFunction[]; - -}; // namespace extension_browser_actions_api_constants - #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_ diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h index 238f8e4..6090f8a 100644 --- a/chrome/browser/extensions/extension_function.h +++ b/chrome/browser/extensions/extension_function.h @@ -22,6 +22,9 @@ class Profile; } \ } while (0) +#define DECLARE_EXTENSION_FUNCTION_NAME(name) \ + public: static const char* function_name() { return name; } + // Abstract base class for extension functions the ExtensionFunctionDispatcher // knows how to dispatch to. // diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index d17e575..4b07658 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -60,6 +60,11 @@ class FactoryRegistry { ExtensionFunction* NewFunction(const std::string& name); private: + template<class T> + void RegisterFunction() { + factories_[T::function_name()] = &NewExtensionFunction<T>; + } + typedef std::map<std::string, ExtensionFunctionFactory> FactoryMap; FactoryMap factories_; }; @@ -71,107 +76,60 @@ FactoryRegistry* FactoryRegistry::instance() { void FactoryRegistry::ResetFunctions() { // Register all functions here. - namespace bookmarks = extension_bookmarks_module_constants; - namespace i18n = extension_i18n_api_functions; - namespace page_actions = extension_page_actions_module_constants; - namespace browser_actions = extension_browser_actions_api_constants; - namespace tabs = extension_tabs_module_constants; - namespace test = extension_test_api_functions; - namespace toolstrip = extension_toolstrip_api_functions; - // Windows - factories_[tabs::kGetWindowFunction] = - &NewExtensionFunction<GetWindowFunction>; - factories_[tabs::kGetCurrentWindowFunction] = - &NewExtensionFunction<GetCurrentWindowFunction>; - factories_[tabs::kGetLastFocusedWindowFunction] = - &NewExtensionFunction<GetLastFocusedWindowFunction>; - factories_[tabs::kGetAllWindowsFunction] = - &NewExtensionFunction<GetAllWindowsFunction>; - factories_[tabs::kCreateWindowFunction] = - &NewExtensionFunction<CreateWindowFunction>; - factories_[tabs::kUpdateWindowFunction] = - &NewExtensionFunction<UpdateWindowFunction>; - factories_[tabs::kRemoveWindowFunction] = - &NewExtensionFunction<RemoveWindowFunction>; + RegisterFunction<GetWindowFunction>(); + RegisterFunction<GetCurrentWindowFunction>(); + RegisterFunction<GetLastFocusedWindowFunction>(); + RegisterFunction<GetAllWindowsFunction>(); + RegisterFunction<CreateWindowFunction>(); + RegisterFunction<UpdateWindowFunction>(); + RegisterFunction<RemoveWindowFunction>(); // Tabs - factories_[tabs::kGetTabFunction] = - &NewExtensionFunction<GetTabFunction>; - factories_[tabs::kGetSelectedTabFunction] = - &NewExtensionFunction<GetSelectedTabFunction>; - factories_[tabs::kGetAllTabsInWindowFunction] = - &NewExtensionFunction<GetAllTabsInWindowFunction>; - factories_[tabs::kCreateTabFunction] = - &NewExtensionFunction<CreateTabFunction>; - factories_[tabs::kUpdateTabFunction] = - &NewExtensionFunction<UpdateTabFunction>; - factories_[tabs::kMoveTabFunction] = - &NewExtensionFunction<MoveTabFunction>; - factories_[tabs::kRemoveTabFunction] = - &NewExtensionFunction<RemoveTabFunction>; - factories_[tabs::kDetectTabLanguageFunction] = - &NewExtensionFunction<DetectTabLanguageFunction>; - factories_[tabs::kCaptureVisibleTabFunction] = - &NewExtensionFunction<CaptureVisibleTabFunction>; - factories_[tabs::kExecuteScriptFunction] = - &NewExtensionFunction<ExecuteCodeInTabFunction>; - factories_[tabs::kInsertCSSFunction] = - &NewExtensionFunction<ExecuteCodeInTabFunction>; + RegisterFunction<GetTabFunction>(); + RegisterFunction<GetSelectedTabFunction>(); + RegisterFunction<GetAllTabsInWindowFunction>(); + RegisterFunction<CreateTabFunction>(); + RegisterFunction<UpdateTabFunction>(); + RegisterFunction<MoveTabFunction>(); + RegisterFunction<RemoveTabFunction>(); + RegisterFunction<DetectTabLanguageFunction>(); + RegisterFunction<CaptureVisibleTabFunction>(); + RegisterFunction<TabsExecuteScriptFunction>(); + RegisterFunction<TabsInsertCSSFunction>(); // Page Actions. - factories_[page_actions::kEnablePageActionFunction] = - &NewExtensionFunction<EnablePageActionFunction>; - factories_[page_actions::kDisablePageActionFunction] = - &NewExtensionFunction<DisablePageActionFunction>; + RegisterFunction<EnablePageActionFunction>(); + RegisterFunction<DisablePageActionFunction>(); // Browser Actions. - factories_[browser_actions::kSetNameFunction] = - &NewExtensionFunction<BrowserActionSetNameFunction>; - factories_[browser_actions::kSetIconFunction] = - &NewExtensionFunction<BrowserActionSetIconFunction>; - factories_[browser_actions::kSetBadgeTextFunction] = - &NewExtensionFunction<BrowserActionSetBadgeTextFunction>; - factories_[browser_actions::kSetBadgeBackgroundColorFunction] = - &NewExtensionFunction<BrowserActionSetBadgeBackgroundColorFunction>; + RegisterFunction<BrowserActionSetNameFunction>(); + RegisterFunction<BrowserActionSetIconFunction>(); + RegisterFunction<BrowserActionSetBadgeTextFunction>(); + RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>(); // Bookmarks. - factories_[bookmarks::kGetBookmarksFunction] = - &NewExtensionFunction<GetBookmarksFunction>; - factories_[bookmarks::kGetBookmarkChildrenFunction] = - &NewExtensionFunction<GetBookmarkChildrenFunction>; - factories_[bookmarks::kGetBookmarkTreeFunction] = - &NewExtensionFunction<GetBookmarkTreeFunction>; - factories_[bookmarks::kSearchBookmarksFunction] = - &NewExtensionFunction<SearchBookmarksFunction>; - factories_[bookmarks::kRemoveBookmarkFunction] = - &NewExtensionFunction<RemoveBookmarkFunction>; - factories_[bookmarks::kRemoveBookmarkTreeFunction] = - &NewExtensionFunction<RemoveBookmarkFunction>; - factories_[bookmarks::kCreateBookmarkFunction] = - &NewExtensionFunction<CreateBookmarkFunction>; - factories_[bookmarks::kMoveBookmarkFunction] = - &NewExtensionFunction<MoveBookmarkFunction>; - factories_[bookmarks::kUpdateBookmarkFunction] = - &NewExtensionFunction<UpdateBookmarkFunction>; + RegisterFunction<GetBookmarksFunction>(); + RegisterFunction<GetBookmarkChildrenFunction>(); + RegisterFunction<GetBookmarkTreeFunction>(); + RegisterFunction<SearchBookmarksFunction>(); + RegisterFunction<RemoveBookmarkFunction>(); + RegisterFunction<RemoveTreeBookmarkFunction>(); + RegisterFunction<CreateBookmarkFunction>(); + RegisterFunction<MoveBookmarkFunction>(); + RegisterFunction<UpdateBookmarkFunction>(); // Toolstrips. - factories_[toolstrip::kExpandFunction] = - &NewExtensionFunction<ToolstripExpandFunction>; - factories_[toolstrip::kCollapseFunction] = - &NewExtensionFunction<ToolstripCollapseFunction>; + RegisterFunction<ToolstripExpandFunction>(); + RegisterFunction<ToolstripCollapseFunction>(); // I18N. - factories_[i18n::kGetAcceptLanguagesFunction] = - &NewExtensionFunction<GetAcceptLanguagesFunction>; + RegisterFunction<GetAcceptLanguagesFunction>(); // Test. - factories_[test::kPassFunction] = - &NewExtensionFunction<ExtensionTestPassFunction>; - factories_[test::kFailFunction] = - &NewExtensionFunction<ExtensionTestFailFunction>; - factories_[test::kLogFunction] = - &NewExtensionFunction<ExtensionTestLogFunction>; + RegisterFunction<ExtensionTestPassFunction>(); + RegisterFunction<ExtensionTestFailFunction>(); + RegisterFunction<ExtensionTestLogFunction>(); } void FactoryRegistry::GetAllNames(std::vector<std::string>* names) { diff --git a/chrome/browser/extensions/extension_i18n_api.cc b/chrome/browser/extensions/extension_i18n_api.cc index 01048e9..7629821 100644 --- a/chrome/browser/extensions/extension_i18n_api.cc +++ b/chrome/browser/extensions/extension_i18n_api.cc @@ -7,10 +7,6 @@ #include "chrome/browser/profile.h" #include "chrome/common/pref_names.h" -namespace extension_i18n_api_functions { - const char kGetAcceptLanguagesFunction[] = "i18n.getAcceptLanguages"; -} // namespace extension_i18n_api_functions - namespace { // Errors. const char kEmptyAcceptLanguagesError[] = "accept-languages is empty."; diff --git a/chrome/browser/extensions/extension_i18n_api.h b/chrome/browser/extensions/extension_i18n_api.h index 8fc18ac..b7e0cd9 100644 --- a/chrome/browser/extensions/extension_i18n_api.h +++ b/chrome/browser/extensions/extension_i18n_api.h @@ -7,12 +7,9 @@ #include "chrome/browser/extensions/extension_function.h" -namespace extension_i18n_api_functions { - extern const char kGetAcceptLanguagesFunction[]; -}; // namespace extension_i18n_api_functions - class GetAcceptLanguagesFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("i18n.getAcceptLanguages") }; #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_I18N_API_H__ diff --git a/chrome/browser/extensions/extension_page_actions_module.h b/chrome/browser/extensions/extension_page_actions_module.h index 48ed414..6a85cc3 100644 --- a/chrome/browser/extensions/extension_page_actions_module.h +++ b/chrome/browser/extensions/extension_page_actions_module.h @@ -14,10 +14,12 @@ class PageActionFunction : public SyncExtensionFunction { class EnablePageActionFunction : public PageActionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("pageActions.enableForTab") }; class DisablePageActionFunction : public PageActionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("pageActions.disableForTab") }; #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PAGE_ACTIONS_MODULE_H_ diff --git a/chrome/browser/extensions/extension_page_actions_module_constants.cc b/chrome/browser/extensions/extension_page_actions_module_constants.cc index cf43d78..48ceaae 100644 --- a/chrome/browser/extensions/extension_page_actions_module_constants.cc +++ b/chrome/browser/extensions/extension_page_actions_module_constants.cc @@ -17,7 +17,4 @@ 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[] = "pageActions.enableForTab"; -const char kDisablePageActionFunction[] = "pageActions.disableForTab"; - } // namespace extension_page_actions_module_constants diff --git a/chrome/browser/extensions/extension_page_actions_module_constants.h b/chrome/browser/extensions/extension_page_actions_module_constants.h index 0d31175..16556d6 100644 --- a/chrome/browser/extensions/extension_page_actions_module_constants.h +++ b/chrome/browser/extensions/extension_page_actions_module_constants.h @@ -22,10 +22,6 @@ extern const char kNoTabError[]; extern const char kNoPageActionError[]; extern const char kUrlNotActiveError[]; -// Function names. -extern const char kEnablePageActionFunction[]; -extern const char kDisablePageActionFunction[]; - }; // namespace extension_page_actions_module_constants #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PAGE_ACTIONS_MODULE_CONSTANTS_H_ diff --git a/chrome/browser/extensions/extension_tabs_module.h b/chrome/browser/extensions/extension_tabs_module.h index 0914758..05fdcf3 100644 --- a/chrome/browser/extensions/extension_tabs_module.h +++ b/chrome/browser/extensions/extension_tabs_module.h @@ -52,47 +52,61 @@ class ExtensionTabUtil { // Windows class GetWindowFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("windows.get") }; class GetCurrentWindowFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("windows.getCurrent") }; class GetLastFocusedWindowFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("windows.getLastFocused") }; class GetAllWindowsFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("windows.getAll") }; class CreateWindowFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("windows.create") }; class UpdateWindowFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("windows.update") }; class RemoveWindowFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("windows.remove") }; // Tabs class GetTabFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("tabs.get") }; class GetSelectedTabFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("tabs.getSelected") }; class GetAllTabsInWindowFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("tabs.getAllInWindow") }; class CreateTabFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("tabs.create") }; class UpdateTabFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("tabs.update") }; class MoveTabFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("tabs.move") }; class RemoveTabFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("tabs.remove") }; class DetectTabLanguageFunction : public AsyncExtensionFunction, public NotificationObserver { @@ -103,9 +117,11 @@ class DetectTabLanguageFunction : public AsyncExtensionFunction, const NotificationSource& source, const NotificationDetails& details); NotificationRegistrar registrar_; + DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage") }; class CaptureVisibleTabFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("tabs.captureVisibleTab") }; #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__ diff --git a/chrome/browser/extensions/extension_tabs_module_constants.cc b/chrome/browser/extensions/extension_tabs_module_constants.cc index 8c9e153..dac399f3 100644 --- a/chrome/browser/extensions/extension_tabs_module_constants.cc +++ b/chrome/browser/extensions/extension_tabs_module_constants.cc @@ -46,26 +46,6 @@ const char kCannotAccessPageError[] = "Cannot access contents of url \"*\". " "Extension manifest must request permission to access this host."; const char kSupportedInWindowsOnlyError[] = "Supported in Windows only"; -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"; -const char kCaptureVisibleTabFunction[] = "tabs.captureVisibleTab"; - -const char kExecuteScriptFunction[] = "tabs.executeScript"; -const char kInsertCSSFunction[] = "tabs.insertCSS"; const char kNoCodeOrFileToExecuteError[] = "No source code or file specified."; const char kMoreThanOneValuesError[] = "There should be only one value (either" "code or file) in the second argument."; diff --git a/chrome/browser/extensions/extension_tabs_module_constants.h b/chrome/browser/extensions/extension_tabs_module_constants.h index cfb3412..6e0967d 100644 --- a/chrome/browser/extensions/extension_tabs_module_constants.h +++ b/chrome/browser/extensions/extension_tabs_module_constants.h @@ -50,27 +50,6 @@ extern const char kNotImplementedError[]; extern const char kCannotAccessPageError[]; extern const char kSupportedInWindowsOnlyError[]; -// Function names, Windows API. -extern const char kGetWindowFunction[]; -extern const char kGetCurrentWindowFunction[]; -extern const char kGetLastFocusedWindowFunction[]; -extern const char kGetAllWindowsFunction[]; -extern const char kCreateWindowFunction[]; -extern const char kUpdateWindowFunction[]; -extern const char kRemoveWindowFunction[]; - -// Function names, Tabs API. -extern const char kGetTabFunction[]; -extern const char kGetSelectedTabFunction[]; -extern const char kGetAllTabsInWindowFunction[]; -extern const char kCreateTabFunction[]; -extern const char kUpdateTabFunction[]; -extern const char kMoveTabFunction[]; -extern const char kRemoveTabFunction[]; -extern const char kDetectTabLanguageFunction[]; -extern const char kCaptureVisibleTabFunction[]; -extern const char kExecuteScriptFunction[]; -extern const char kInsertCSSFunction[]; extern const char kNoCodeOrFileToExecuteError[]; extern const char kMoreThanOneValuesError[]; extern const char kLoadFileError[]; diff --git a/chrome/browser/extensions/extension_test_api.cc b/chrome/browser/extensions/extension_test_api.cc index ef4cb16..e3354e4 100644 --- a/chrome/browser/extensions/extension_test_api.cc +++ b/chrome/browser/extensions/extension_test_api.cc @@ -5,12 +5,6 @@ #include "chrome/browser/extensions/extension_test_api.h" #include "chrome/common/notification_service.h" -namespace extension_test_api_functions { -const char kPassFunction[] = "test.notifyPass"; -const char kFailFunction[] = "test.notifyFail"; -const char kLogFunction[] = "test.log"; -}; // namespace extension_test_api_functions - bool ExtensionTestPassFunction::RunImpl() { NotificationService::current()->Notify( NotificationType::EXTENSION_TEST_PASSED, diff --git a/chrome/browser/extensions/extension_test_api.h b/chrome/browser/extensions/extension_test_api.h index 77096e5..6ab6857 100644 --- a/chrome/browser/extensions/extension_test_api.h +++ b/chrome/browser/extensions/extension_test_api.h @@ -7,23 +7,19 @@ #include "chrome/browser/extensions/extension_function.h" -// Function names. -namespace extension_test_api_functions { - extern const char kPassFunction[]; - extern const char kFailFunction[]; - extern const char kLogFunction[]; -}; // namespace extension_test_api_functions - class ExtensionTestPassFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("test.notifyPass") }; class ExtensionTestFailFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("test.notifyFail") }; class ExtensionTestLogFunction : public SyncExtensionFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("test.log") }; #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_ diff --git a/chrome/browser/extensions/extension_toolstrip_api.cc b/chrome/browser/extensions/extension_toolstrip_api.cc index 492c730..58950ae 100644 --- a/chrome/browser/extensions/extension_toolstrip_api.cc +++ b/chrome/browser/extensions/extension_toolstrip_api.cc @@ -13,11 +13,6 @@ #include "chrome/browser/extensions/extension_tabs_module_constants.h" #include "chrome/browser/profile.h" -namespace extension_toolstrip_api_functions { -const char kExpandFunction[] = "toolstrip.expand"; -const char kCollapseFunction[] = "toolstrip.collapse"; -}; // namespace extension_toolstrip_api_functions - namespace extension_toolstrip_api_events { const char kOnToolstripExpanded[] = "toolstrip.onExpanded.%d"; const char kOnToolstripCollapsed[] = "toolstrip.onCollapsed.%d"; diff --git a/chrome/browser/extensions/extension_toolstrip_api.h b/chrome/browser/extensions/extension_toolstrip_api.h index a21e627..6f648bb 100644 --- a/chrome/browser/extensions/extension_toolstrip_api.h +++ b/chrome/browser/extensions/extension_toolstrip_api.h @@ -10,12 +10,6 @@ class Profile; -// Function names. -namespace extension_toolstrip_api_functions { - extern const char kExpandFunction[]; - extern const char kCollapseFunction[]; -}; // namespace extension_toolstrip_api_functions - namespace extension_toolstrip_api_events { extern const char kOnToolstripExpanded[]; extern const char kOnToolstripCollapsed[]; @@ -31,10 +25,12 @@ class ToolstripFunction : public SyncExtensionFunction { class ToolstripExpandFunction : public ToolstripFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("toolstrip.expand") }; class ToolstripCollapseFunction : public ToolstripFunction { virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("toolstrip.collapse") }; class ToolstripEventRouter { |