[email protected] | e0813a39 | 2011-02-01 22:57:25 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 6 | |
[email protected] | 745feedb | 2010-08-02 04:08:07 | [diff] [blame] | 7 | #include <map> |
| 8 | |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
| 10 | #include "base/memory/singleton.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 11 | #include "base/process_util.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 12 | #include "base/values.h" |
[email protected] | 17d40f0 | 2010-07-01 01:18:06 | [diff] [blame] | 13 | #include "build/build_config.h" |
[email protected] | 23d5f17 | 2011-10-25 05:49:53 | [diff] [blame] | 14 | #include "chrome/browser/bookmarks/bookmark_extension_api.h" |
| 15 | #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h" |
[email protected] | 912256b3 | 2009-09-18 09:47:35 | [diff] [blame] | 16 | #include "chrome/browser/extensions/execute_code_in_tab_function.h" |
[email protected] | 5cbe1e2 | 2010-01-30 01:18:56 | [diff] [blame] | 17 | #include "chrome/browser/extensions/extension_accessibility_api.h" |
[email protected] | c1d05aa | 2011-06-28 02:07:30 | [diff] [blame] | 18 | #include "chrome/browser/extensions/extension_app_api.h" |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 19 | #include "chrome/browser/extensions/extension_browser_actions_api.h" |
[email protected] | 6093d74 | 2011-08-26 16:37:18 | [diff] [blame] | 20 | #include "chrome/browser/extensions/extension_clear_api.h" |
[email protected] | 6a16dc9b | 2011-10-17 18:28:16 | [diff] [blame] | 21 | #include "chrome/browser/extensions/extension_clipboard_api.h" |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 22 | #include "chrome/browser/extensions/extension_chrome_auth_private_api.h" |
[email protected] | fa062426 | 2011-06-09 14:17:38 | [diff] [blame] | 23 | #include "chrome/browser/extensions/extension_content_settings_api.h" |
[email protected] | 2e3b520 | 2010-03-23 06:52:41 | [diff] [blame] | 24 | #include "chrome/browser/extensions/extension_context_menu_api.h" |
[email protected] | 898bbd3 | 2010-05-18 18:52:29 | [diff] [blame] | 25 | #include "chrome/browser/extensions/extension_cookies_api.h" |
[email protected] | 91ba331 | 2011-03-17 20:39:22 | [diff] [blame] | 26 | #include "chrome/browser/extensions/extension_debugger_api.h" |
[email protected] | 21d7a4e30 | 2011-08-15 16:17:12 | [diff] [blame] | 27 | #include "chrome/browser/extensions/extension_downloads_api.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 28 | #include "chrome/browser/extensions/extension_function.h" |
[email protected] | 2bb5130 | 2011-02-18 22:39:27 | [diff] [blame] | 29 | #include "chrome/browser/extensions/extension_i18n_api.h" |
[email protected] | 2f69b38 | 2011-02-19 00:34:25 | [diff] [blame] | 30 | #include "chrome/browser/extensions/extension_idle_api.h" |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 31 | #include "chrome/browser/extensions/extension_management_api.h" |
[email protected] | 438772df | 2010-02-26 18:08:43 | [diff] [blame] | 32 | #include "chrome/browser/extensions/extension_metrics_module.h" |
[email protected] | a65882c | 2010-11-12 15:15:09 | [diff] [blame] | 33 | #include "chrome/browser/extensions/extension_module.h" |
[email protected] | 56ad379 | 2010-05-28 17:45:33 | [diff] [blame] | 34 | #include "chrome/browser/extensions/extension_omnibox_api.h" |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 35 | #include "chrome/browser/extensions/extension_page_actions_module.h" |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 36 | #include "chrome/browser/extensions/extension_permissions_api.h" |
[email protected] | 598bbcc | 2011-02-24 10:03:25 | [diff] [blame] | 37 | #include "chrome/browser/extensions/extension_preference_api.h" |
[email protected] | 381162b | 2010-01-28 17:29:35 | [diff] [blame] | 38 | #include "chrome/browser/extensions/extension_processes_api.h" |
[email protected] | a9c23a5 | 2010-08-04 09:13:44 | [diff] [blame] | 39 | #include "chrome/browser/extensions/extension_proxy_api.h" |
[email protected] | 3a605e8 | 2011-09-26 17:26:16 | [diff] [blame] | 40 | #include "chrome/browser/extensions/extension_save_page_api.h" |
[email protected] | 2f69b38 | 2011-02-19 00:34:25 | [diff] [blame] | 41 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 42 | #include "chrome/browser/extensions/extension_settings_api.h" |
[email protected] | 8b8e7c9 | 2010-08-19 18:05:56 | [diff] [blame] | 43 | #include "chrome/browser/extensions/extension_sidebar_api.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 44 | #include "chrome/browser/extensions/extension_tabs_module.h" |
[email protected] | 25fd1b2e | 2009-08-17 20:57:14 | [diff] [blame] | 45 | #include "chrome/browser/extensions/extension_test_api.h" |
[email protected] | 8abe0a3 | 2010-08-12 00:40:22 | [diff] [blame] | 46 | #include "chrome/browser/extensions/extension_tts_api.h" |
[email protected] | c63f2b7 | 2011-07-07 05:25:00 | [diff] [blame] | 47 | #include "chrome/browser/extensions/extension_tts_engine_api.h" |
[email protected] | c6e584c | 2011-05-18 11:58:44 | [diff] [blame] | 48 | #include "chrome/browser/extensions/extension_web_socket_proxy_private_api.h" |
[email protected] | 8f9d4eb | 2011-02-05 01:39:10 | [diff] [blame] | 49 | #include "chrome/browser/extensions/extension_web_ui.h" |
[email protected] | 557a51dd | 2011-07-26 12:17:11 | [diff] [blame] | 50 | #include "chrome/browser/extensions/extension_webnavigation_api.h" |
[email protected] | c41fe66 | 2011-02-15 01:19:26 | [diff] [blame] | 51 | #include "chrome/browser/extensions/extension_webrequest_api.h" |
[email protected] | 63cda0c | 2010-09-01 04:41:23 | [diff] [blame] | 52 | #include "chrome/browser/extensions/extension_webstore_private_api.h" |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 53 | #include "chrome/browser/extensions/extensions_quota_service.h" |
[email protected] | 7c216711 | 2011-10-13 10:48:16 | [diff] [blame] | 54 | #include "chrome/browser/extensions/speech_input/extension_speech_input_api.h" |
[email protected] | ed2b100 | 2011-05-25 14:12:10 | [diff] [blame] | 55 | #include "chrome/browser/external_protocol/external_protocol_handler.h" |
[email protected] | c583f5f | 2011-10-24 17:03:52 | [diff] [blame] | 56 | #include "chrome/browser/infobars/infobar_extension_api.h" |
[email protected] | d2e6bd6 | 2011-10-24 20:29:07 | [diff] [blame] | 57 | #include "chrome/browser/history/history_extension_api.h" |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 58 | #include "chrome/browser/history/top_sites_extension_api.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 59 | #include "chrome/browser/profiles/profile.h" |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 60 | #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
[email protected] | 792556c | 2011-10-25 05:01:07 | [diff] [blame] | 61 | #include "chrome/browser/rlz/rlz_extension_api.h" |
[email protected] | 71b73f0 | 2011-04-06 15:57:29 | [diff] [blame] | 62 | #include "chrome/browser/ui/browser_list.h" |
[email protected] | 00070c73 | 2011-04-09 15:31:33 | [diff] [blame] | 63 | #include "chrome/browser/ui/browser_window.h" |
[email protected] | 44c49c9 | 2011-03-28 16:17:23 | [diff] [blame] | 64 | #include "chrome/common/extensions/extension_messages.h" |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 65 | #include "chrome/common/url_constants.h" |
[email protected] | 5de63471 | 2011-03-02 00:20:19 | [diff] [blame] | 66 | #include "content/browser/renderer_host/render_process_host.h" |
| 67 | #include "content/browser/renderer_host/render_view_host.h" |
[email protected] | f82d57b5 | 2011-04-27 19:13:17 | [diff] [blame] | 68 | #include "ipc/ipc_message.h" |
| 69 | #include "ipc/ipc_message_macros.h" |
[email protected] | 939856a | 2010-08-24 20:29:02 | [diff] [blame] | 70 | #include "third_party/skia/include/core/SkBitmap.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 71 | |
[email protected] | 8f9d4eb | 2011-02-05 01:39:10 | [diff] [blame] | 72 | #if defined(TOOLKIT_VIEWS) |
| 73 | #include "chrome/browser/extensions/extension_input_api.h" |
| 74 | #endif |
[email protected] | d683385 | 2010-08-20 18:00:45 | [diff] [blame] | 75 | |
[email protected] | 27072cad | 2011-05-09 19:46:40 | [diff] [blame] | 76 | #if defined(OS_CHROMEOS) && defined(TOUCH_UI) |
| 77 | #include "chrome/browser/extensions/extension_input_ui_api.h" |
| 78 | #endif |
| 79 | |
[email protected] | 61b55b6 | 2011-03-24 09:03:10 | [diff] [blame] | 80 | #if defined(OS_CHROMEOS) |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 81 | #include "chrome/browser/extensions/extension_file_browser_private_api.h" |
[email protected] | 61b55b6 | 2011-03-24 09:03:10 | [diff] [blame] | 82 | #include "chrome/browser/extensions/extension_info_private_api_chromeos.h" |
[email protected] | 14da67b0 | 2011-08-02 05:49:13 | [diff] [blame] | 83 | #include "chrome/browser/extensions/extension_input_ime_api.h" |
[email protected] | be5bd574 | 2011-07-14 07:21:01 | [diff] [blame] | 84 | #include "chrome/browser/extensions/extension_input_method_api.h" |
[email protected] | ce980204 | 2011-05-27 10:11:40 | [diff] [blame] | 85 | #include "chrome/browser/extensions/extension_mediaplayer_private_api.h" |
[email protected] | 61b55b6 | 2011-03-24 09:03:10 | [diff] [blame] | 86 | #endif |
| 87 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 88 | // FactoryRegistry ------------------------------------------------------------- |
| 89 | |
| 90 | namespace { |
| 91 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 92 | // Template for defining ExtensionFunctionFactory. |
| 93 | template<class T> |
| 94 | ExtensionFunction* NewExtensionFunction() { |
| 95 | return new T(); |
| 96 | } |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 97 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 98 | // Contains a list of all known extension functions and allows clients to |
| 99 | // create instances of them. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 100 | class FactoryRegistry { |
| 101 | public: |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 102 | static FactoryRegistry* GetInstance(); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 103 | FactoryRegistry() { ResetFunctions(); } |
| 104 | |
| 105 | // Resets all functions to their default values. |
| 106 | void ResetFunctions(); |
| 107 | |
| 108 | // Adds all function names to 'names'. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 109 | void GetAllNames(std::vector<std::string>* names); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 110 | |
| 111 | // Allows overriding of specific functions (e.g. for testing). Functions |
| 112 | // must be previously registered. Returns true if successful. |
| 113 | bool OverrideFunction(const std::string& name, |
| 114 | ExtensionFunctionFactory factory); |
| 115 | |
| 116 | // Factory method for the ExtensionFunction registered as 'name'. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 117 | ExtensionFunction* NewFunction(const std::string& name); |
| 118 | |
| 119 | private: |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 120 | template<class T> |
| 121 | void RegisterFunction() { |
| 122 | factories_[T::function_name()] = &NewExtensionFunction<T>; |
| 123 | } |
| 124 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 125 | typedef std::map<std::string, ExtensionFunctionFactory> FactoryMap; |
| 126 | FactoryMap factories_; |
| 127 | }; |
| 128 | |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 129 | FactoryRegistry* FactoryRegistry::GetInstance() { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 130 | return Singleton<FactoryRegistry>::get(); |
| 131 | } |
| 132 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 133 | void FactoryRegistry::ResetFunctions() { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 134 | // Register all functions here. |
| 135 | |
[email protected] | e515f5d | 2009-05-05 03:05:00 | [diff] [blame] | 136 | // Windows |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 137 | RegisterFunction<GetWindowFunction>(); |
| 138 | RegisterFunction<GetCurrentWindowFunction>(); |
| 139 | RegisterFunction<GetLastFocusedWindowFunction>(); |
| 140 | RegisterFunction<GetAllWindowsFunction>(); |
| 141 | RegisterFunction<CreateWindowFunction>(); |
| 142 | RegisterFunction<UpdateWindowFunction>(); |
| 143 | RegisterFunction<RemoveWindowFunction>(); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 144 | |
[email protected] | e515f5d | 2009-05-05 03:05:00 | [diff] [blame] | 145 | // Tabs |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 146 | RegisterFunction<GetTabFunction>(); |
[email protected] | e3eafb29 | 2010-04-14 21:30:41 | [diff] [blame] | 147 | RegisterFunction<GetCurrentTabFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 148 | RegisterFunction<GetSelectedTabFunction>(); |
| 149 | RegisterFunction<GetAllTabsInWindowFunction>(); |
[email protected] | 8c3495c | 2011-09-28 03:32:30 | [diff] [blame] | 150 | RegisterFunction<QueryTabsFunction>(); |
| 151 | RegisterFunction<HighlightTabsFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 152 | RegisterFunction<CreateTabFunction>(); |
| 153 | RegisterFunction<UpdateTabFunction>(); |
[email protected] | 8c3495c | 2011-09-28 03:32:30 | [diff] [blame] | 154 | RegisterFunction<MoveTabsFunction>(); |
[email protected] | 5d93511 | 2011-09-07 09:24:54 | [diff] [blame] | 155 | RegisterFunction<ReloadTabFunction>(); |
[email protected] | 8c3495c | 2011-09-28 03:32:30 | [diff] [blame] | 156 | RegisterFunction<RemoveTabsFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 157 | RegisterFunction<DetectTabLanguageFunction>(); |
| 158 | RegisterFunction<CaptureVisibleTabFunction>(); |
| 159 | RegisterFunction<TabsExecuteScriptFunction>(); |
| 160 | RegisterFunction<TabsInsertCSSFunction>(); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 161 | |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 162 | // Page Actions. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 163 | RegisterFunction<EnablePageActionFunction>(); |
| 164 | RegisterFunction<DisablePageActionFunction>(); |
[email protected] | 744ef17 | 2009-10-16 21:53:46 | [diff] [blame] | 165 | RegisterFunction<PageActionShowFunction>(); |
| 166 | RegisterFunction<PageActionHideFunction>(); |
| 167 | RegisterFunction<PageActionSetIconFunction>(); |
| 168 | RegisterFunction<PageActionSetTitleFunction>(); |
[email protected] | e478d670 | 2010-01-28 00:10:29 | [diff] [blame] | 169 | RegisterFunction<PageActionSetPopupFunction>(); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 170 | |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 171 | // Browser Actions. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 172 | RegisterFunction<BrowserActionSetIconFunction>(); |
[email protected] | 1288ba0 | 2009-10-15 00:02:24 | [diff] [blame] | 173 | RegisterFunction<BrowserActionSetTitleFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 174 | RegisterFunction<BrowserActionSetBadgeTextFunction>(); |
| 175 | RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>(); |
[email protected] | 85ae959 | 2010-02-03 20:58:50 | [diff] [blame] | 176 | RegisterFunction<BrowserActionSetPopupFunction>(); |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 177 | |
[email protected] | 6093d74 | 2011-08-26 16:37:18 | [diff] [blame] | 178 | // Browsing Data. |
| 179 | RegisterFunction<ClearBrowsingDataFunction>(); |
| 180 | RegisterFunction<ClearCacheFunction>(); |
| 181 | RegisterFunction<ClearCookiesFunction>(); |
| 182 | RegisterFunction<ClearDownloadsFunction>(); |
| 183 | RegisterFunction<ClearFormDataFunction>(); |
| 184 | RegisterFunction<ClearHistoryFunction>(); |
| 185 | RegisterFunction<ClearPasswordsFunction>(); |
| 186 | |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 187 | // Bookmarks. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 188 | RegisterFunction<GetBookmarksFunction>(); |
| 189 | RegisterFunction<GetBookmarkChildrenFunction>(); |
[email protected] | a3c94c71 | 2009-12-18 19:23:55 | [diff] [blame] | 190 | RegisterFunction<GetBookmarkRecentFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 191 | RegisterFunction<GetBookmarkTreeFunction>(); |
[email protected] | 532a8c6 | 2011-06-03 21:30:01 | [diff] [blame] | 192 | RegisterFunction<GetBookmarkSubTreeFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 193 | RegisterFunction<SearchBookmarksFunction>(); |
| 194 | RegisterFunction<RemoveBookmarkFunction>(); |
| 195 | RegisterFunction<RemoveTreeBookmarkFunction>(); |
| 196 | RegisterFunction<CreateBookmarkFunction>(); |
| 197 | RegisterFunction<MoveBookmarkFunction>(); |
| 198 | RegisterFunction<UpdateBookmarkFunction>(); |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 199 | |
[email protected] | f34e7963 | 2010-03-17 02:34:08 | [diff] [blame] | 200 | // Infobars. |
| 201 | RegisterFunction<ShowInfoBarFunction>(); |
| 202 | |
[email protected] | 9dd97bc | 2010-01-14 01:40:04 | [diff] [blame] | 203 | // BookmarkManager |
| 204 | RegisterFunction<CopyBookmarkManagerFunction>(); |
| 205 | RegisterFunction<CutBookmarkManagerFunction>(); |
| 206 | RegisterFunction<PasteBookmarkManagerFunction>(); |
[email protected] | 03b3bbf | 2010-01-29 23:54:57 | [diff] [blame] | 207 | RegisterFunction<CanPasteBookmarkManagerFunction>(); |
[email protected] | cb6cf79 | 2010-01-28 00:04:56 | [diff] [blame] | 208 | RegisterFunction<ImportBookmarksFunction>(); |
| 209 | RegisterFunction<ExportBookmarksFunction>(); |
[email protected] | d406e2e | 2010-01-30 21:45:18 | [diff] [blame] | 210 | RegisterFunction<SortChildrenBookmarkManagerFunction>(); |
[email protected] | 9dd97bc | 2010-01-14 01:40:04 | [diff] [blame] | 211 | RegisterFunction<BookmarkManagerGetStringsFunction>(); |
[email protected] | ced90ae1 | 2010-02-20 02:06:16 | [diff] [blame] | 212 | RegisterFunction<StartDragBookmarkManagerFunction>(); |
| 213 | RegisterFunction<DropBookmarkManagerFunction>(); |
[email protected] | 9b07185 | 2010-04-02 06:45:31 | [diff] [blame] | 214 | RegisterFunction<GetSubtreeBookmarkManagerFunction>(); |
[email protected] | 933ebbe | 2011-06-30 12:24:01 | [diff] [blame] | 215 | RegisterFunction<CanEditBookmarkManagerFunction>(); |
[email protected] | 9dd97bc | 2010-01-14 01:40:04 | [diff] [blame] | 216 | |
[email protected] | de768a83 | 2009-10-30 05:25:01 | [diff] [blame] | 217 | // History |
| 218 | RegisterFunction<AddUrlHistoryFunction>(); |
| 219 | RegisterFunction<DeleteAllHistoryFunction>(); |
| 220 | RegisterFunction<DeleteRangeHistoryFunction>(); |
| 221 | RegisterFunction<DeleteUrlHistoryFunction>(); |
| 222 | RegisterFunction<GetVisitsHistoryFunction>(); |
| 223 | RegisterFunction<SearchHistoryFunction>(); |
| 224 | |
[email protected] | f520541 | 2010-03-16 00:19:34 | [diff] [blame] | 225 | // Idle |
| 226 | RegisterFunction<ExtensionIdleQueryStateFunction>(); |
| 227 | |
[email protected] | 198bcfe | 2009-09-09 22:56:28 | [diff] [blame] | 228 | // I18N. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 229 | RegisterFunction<GetAcceptLanguagesFunction>(); |
[email protected] | 198bcfe | 2009-09-09 22:56:28 | [diff] [blame] | 230 | |
[email protected] | 381162b | 2010-01-28 17:29:35 | [diff] [blame] | 231 | // Processes. |
[email protected] | 8a661f8 | 2010-10-19 21:47:11 | [diff] [blame] | 232 | RegisterFunction<GetProcessIdForTabFunction>(); |
[email protected] | 381162b | 2010-01-28 17:29:35 | [diff] [blame] | 233 | |
[email protected] | 438772df | 2010-02-26 18:08:43 | [diff] [blame] | 234 | // Metrics. |
[email protected] | e93d2d0 | 2011-01-12 21:41:03 | [diff] [blame] | 235 | RegisterFunction<MetricsGetEnabledFunction>(); |
| 236 | RegisterFunction<MetricsSetEnabledFunction>(); |
[email protected] | cf25e4d | 2010-03-12 21:19:34 | [diff] [blame] | 237 | RegisterFunction<MetricsRecordUserActionFunction>(); |
| 238 | RegisterFunction<MetricsRecordValueFunction>(); |
| 239 | RegisterFunction<MetricsRecordPercentageFunction>(); |
| 240 | RegisterFunction<MetricsRecordCountFunction>(); |
| 241 | RegisterFunction<MetricsRecordSmallCountFunction>(); |
| 242 | RegisterFunction<MetricsRecordMediumCountFunction>(); |
| 243 | RegisterFunction<MetricsRecordTimeFunction>(); |
| 244 | RegisterFunction<MetricsRecordMediumTimeFunction>(); |
| 245 | RegisterFunction<MetricsRecordLongTimeFunction>(); |
[email protected] | 438772df | 2010-02-26 18:08:43 | [diff] [blame] | 246 | |
[email protected] | 17d40f0 | 2010-07-01 01:18:06 | [diff] [blame] | 247 | // RLZ. |
| 248 | #if defined(OS_WIN) |
| 249 | RegisterFunction<RlzRecordProductEventFunction>(); |
| 250 | RegisterFunction<RlzGetAccessPointRlzFunction>(); |
[email protected] | 3a612be | 2010-07-17 03:11:21 | [diff] [blame] | 251 | RegisterFunction<RlzSendFinancialPingFunction>(); |
[email protected] | 17d40f0 | 2010-07-01 01:18:06 | [diff] [blame] | 252 | RegisterFunction<RlzClearProductStateFunction>(); |
| 253 | #endif |
| 254 | |
[email protected] | 898bbd3 | 2010-05-18 18:52:29 | [diff] [blame] | 255 | // Cookies. |
| 256 | RegisterFunction<GetCookieFunction>(); |
| 257 | RegisterFunction<GetAllCookiesFunction>(); |
| 258 | RegisterFunction<SetCookieFunction>(); |
| 259 | RegisterFunction<RemoveCookieFunction>(); |
| 260 | RegisterFunction<GetAllCookieStoresFunction>(); |
| 261 | |
[email protected] | 25fd1b2e | 2009-08-17 20:57:14 | [diff] [blame] | 262 | // Test. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 263 | RegisterFunction<ExtensionTestPassFunction>(); |
| 264 | RegisterFunction<ExtensionTestFailFunction>(); |
| 265 | RegisterFunction<ExtensionTestLogFunction>(); |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 266 | RegisterFunction<ExtensionTestQuotaResetFunction>(); |
[email protected] | db7331a | 2010-02-25 22:10:50 | [diff] [blame] | 267 | RegisterFunction<ExtensionTestCreateIncognitoTabFunction>(); |
[email protected] | 745feedb | 2010-08-02 04:08:07 | [diff] [blame] | 268 | RegisterFunction<ExtensionTestSendMessageFunction>(); |
[email protected] | 761e716 | 2010-10-18 19:26:39 | [diff] [blame] | 269 | RegisterFunction<ExtensionTestGetConfigFunction>(); |
[email protected] | 5cbe1e2 | 2010-01-30 01:18:56 | [diff] [blame] | 270 | |
| 271 | // Accessibility. |
| 272 | RegisterFunction<GetFocusedControlFunction>(); |
| 273 | RegisterFunction<SetAccessibilityEnabledFunction>(); |
[email protected] | 44625595 | 2010-03-17 20:41:58 | [diff] [blame] | 274 | |
[email protected] | 8abe0a3 | 2010-08-12 00:40:22 | [diff] [blame] | 275 | // Text-to-speech. |
[email protected] | c63f2b7 | 2011-07-07 05:25:00 | [diff] [blame] | 276 | RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>(); |
| 277 | RegisterFunction<ExtensionTtsGetVoicesFunction>(); |
| 278 | RegisterFunction<ExtensionTtsIsSpeakingFunction>(); |
[email protected] | 8abe0a3 | 2010-08-12 00:40:22 | [diff] [blame] | 279 | RegisterFunction<ExtensionTtsSpeakFunction>(); |
| 280 | RegisterFunction<ExtensionTtsStopSpeakingFunction>(); |
[email protected] | 8abe0a3 | 2010-08-12 00:40:22 | [diff] [blame] | 281 | |
[email protected] | 2e3b520 | 2010-03-23 06:52:41 | [diff] [blame] | 282 | // Context Menus. |
| 283 | RegisterFunction<CreateContextMenuFunction>(); |
[email protected] | 66dbfb2c | 2010-05-12 20:20:15 | [diff] [blame] | 284 | RegisterFunction<UpdateContextMenuFunction>(); |
[email protected] | 2e3b520 | 2010-03-23 06:52:41 | [diff] [blame] | 285 | RegisterFunction<RemoveContextMenuFunction>(); |
[email protected] | 66dbfb2c | 2010-05-12 20:20:15 | [diff] [blame] | 286 | RegisterFunction<RemoveAllContextMenusFunction>(); |
[email protected] | 56ad379 | 2010-05-28 17:45:33 | [diff] [blame] | 287 | |
| 288 | // Omnibox. |
| 289 | RegisterFunction<OmniboxSendSuggestionsFunction>(); |
[email protected] | 1bead071 | 2010-11-27 17:41:53 | [diff] [blame] | 290 | RegisterFunction<OmniboxSetDefaultSuggestionFunction>(); |
[email protected] | a9c23a5 | 2010-08-04 09:13:44 | [diff] [blame] | 291 | |
[email protected] | 8b8e7c9 | 2010-08-19 18:05:56 | [diff] [blame] | 292 | // Sidebar. |
| 293 | RegisterFunction<CollapseSidebarFunction>(); |
| 294 | RegisterFunction<ExpandSidebarFunction>(); |
| 295 | RegisterFunction<GetStateSidebarFunction>(); |
| 296 | RegisterFunction<HideSidebarFunction>(); |
| 297 | RegisterFunction<NavigateSidebarFunction>(); |
| 298 | RegisterFunction<SetBadgeTextSidebarFunction>(); |
| 299 | RegisterFunction<SetIconSidebarFunction>(); |
| 300 | RegisterFunction<SetTitleSidebarFunction>(); |
| 301 | RegisterFunction<ShowSidebarFunction>(); |
[email protected] | d683385 | 2010-08-20 18:00:45 | [diff] [blame] | 302 | |
[email protected] | e06a1fe | 2011-09-29 21:20:44 | [diff] [blame] | 303 | // Speech input. |
| 304 | RegisterFunction<StartSpeechInputFunction>(); |
| 305 | RegisterFunction<StopSpeechInputFunction>(); |
| 306 | RegisterFunction<IsRecordingSpeechInputFunction>(); |
| 307 | |
[email protected] | d683385 | 2010-08-20 18:00:45 | [diff] [blame] | 308 | #if defined(TOOLKIT_VIEWS) |
| 309 | // Input. |
| 310 | RegisterFunction<SendKeyboardEventInputFunction>(); |
| 311 | #endif |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 312 | |
[email protected] | 2cc81d3 | 2011-10-04 17:03:18 | [diff] [blame] | 313 | #if defined(USE_VIRTUAL_KEYBOARD) |
[email protected] | bcde748 | 2011-05-23 19:29:12 | [diff] [blame] | 314 | RegisterFunction<HideKeyboardFunction>(); |
[email protected] | 3c8faef | 2011-06-09 22:56:51 | [diff] [blame] | 315 | RegisterFunction<SetKeyboardHeightFunction>(); |
[email protected] | bcde748 | 2011-05-23 19:29:12 | [diff] [blame] | 316 | #endif |
| 317 | |
[email protected] | 14da67b0 | 2011-08-02 05:49:13 | [diff] [blame] | 318 | #if defined(OS_CHROMEOS) |
[email protected] | 27072cad | 2011-05-09 19:46:40 | [diff] [blame] | 319 | // IME |
[email protected] | 14da67b0 | 2011-08-02 05:49:13 | [diff] [blame] | 320 | RegisterFunction<SetCompositionFunction>(); |
| 321 | RegisterFunction<ClearCompositionFunction>(); |
| 322 | RegisterFunction<CommitTextFunction>(); |
| 323 | RegisterFunction<SetCandidateWindowPropertiesFunction>(); |
| 324 | RegisterFunction<SetCandidatesFunction>(); |
| 325 | RegisterFunction<SetCursorPositionFunction>(); |
| 326 | RegisterFunction<SetMenuItemsFunction>(); |
| 327 | RegisterFunction<UpdateMenuItemsFunction>(); |
[email protected] | cd0b04c9 | 2011-09-08 05:18:06 | [diff] [blame] | 328 | |
| 329 | RegisterFunction<InputEventHandled>(); |
[email protected] | 14da67b0 | 2011-08-02 05:49:13 | [diff] [blame] | 330 | #if defined(TOUCH_UI) |
[email protected] | 27072cad | 2011-05-09 19:46:40 | [diff] [blame] | 331 | RegisterFunction<CandidateClickedInputUiFunction>(); |
| 332 | RegisterFunction<CursorUpInputUiFunction>(); |
| 333 | RegisterFunction<CursorDownInputUiFunction>(); |
| 334 | RegisterFunction<PageUpInputUiFunction>(); |
| 335 | RegisterFunction<PageDownInputUiFunction>(); |
| 336 | RegisterFunction<RegisterInputUiFunction>(); |
| 337 | RegisterFunction<PageUpInputUiFunction>(); |
| 338 | RegisterFunction<PageDownInputUiFunction>(); |
| 339 | #endif |
[email protected] | 14da67b0 | 2011-08-02 05:49:13 | [diff] [blame] | 340 | #endif |
[email protected] | 27072cad | 2011-05-09 19:46:40 | [diff] [blame] | 341 | |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 342 | // Management. |
| 343 | RegisterFunction<GetAllExtensionsFunction>(); |
[email protected] | e78543c | 2010-11-08 22:05:23 | [diff] [blame] | 344 | RegisterFunction<GetExtensionByIdFunction>(); |
[email protected] | 925a54d | 2011-07-29 17:21:00 | [diff] [blame] | 345 | RegisterFunction<GetPermissionWarningsByIdFunction>(); |
| 346 | RegisterFunction<GetPermissionWarningsByManifestFunction>(); |
[email protected] | e558ff8 | 2010-09-23 20:19:56 | [diff] [blame] | 347 | RegisterFunction<LaunchAppFunction>(); |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 348 | RegisterFunction<SetEnabledFunction>(); |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 349 | RegisterFunction<UninstallFunction>(); |
[email protected] | 63cda0c | 2010-09-01 04:41:23 | [diff] [blame] | 350 | |
[email protected] | a65882c | 2010-11-12 15:15:09 | [diff] [blame] | 351 | // Extension module. |
| 352 | RegisterFunction<SetUpdateUrlDataFunction>(); |
[email protected] | c7c401d | 2011-03-16 10:20:01 | [diff] [blame] | 353 | RegisterFunction<IsAllowedIncognitoAccessFunction>(); |
| 354 | RegisterFunction<IsAllowedFileSchemeAccessFunction>(); |
[email protected] | a65882c | 2010-11-12 15:15:09 | [diff] [blame] | 355 | |
[email protected] | 63cda0c | 2010-09-01 04:41:23 | [diff] [blame] | 356 | // WebstorePrivate. |
[email protected] | d688559 | 2010-10-11 19:38:24 | [diff] [blame] | 357 | RegisterFunction<GetBrowserLoginFunction>(); |
[email protected] | 63cda0c | 2010-09-01 04:41:23 | [diff] [blame] | 358 | RegisterFunction<GetStoreLoginFunction>(); |
| 359 | RegisterFunction<SetStoreLoginFunction>(); |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 360 | RegisterFunction<BeginInstallWithManifestFunction>(); |
[email protected] | b1f04cc | 2010-11-10 22:59:30 | [diff] [blame] | 361 | RegisterFunction<CompleteInstallFunction>(); |
[email protected] | f66a50a | 2011-11-02 23:53:46 | [diff] [blame^] | 362 | RegisterFunction<SilentlyInstallFunction>(); |
[email protected] | c41fe66 | 2011-02-15 01:19:26 | [diff] [blame] | 363 | |
[email protected] | 557a51dd | 2011-07-26 12:17:11 | [diff] [blame] | 364 | // WebNavigation. |
| 365 | RegisterFunction<GetFrameFunction>(); |
[email protected] | 5a13067 | 2011-09-09 08:42:29 | [diff] [blame] | 366 | RegisterFunction<GetAllFramesFunction>(); |
[email protected] | 557a51dd | 2011-07-26 12:17:11 | [diff] [blame] | 367 | |
[email protected] | c41fe66 | 2011-02-15 01:19:26 | [diff] [blame] | 368 | // WebRequest. |
| 369 | RegisterFunction<WebRequestAddEventListener>(); |
[email protected] | 05cc4e7 | 2011-03-08 21:29:48 | [diff] [blame] | 370 | RegisterFunction<WebRequestEventHandled>(); |
[email protected] | e81d4d7 | 2011-09-29 16:54:31 | [diff] [blame] | 371 | RegisterFunction<WebRequestHandlerBehaviorChanged>(); |
[email protected] | 598bbcc | 2011-02-24 10:03:25 | [diff] [blame] | 372 | |
| 373 | // Preferences. |
| 374 | RegisterFunction<GetPreferenceFunction>(); |
| 375 | RegisterFunction<SetPreferenceFunction>(); |
[email protected] | c433bcb | 2011-02-24 13:10:27 | [diff] [blame] | 376 | RegisterFunction<ClearPreferenceFunction>(); |
[email protected] | 91ba331 | 2011-03-17 20:39:22 | [diff] [blame] | 377 | |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 378 | // ChromeOS-specific part of the API. |
| 379 | #if defined(OS_CHROMEOS) |
| 380 | // Device Customization. |
| 381 | RegisterFunction<GetChromeosInfoFunction>(); |
| 382 | |
| 383 | // FileBrowserPrivate functions. |
[email protected] | 94bda20 | 2011-04-18 23:31:00 | [diff] [blame] | 384 | RegisterFunction<CancelFileDialogFunction>(); |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 385 | RegisterFunction<ExecuteTasksFileBrowserFunction>(); |
[email protected] | 94bda20 | 2011-04-18 23:31:00 | [diff] [blame] | 386 | RegisterFunction<FileDialogStringsFunction>(); |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 387 | RegisterFunction<GetFileTasksFileBrowserFunction>(); |
[email protected] | 61334fa | 2011-06-16 01:01:40 | [diff] [blame] | 388 | RegisterFunction<GetVolumeMetadataFunction>(); |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 389 | RegisterFunction<RequestLocalFileSystemFunction>(); |
[email protected] | a6d0664 | 2011-06-02 05:55:23 | [diff] [blame] | 390 | RegisterFunction<AddFileWatchBrowserFunction>(); |
| 391 | RegisterFunction<RemoveFileWatchBrowserFunction>(); |
[email protected] | 9d4c2c5 | 2011-04-07 18:53:10 | [diff] [blame] | 392 | RegisterFunction<SelectFileFunction>(); |
| 393 | RegisterFunction<SelectFilesFunction>(); |
[email protected] | 928ae885 | 2011-07-26 01:15:03 | [diff] [blame] | 394 | RegisterFunction<AddMountFunction>(); |
| 395 | RegisterFunction<RemoveMountFunction>(); |
| 396 | RegisterFunction<GetMountPointsFunction>(); |
[email protected] | 694cafac | 2011-09-21 17:41:53 | [diff] [blame] | 397 | RegisterFunction<GetSizeStatsFunction>(); |
[email protected] | 3fd9004c | 2011-08-12 00:58:46 | [diff] [blame] | 398 | RegisterFunction<FormatDeviceFunction>(); |
[email protected] | 94bda20 | 2011-04-18 23:31:00 | [diff] [blame] | 399 | RegisterFunction<ViewFilesFunction>(); |
[email protected] | f1852b5 | 2011-05-17 04:58:08 | [diff] [blame] | 400 | |
[email protected] | ce980204 | 2011-05-27 10:11:40 | [diff] [blame] | 401 | // Mediaplayer |
| 402 | RegisterFunction<PlayAtMediaplayerFunction>(); |
| 403 | RegisterFunction<SetPlaybackErrorMediaplayerFunction>(); |
| 404 | RegisterFunction<GetPlaylistMediaplayerFunction>(); |
| 405 | RegisterFunction<TogglePlaylistPanelMediaplayerFunction>(); |
| 406 | RegisterFunction<ToggleFullscreenMediaplayerFunction>(); |
[email protected] | be5bd574 | 2011-07-14 07:21:01 | [diff] [blame] | 407 | |
| 408 | // InputMethod |
| 409 | RegisterFunction<GetInputMethodFunction>(); |
| 410 | |
[email protected] | f1852b5 | 2011-05-17 04:58:08 | [diff] [blame] | 411 | #if defined(TOUCH_UI) |
| 412 | // Input |
| 413 | RegisterFunction<SendHandwritingStrokeFunction>(); |
| 414 | RegisterFunction<CancelHandwritingStrokesFunction>(); |
| 415 | #endif |
[email protected] | 61b55b6 | 2011-03-24 09:03:10 | [diff] [blame] | 416 | #endif |
| 417 | |
[email protected] | c6e584c | 2011-05-18 11:58:44 | [diff] [blame] | 418 | // Websocket to TCP proxy. Currently noop on anything other than ChromeOS. |
| 419 | RegisterFunction<WebSocketProxyPrivateGetPassportForTCPFunction>(); |
[email protected] | 5ddffb8 | 2011-10-14 17:48:07 | [diff] [blame] | 420 | RegisterFunction<WebSocketProxyPrivateGetURLForTCPFunction>(); |
[email protected] | c6e584c | 2011-05-18 11:58:44 | [diff] [blame] | 421 | |
[email protected] | 91ba331 | 2011-03-17 20:39:22 | [diff] [blame] | 422 | // Debugger |
| 423 | RegisterFunction<AttachDebuggerFunction>(); |
| 424 | RegisterFunction<DetachDebuggerFunction>(); |
[email protected] | c7580b6 | 2011-10-26 08:46:30 | [diff] [blame] | 425 | RegisterFunction<SendCommandDebuggerFunction>(); |
[email protected] | fa062426 | 2011-06-09 14:17:38 | [diff] [blame] | 426 | |
[email protected] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 427 | // Settings |
| 428 | RegisterFunction<GetSettingsFunction>(); |
| 429 | RegisterFunction<SetSettingsFunction>(); |
| 430 | RegisterFunction<RemoveSettingsFunction>(); |
| 431 | RegisterFunction<ClearSettingsFunction>(); |
| 432 | |
[email protected] | fa062426 | 2011-06-09 14:17:38 | [diff] [blame] | 433 | // Content settings. |
[email protected] | 49ba482 | 2011-06-15 18:41:56 | [diff] [blame] | 434 | RegisterFunction<GetResourceIdentifiersFunction>(); |
[email protected] | fa062426 | 2011-06-09 14:17:38 | [diff] [blame] | 435 | RegisterFunction<ClearContentSettingsFunction>(); |
| 436 | RegisterFunction<GetContentSettingFunction>(); |
| 437 | RegisterFunction<SetContentSettingFunction>(); |
[email protected] | c1d05aa | 2011-06-28 02:07:30 | [diff] [blame] | 438 | |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 439 | // ChromeAuth settings. |
| 440 | RegisterFunction<SetCloudPrintCredentialsFunction>(); |
| 441 | |
[email protected] | c1d05aa | 2011-06-28 02:07:30 | [diff] [blame] | 442 | // Experimental App API. |
| 443 | RegisterFunction<AppNotifyFunction>(); |
| 444 | RegisterFunction<AppClearAllNotificationsFunction>(); |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 445 | |
| 446 | // Permissions |
| 447 | RegisterFunction<ContainsPermissionsFunction>(); |
| 448 | RegisterFunction<GetAllPermissionsFunction>(); |
| 449 | RegisterFunction<RemovePermissionsFunction>(); |
| 450 | RegisterFunction<RequestPermissionsFunction>(); |
[email protected] | 21d7a4e30 | 2011-08-15 16:17:12 | [diff] [blame] | 451 | |
| 452 | // Downloads |
| 453 | RegisterFunction<DownloadsDownloadFunction>(); |
| 454 | RegisterFunction<DownloadsSearchFunction>(); |
| 455 | RegisterFunction<DownloadsPauseFunction>(); |
| 456 | RegisterFunction<DownloadsResumeFunction>(); |
| 457 | RegisterFunction<DownloadsCancelFunction>(); |
| 458 | RegisterFunction<DownloadsEraseFunction>(); |
| 459 | RegisterFunction<DownloadsSetDestinationFunction>(); |
| 460 | RegisterFunction<DownloadsAcceptDangerFunction>(); |
| 461 | RegisterFunction<DownloadsShowFunction>(); |
| 462 | RegisterFunction<DownloadsDragFunction>(); |
[email protected] | 3a605e8 | 2011-09-26 17:26:16 | [diff] [blame] | 463 | |
| 464 | // SavePage |
| 465 | RegisterFunction<SavePageAsMHTMLFunction>(); |
[email protected] | 6a16dc9b | 2011-10-17 18:28:16 | [diff] [blame] | 466 | |
| 467 | // Clipboard |
| 468 | RegisterFunction<WriteDataClipboardFunction>(); |
| 469 | RegisterFunction<ReadDataClipboardFunction>(); |
| 470 | RegisterFunction<GetAvailableMimeTypesClipboardFunction>(); |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 471 | |
| 472 | // TopSites |
| 473 | RegisterFunction<GetTopSitesFunction>(); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 474 | } |
| 475 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 476 | void FactoryRegistry::GetAllNames(std::vector<std::string>* names) { |
| 477 | for (FactoryMap::iterator iter = factories_.begin(); |
| 478 | iter != factories_.end(); ++iter) { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 479 | names->push_back(iter->first); |
| 480 | } |
| 481 | } |
| 482 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 483 | bool FactoryRegistry::OverrideFunction(const std::string& name, |
| 484 | ExtensionFunctionFactory factory) { |
| 485 | FactoryMap::iterator iter = factories_.find(name); |
| 486 | if (iter == factories_.end()) { |
| 487 | return false; |
| 488 | } else { |
| 489 | iter->second = factory; |
| 490 | return true; |
| 491 | } |
| 492 | } |
| 493 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 494 | ExtensionFunction* FactoryRegistry::NewFunction(const std::string& name) { |
| 495 | FactoryMap::iterator iter = factories_.find(name); |
| 496 | DCHECK(iter != factories_.end()); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 497 | ExtensionFunction* function = iter->second(); |
[email protected] | 76a3db85 | 2009-07-24 02:14:56 | [diff] [blame] | 498 | function->set_name(name); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 499 | return function; |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 500 | } |
| 501 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 502 | }; // namespace |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 503 | |
| 504 | // ExtensionFunctionDispatcher ------------------------------------------------- |
| 505 | |
| 506 | void ExtensionFunctionDispatcher::GetAllFunctionNames( |
| 507 | std::vector<std::string>* names) { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 508 | FactoryRegistry::GetInstance()->GetAllNames(names); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 509 | } |
| 510 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 511 | bool ExtensionFunctionDispatcher::OverrideFunction( |
| 512 | const std::string& name, ExtensionFunctionFactory factory) { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 513 | return FactoryRegistry::GetInstance()->OverrideFunction(name, factory); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | void ExtensionFunctionDispatcher::ResetFunctions() { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 517 | FactoryRegistry::GetInstance()->ResetFunctions(); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 518 | } |
| 519 | |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 520 | // static |
| 521 | void ExtensionFunctionDispatcher::DispatchOnIOThread( |
| 522 | const ExtensionInfoMap* extension_info_map, |
[email protected] | 67351452 | 2011-07-13 18:17:18 | [diff] [blame] | 523 | void* profile, |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 524 | int render_process_id, |
| 525 | base::WeakPtr<ChromeRenderMessageFilter> ipc_sender, |
| 526 | int routing_id, |
| 527 | const ExtensionHostMsg_Request_Params& params) { |
| 528 | const Extension* extension = |
| 529 | extension_info_map->extensions().GetByURL(params.source_url); |
| 530 | |
[email protected] | 2cce7ae | 2011-10-23 15:54:36 | [diff] [blame] | 531 | if (!extension_info_map->IsExtensionInProcess(extension->id(), |
| 532 | render_process_id)) { |
[email protected] | 8add541 | 2011-10-01 21:02:14 | [diff] [blame] | 533 | // TODO(aa): Allow content scripts access to low-threat extension APIs. |
| 534 | // See: crbug.com/80308. |
| 535 | LOG(ERROR) << "Extension API called from non-extension process."; |
| 536 | SendAccessDenied(ipc_sender, routing_id, params.request_id); |
| 537 | return; |
| 538 | } |
| 539 | |
| 540 | scoped_refptr<ExtensionFunction> function(CreateExtensionFunction( |
| 541 | params, extension, profile, ipc_sender, routing_id)); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 542 | if (!function) |
| 543 | return; |
| 544 | |
| 545 | IOThreadExtensionFunction* function_io = |
| 546 | function->AsIOThreadExtensionFunction(); |
| 547 | if (!function_io) { |
| 548 | NOTREACHED(); |
| 549 | return; |
| 550 | } |
| 551 | function_io->set_ipc_sender(ipc_sender, routing_id); |
| 552 | function_io->set_extension_info_map(extension_info_map); |
| 553 | function->set_include_incognito( |
| 554 | extension_info_map->IsIncognitoEnabled(extension->id())); |
| 555 | function->Run(); |
| 556 | } |
| 557 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 558 | ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(Profile* profile, |
| 559 | Delegate* delegate) |
| 560 | : profile_(profile), |
[email protected] | 55ce33071 | 2011-05-24 19:04:27 | [diff] [blame] | 561 | delegate_(delegate) { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 562 | } |
| 563 | |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 564 | ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() { |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 565 | } |
| 566 | |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 567 | Browser* ExtensionFunctionDispatcher::GetCurrentBrowser( |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 568 | RenderViewHost* render_view_host, bool include_incognito) { |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 569 | Browser* browser = delegate_->GetBrowser(); |
[email protected] | 7eecaed5 | 2009-05-07 21:44:12 | [diff] [blame] | 570 | |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 571 | // If the delegate has an associated browser, that is always the right answer. |
| 572 | if (browser) |
| 573 | return browser; |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 574 | |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 575 | // Otherwise, try to default to a reasonable browser. If |include_incognito| |
| 576 | // is true, we will also search browsers in the incognito version of this |
| 577 | // profile. Note that the profile may already be incognito, in which case |
| 578 | // we will search the incognito version only, regardless of the value of |
| 579 | // |include_incognito|. |
[email protected] | 9b62ecf | 2011-07-27 20:23:08 | [diff] [blame] | 580 | Profile* profile = Profile::FromBrowserContext( |
| 581 | render_view_host->process()->browser_context()); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 582 | browser = BrowserList::FindTabbedBrowser(profile, include_incognito); |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 583 | |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 584 | // NOTE(rafaelw): This can return NULL in some circumstances. In particular, |
[email protected] | 6d7a604 | 2010-08-12 20:12:42 | [diff] [blame] | 585 | // a background_page onload chrome.tabs api call can make it into here |
| 586 | // before the browser is sufficiently initialized to return here. |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 587 | // A similar situation may arise during shutdown. |
| 588 | // TODO(rafaelw): Delay creation of background_page until the browser |
| 589 | // is available. http://code.google.com/p/chromium/issues/detail?id=13284 |
| 590 | return browser; |
[email protected] | b2725756 | 2009-11-16 23:28:26 | [diff] [blame] | 591 | } |
| 592 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 593 | void ExtensionFunctionDispatcher::Dispatch( |
| 594 | const ExtensionHostMsg_Request_Params& params, |
| 595 | RenderViewHost* render_view_host) { |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 596 | ExtensionService* service = profile()->GetExtensionService(); |
[email protected] | 8add541 | 2011-10-01 21:02:14 | [diff] [blame] | 597 | ExtensionProcessManager* extension_process_manager = |
| 598 | profile()->GetExtensionProcessManager(); |
| 599 | if (!service || !extension_process_manager) |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 600 | return; |
| 601 | |
| 602 | if (!service->ExtensionBindingsAllowed(params.source_url)) { |
| 603 | LOG(ERROR) << "Extension bindings not allowed for URL: " |
| 604 | << params.source_url.spec(); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 605 | SendAccessDenied(render_view_host, render_view_host->routing_id(), |
| 606 | params.request_id); |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 607 | return; |
| 608 | } |
[email protected] | 8add541 | 2011-10-01 21:02:14 | [diff] [blame] | 609 | if (!extension_process_manager->AreBindingsEnabledForProcess( |
| 610 | render_view_host->process()->id())) { |
| 611 | // TODO(aa): Allow content scripts access to low-threat extension APIs. |
| 612 | // See: crbug.com/80308. |
| 613 | LOG(ERROR) << "Extension API called from non-extension process."; |
| 614 | SendAccessDenied(render_view_host, render_view_host->routing_id(), |
| 615 | params.request_id); |
| 616 | return; |
| 617 | } |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 618 | |
| 619 | // TODO(aa): When we allow content scripts to call extension APIs, we will |
| 620 | // have to pass the extension ID explicitly here, not use the source URL. |
| 621 | const Extension* extension = service->GetExtensionByURL(params.source_url); |
| 622 | if (!extension) |
| 623 | extension = service->GetExtensionByWebExtent(params.source_url); |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 624 | |
[email protected] | 8add541 | 2011-10-01 21:02:14 | [diff] [blame] | 625 | scoped_refptr<ExtensionFunction> function( |
| 626 | CreateExtensionFunction(params, extension, profile(), render_view_host, |
| 627 | render_view_host->routing_id())); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 628 | if (!function) |
[email protected] | f82d57b5 | 2011-04-27 19:13:17 | [diff] [blame] | 629 | return; |
[email protected] | f82d57b5 | 2011-04-27 19:13:17 | [diff] [blame] | 630 | |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 631 | UIThreadExtensionFunction* function_ui = |
| 632 | function->AsUIThreadExtensionFunction(); |
| 633 | if (!function_ui) { |
| 634 | NOTREACHED(); |
| 635 | return; |
| 636 | } |
| 637 | function_ui->SetRenderViewHost(render_view_host); |
| 638 | function_ui->set_dispatcher(AsWeakPtr()); |
| 639 | function_ui->set_profile(profile_); |
[email protected] | 2a8f24e | 2010-11-03 21:37:05 | [diff] [blame] | 640 | function->set_include_incognito(service->CanCrossIncognito(extension)); |
[email protected] | cb0ce1e02 | 2010-03-10 19:54:41 | [diff] [blame] | 641 | |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 642 | ExtensionsQuotaService* quota = service->quota_service(); |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 643 | if (quota->Assess(extension->id(), function, ¶ms.arguments, |
[email protected] | 8b8e7c9 | 2010-08-19 18:05:56 | [diff] [blame] | 644 | base::TimeTicks::Now())) { |
[email protected] | d070ec6 | 2010-07-27 21:28:26 | [diff] [blame] | 645 | // See crbug.com/39178. |
| 646 | ExternalProtocolHandler::PermitLaunchUrl(); |
| 647 | |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 648 | function->Run(); |
| 649 | } else { |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 650 | render_view_host->Send(new ExtensionMsg_Response( |
| 651 | render_view_host->routing_id(), function->request_id(), false, |
[email protected] | 553602e1 | 2011-04-05 17:01:18 | [diff] [blame] | 652 | std::string(), QuotaLimitHeuristic::kGenericOverQuotaError)); |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 653 | } |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 654 | } |
| 655 | |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 656 | // static |
| 657 | ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction( |
| 658 | const ExtensionHostMsg_Request_Params& params, |
| 659 | const Extension* extension, |
[email protected] | 67351452 | 2011-07-13 18:17:18 | [diff] [blame] | 660 | void* profile, |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 661 | IPC::Message::Sender* ipc_sender, |
| 662 | int routing_id) { |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 663 | if (!extension) { |
| 664 | LOG(ERROR) << "Extension does not exist for URL: " |
| 665 | << params.source_url.spec(); |
| 666 | SendAccessDenied(ipc_sender, routing_id, params.request_id); |
| 667 | return NULL; |
| 668 | } |
| 669 | |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 670 | if (!extension->HasAPIPermission(params.name)) { |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 671 | LOG(ERROR) << "Extension " << extension->id() << " does not have " |
| 672 | << "permission to function: " << params.name; |
| 673 | SendAccessDenied(ipc_sender, routing_id, params.request_id); |
| 674 | return NULL; |
| 675 | } |
| 676 | |
| 677 | ExtensionFunction* function = |
| 678 | FactoryRegistry::GetInstance()->NewFunction(params.name); |
| 679 | function->SetArgs(¶ms.arguments); |
| 680 | function->set_source_url(params.source_url); |
| 681 | function->set_request_id(params.request_id); |
| 682 | function->set_has_callback(params.has_callback); |
| 683 | function->set_user_gesture(params.user_gesture); |
| 684 | function->set_extension(extension); |
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 685 | function->set_profile_id(profile); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 686 | return function; |
| 687 | } |
| 688 | |
| 689 | // static |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 690 | void ExtensionFunctionDispatcher::SendAccessDenied( |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 691 | IPC::Message::Sender* ipc_sender, int routing_id, int request_id) { |
| 692 | ipc_sender->Send(new ExtensionMsg_Response( |
| 693 | routing_id, request_id, false, std::string(), |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 694 | "Access to extension API denied.")); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 695 | } |