[email protected] | 64c82073 | 2012-01-05 20:50:34 | [diff] [blame] | 1 | // Copyright (c) 2012 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] | ffbec69 | 2012-02-26 20:26:42 | [diff] [blame] | 9 | #include "base/json/json_string_value_serializer.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
| 11 | #include "base/memory/singleton.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 12 | #include "base/process_util.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 13 | #include "base/values.h" |
[email protected] | 17d40f0 | 2010-07-01 01:18:06 | [diff] [blame] | 14 | #include "build/build_config.h" |
[email protected] | a692a95 | 2011-11-28 08:23:54 | [diff] [blame] | 15 | #include "chrome/browser/accessibility/accessibility_extension_api.h" |
[email protected] | 23d5f17 | 2011-10-25 05:49:53 | [diff] [blame] | 16 | #include "chrome/browser/bookmarks/bookmark_extension_api.h" |
| 17 | #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h" |
[email protected] | cdcf6024 | 2011-11-04 15:53:43 | [diff] [blame] | 18 | #include "chrome/browser/download/download_extension_api.h" |
[email protected] | b7309da | 2012-01-23 16:03:51 | [diff] [blame] | 19 | #include "chrome/browser/extensions/api/app/app_api.h" |
[email protected] | 006236a2 | 2012-02-24 13:20:17 | [diff] [blame] | 20 | #include "chrome/browser/extensions/api/browsingdata/browsing_data_api.h" |
[email protected] | 8ef650e | 2012-02-08 10:20:59 | [diff] [blame] | 21 | #include "chrome/browser/extensions/api/declarative/declarative_api.h" |
[email protected] | 14a38f3f | 2012-01-12 16:16:51 | [diff] [blame] | 22 | #include "chrome/browser/extensions/api/dns/dns_api.h" |
[email protected] | 76aeb177 | 2012-01-20 22:14:16 | [diff] [blame] | 23 | #include "chrome/browser/extensions/api/permissions/permissions_api.h" |
[email protected] | 223a93f1 | 2012-01-18 21:17:53 | [diff] [blame] | 24 | #include "chrome/browser/extensions/api/serial/serial_api.h" |
[email protected] | 55afeb5 | 2011-12-06 00:15:39 | [diff] [blame] | 25 | #include "chrome/browser/extensions/api/socket/socket_api.h" |
[email protected] | 6e672df | 2012-01-25 10:39:47 | [diff] [blame] | 26 | #include "chrome/browser/extensions/api/webrequest/webrequest_api.h" |
[email protected] | 912256b3 | 2009-09-18 09:47:35 | [diff] [blame] | 27 | #include "chrome/browser/extensions/execute_code_in_tab_function.h" |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 28 | #include "chrome/browser/extensions/extension_activity_log.h" |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 29 | #include "chrome/browser/extensions/extension_browser_actions_api.h" |
[email protected] | cdcf6024 | 2011-11-04 15:53:43 | [diff] [blame] | 30 | #include "chrome/browser/extensions/extension_chrome_auth_private_api.h" |
[email protected] | fa062426 | 2011-06-09 14:17:38 | [diff] [blame] | 31 | #include "chrome/browser/extensions/extension_content_settings_api.h" |
[email protected] | 2e3b520 | 2010-03-23 06:52:41 | [diff] [blame] | 32 | #include "chrome/browser/extensions/extension_context_menu_api.h" |
[email protected] | 898bbd3 | 2010-05-18 18:52:29 | [diff] [blame] | 33 | #include "chrome/browser/extensions/extension_cookies_api.h" |
[email protected] | 91ba331 | 2011-03-17 20:39:22 | [diff] [blame] | 34 | #include "chrome/browser/extensions/extension_debugger_api.h" |
[email protected] | caedf60c | 2012-02-21 04:24:47 | [diff] [blame] | 35 | #include "chrome/browser/extensions/extension_font_settings_api.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 36 | #include "chrome/browser/extensions/extension_function.h" |
[email protected] | 2bb5130 | 2011-02-18 22:39:27 | [diff] [blame] | 37 | #include "chrome/browser/extensions/extension_i18n_api.h" |
[email protected] | 2f69b38 | 2011-02-19 00:34:25 | [diff] [blame] | 38 | #include "chrome/browser/extensions/extension_idle_api.h" |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 39 | #include "chrome/browser/extensions/extension_management_api.h" |
[email protected] | 438772df | 2010-02-26 18:08:43 | [diff] [blame] | 40 | #include "chrome/browser/extensions/extension_metrics_module.h" |
[email protected] | a65882c | 2010-11-12 15:15:09 | [diff] [blame] | 41 | #include "chrome/browser/extensions/extension_module.h" |
[email protected] | 56ad379 | 2010-05-28 17:45:33 | [diff] [blame] | 42 | #include "chrome/browser/extensions/extension_omnibox_api.h" |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 43 | #include "chrome/browser/extensions/extension_page_actions_module.h" |
[email protected] | 9e4430f | 2011-11-28 07:43:29 | [diff] [blame] | 44 | #include "chrome/browser/extensions/extension_page_capture_api.h" |
[email protected] | 598bbcc | 2011-02-24 10:03:25 | [diff] [blame] | 45 | #include "chrome/browser/extensions/extension_preference_api.h" |
[email protected] | 381162b | 2010-01-28 17:29:35 | [diff] [blame] | 46 | #include "chrome/browser/extensions/extension_processes_api.h" |
[email protected] | a9c23a5 | 2010-08-04 09:13:44 | [diff] [blame] | 47 | #include "chrome/browser/extensions/extension_proxy_api.h" |
[email protected] | 2f69b38 | 2011-02-19 00:34:25 | [diff] [blame] | 48 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 49 | #include "chrome/browser/extensions/extension_tabs_module.h" |
[email protected] | 25fd1b2e | 2009-08-17 20:57:14 | [diff] [blame] | 50 | #include "chrome/browser/extensions/extension_test_api.h" |
[email protected] | 8abe0a3 | 2010-08-12 00:40:22 | [diff] [blame] | 51 | #include "chrome/browser/extensions/extension_tts_api.h" |
[email protected] | c63f2b7 | 2011-07-07 05:25:00 | [diff] [blame] | 52 | #include "chrome/browser/extensions/extension_tts_engine_api.h" |
[email protected] | c6e584c | 2011-05-18 11:58:44 | [diff] [blame] | 53 | #include "chrome/browser/extensions/extension_web_socket_proxy_private_api.h" |
[email protected] | 8f9d4eb | 2011-02-05 01:39:10 | [diff] [blame] | 54 | #include "chrome/browser/extensions/extension_web_ui.h" |
[email protected] | 557a51dd | 2011-07-26 12:17:11 | [diff] [blame] | 55 | #include "chrome/browser/extensions/extension_webnavigation_api.h" |
[email protected] | 63cda0c | 2010-09-01 04:41:23 | [diff] [blame] | 56 | #include "chrome/browser/extensions/extension_webstore_private_api.h" |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 57 | #include "chrome/browser/extensions/extensions_quota_service.h" |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 58 | #include "chrome/browser/extensions/process_map.h" |
[email protected] | ae7f1ba | 2011-11-28 23:07:31 | [diff] [blame] | 59 | #include "chrome/browser/extensions/settings/settings_api.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame^] | 60 | #include "chrome/browser/extensions/system/system_api.h" |
[email protected] | ed2b100 | 2011-05-25 14:12:10 | [diff] [blame] | 61 | #include "chrome/browser/external_protocol/external_protocol_handler.h" |
[email protected] | d2e6bd6 | 2011-10-24 20:29:07 | [diff] [blame] | 62 | #include "chrome/browser/history/history_extension_api.h" |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 63 | #include "chrome/browser/history/top_sites_extension_api.h" |
[email protected] | cdcf6024 | 2011-11-04 15:53:43 | [diff] [blame] | 64 | #include "chrome/browser/infobars/infobar_extension_api.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 65 | #include "chrome/browser/profiles/profile.h" |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 66 | #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
[email protected] | 792556c | 2011-10-25 05:01:07 | [diff] [blame] | 67 | #include "chrome/browser/rlz/rlz_extension_api.h" |
[email protected] | b9971dc | 2011-11-11 15:50:43 | [diff] [blame] | 68 | #include "chrome/browser/speech/speech_input_extension_api.h" |
[email protected] | 71b73f0 | 2011-04-06 15:57:29 | [diff] [blame] | 69 | #include "chrome/browser/ui/browser_list.h" |
[email protected] | 00070c73 | 2011-04-09 15:31:33 | [diff] [blame] | 70 | #include "chrome/browser/ui/browser_window.h" |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 71 | #include "chrome/common/extensions/api/extension_api.h" |
[email protected] | 44c49c9 | 2011-03-28 16:17:23 | [diff] [blame] | 72 | #include "chrome/common/extensions/extension_messages.h" |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 73 | #include "chrome/common/extensions/extension_set.h" |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 74 | #include "chrome/common/url_constants.h" |
[email protected] | c333e79 | 2012-01-06 16:57:39 | [diff] [blame] | 75 | #include "content/public/browser/render_process_host.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame^] | 76 | #include "content/public/browser/render_view_host.h" |
[email protected] | f82d57b5 | 2011-04-27 19:13:17 | [diff] [blame] | 77 | #include "ipc/ipc_message.h" |
| 78 | #include "ipc/ipc_message_macros.h" |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 79 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame^] | 80 | #include "third_party/skia/include/core/SkBitmap.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 81 | |
[email protected] | 8f9d4eb | 2011-02-05 01:39:10 | [diff] [blame] | 82 | #if defined(TOOLKIT_VIEWS) |
| 83 | #include "chrome/browser/extensions/extension_input_api.h" |
| 84 | #endif |
[email protected] | d683385 | 2010-08-20 18:00:45 | [diff] [blame] | 85 | |
[email protected] | 9a2aebe0 | 2011-12-02 21:54:14 | [diff] [blame] | 86 | #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) |
[email protected] | 27072cad | 2011-05-09 19:46:40 | [diff] [blame] | 87 | #include "chrome/browser/extensions/extension_input_ui_api.h" |
| 88 | #endif |
| 89 | |
[email protected] | 61b55b6 | 2011-03-24 09:03:10 | [diff] [blame] | 90 | #if defined(OS_CHROMEOS) |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame^] | 91 | #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
| 92 | #include "chrome/browser/chromeos/media/media_player_extension_api.h" |
[email protected] | 8f42798 | 2011-12-13 23:40:23 | [diff] [blame] | 93 | #include "chrome/browser/extensions/api/terminal/terminal_private_api.h" |
[email protected] | 8baf0dbb | 2011-11-27 22:47:02 | [diff] [blame] | 94 | #include "chrome/browser/extensions/extension_info_private_api_chromeos.h" |
| 95 | #include "chrome/browser/extensions/extension_input_ime_api.h" |
| 96 | #include "chrome/browser/extensions/extension_input_method_api.h" |
[email protected] | 61b55b6 | 2011-03-24 09:03:10 | [diff] [blame] | 97 | #endif |
| 98 | |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 99 | using extensions::ExtensionAPI; |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 100 | using WebKit::WebSecurityOrigin; |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 101 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 102 | // FactoryRegistry ------------------------------------------------------------- |
| 103 | |
| 104 | namespace { |
| 105 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 106 | // Template for defining ExtensionFunctionFactory. |
| 107 | template<class T> |
| 108 | ExtensionFunction* NewExtensionFunction() { |
| 109 | return new T(); |
| 110 | } |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 111 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 112 | // Contains a list of all known extension functions and allows clients to |
| 113 | // create instances of them. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 114 | class FactoryRegistry { |
| 115 | public: |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 116 | static FactoryRegistry* GetInstance(); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 117 | FactoryRegistry() { ResetFunctions(); } |
| 118 | |
| 119 | // Resets all functions to their default values. |
| 120 | void ResetFunctions(); |
| 121 | |
| 122 | // Adds all function names to 'names'. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 123 | void GetAllNames(std::vector<std::string>* names); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 124 | |
| 125 | // Allows overriding of specific functions (e.g. for testing). Functions |
| 126 | // must be previously registered. Returns true if successful. |
| 127 | bool OverrideFunction(const std::string& name, |
| 128 | ExtensionFunctionFactory factory); |
| 129 | |
| 130 | // Factory method for the ExtensionFunction registered as 'name'. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 131 | ExtensionFunction* NewFunction(const std::string& name); |
| 132 | |
| 133 | private: |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 134 | template<class T> |
| 135 | void RegisterFunction() { |
| 136 | factories_[T::function_name()] = &NewExtensionFunction<T>; |
| 137 | } |
| 138 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 139 | typedef std::map<std::string, ExtensionFunctionFactory> FactoryMap; |
| 140 | FactoryMap factories_; |
| 141 | }; |
| 142 | |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 143 | FactoryRegistry* FactoryRegistry::GetInstance() { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 144 | return Singleton<FactoryRegistry>::get(); |
| 145 | } |
| 146 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 147 | void FactoryRegistry::ResetFunctions() { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 148 | // Register all functions here. |
| 149 | |
[email protected] | e515f5d | 2009-05-05 03:05:00 | [diff] [blame] | 150 | // Windows |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 151 | RegisterFunction<GetWindowFunction>(); |
| 152 | RegisterFunction<GetCurrentWindowFunction>(); |
| 153 | RegisterFunction<GetLastFocusedWindowFunction>(); |
| 154 | RegisterFunction<GetAllWindowsFunction>(); |
| 155 | RegisterFunction<CreateWindowFunction>(); |
| 156 | RegisterFunction<UpdateWindowFunction>(); |
| 157 | RegisterFunction<RemoveWindowFunction>(); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 158 | |
[email protected] | e515f5d | 2009-05-05 03:05:00 | [diff] [blame] | 159 | // Tabs |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 160 | RegisterFunction<GetTabFunction>(); |
[email protected] | e3eafb29 | 2010-04-14 21:30:41 | [diff] [blame] | 161 | RegisterFunction<GetCurrentTabFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 162 | RegisterFunction<GetSelectedTabFunction>(); |
| 163 | RegisterFunction<GetAllTabsInWindowFunction>(); |
[email protected] | 8c3495c | 2011-09-28 03:32:30 | [diff] [blame] | 164 | RegisterFunction<QueryTabsFunction>(); |
| 165 | RegisterFunction<HighlightTabsFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 166 | RegisterFunction<CreateTabFunction>(); |
| 167 | RegisterFunction<UpdateTabFunction>(); |
[email protected] | 8c3495c | 2011-09-28 03:32:30 | [diff] [blame] | 168 | RegisterFunction<MoveTabsFunction>(); |
[email protected] | 5d93511 | 2011-09-07 09:24:54 | [diff] [blame] | 169 | RegisterFunction<ReloadTabFunction>(); |
[email protected] | 8c3495c | 2011-09-28 03:32:30 | [diff] [blame] | 170 | RegisterFunction<RemoveTabsFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 171 | RegisterFunction<DetectTabLanguageFunction>(); |
| 172 | RegisterFunction<CaptureVisibleTabFunction>(); |
| 173 | RegisterFunction<TabsExecuteScriptFunction>(); |
| 174 | RegisterFunction<TabsInsertCSSFunction>(); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 175 | |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 176 | // Page Actions. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 177 | RegisterFunction<EnablePageActionFunction>(); |
| 178 | RegisterFunction<DisablePageActionFunction>(); |
[email protected] | 744ef17 | 2009-10-16 21:53:46 | [diff] [blame] | 179 | RegisterFunction<PageActionShowFunction>(); |
| 180 | RegisterFunction<PageActionHideFunction>(); |
| 181 | RegisterFunction<PageActionSetIconFunction>(); |
| 182 | RegisterFunction<PageActionSetTitleFunction>(); |
[email protected] | e478d670 | 2010-01-28 00:10:29 | [diff] [blame] | 183 | RegisterFunction<PageActionSetPopupFunction>(); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 184 | |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 185 | // Browser Actions. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 186 | RegisterFunction<BrowserActionSetIconFunction>(); |
[email protected] | 1288ba0 | 2009-10-15 00:02:24 | [diff] [blame] | 187 | RegisterFunction<BrowserActionSetTitleFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 188 | RegisterFunction<BrowserActionSetBadgeTextFunction>(); |
| 189 | RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>(); |
[email protected] | 85ae959 | 2010-02-03 20:58:50 | [diff] [blame] | 190 | RegisterFunction<BrowserActionSetPopupFunction>(); |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 191 | |
[email protected] | 6093d74 | 2011-08-26 16:37:18 | [diff] [blame] | 192 | // Browsing Data. |
[email protected] | 8f5090a5 | 2012-02-10 11:36:21 | [diff] [blame] | 193 | RegisterFunction<RemoveBrowsingDataFunction>(); |
| 194 | RegisterFunction<RemoveAppCacheFunction>(); |
| 195 | RegisterFunction<RemoveCacheFunction>(); |
| 196 | RegisterFunction<RemoveCookiesFunction>(); |
| 197 | RegisterFunction<RemoveDownloadsFunction>(); |
| 198 | RegisterFunction<RemoveFileSystemsFunction>(); |
| 199 | RegisterFunction<RemoveFormDataFunction>(); |
| 200 | RegisterFunction<RemoveHistoryFunction>(); |
| 201 | RegisterFunction<RemoveIndexedDBFunction>(); |
| 202 | RegisterFunction<RemoveLocalStorageFunction>(); |
| 203 | RegisterFunction<RemoveOriginBoundCertsFunction>(); |
| 204 | RegisterFunction<RemovePluginDataFunction>(); |
| 205 | RegisterFunction<RemovePasswordsFunction>(); |
| 206 | RegisterFunction<RemoveWebSQLFunction>(); |
[email protected] | 6093d74 | 2011-08-26 16:37:18 | [diff] [blame] | 207 | |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 208 | // Bookmarks. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 209 | RegisterFunction<GetBookmarksFunction>(); |
| 210 | RegisterFunction<GetBookmarkChildrenFunction>(); |
[email protected] | a3c94c71 | 2009-12-18 19:23:55 | [diff] [blame] | 211 | RegisterFunction<GetBookmarkRecentFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 212 | RegisterFunction<GetBookmarkTreeFunction>(); |
[email protected] | 532a8c6 | 2011-06-03 21:30:01 | [diff] [blame] | 213 | RegisterFunction<GetBookmarkSubTreeFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 214 | RegisterFunction<SearchBookmarksFunction>(); |
| 215 | RegisterFunction<RemoveBookmarkFunction>(); |
| 216 | RegisterFunction<RemoveTreeBookmarkFunction>(); |
| 217 | RegisterFunction<CreateBookmarkFunction>(); |
| 218 | RegisterFunction<MoveBookmarkFunction>(); |
| 219 | RegisterFunction<UpdateBookmarkFunction>(); |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 220 | |
[email protected] | f34e7963 | 2010-03-17 02:34:08 | [diff] [blame] | 221 | // Infobars. |
| 222 | RegisterFunction<ShowInfoBarFunction>(); |
| 223 | |
[email protected] | 9dd97bc | 2010-01-14 01:40:04 | [diff] [blame] | 224 | // BookmarkManager |
| 225 | RegisterFunction<CopyBookmarkManagerFunction>(); |
| 226 | RegisterFunction<CutBookmarkManagerFunction>(); |
| 227 | RegisterFunction<PasteBookmarkManagerFunction>(); |
[email protected] | 03b3bbf | 2010-01-29 23:54:57 | [diff] [blame] | 228 | RegisterFunction<CanPasteBookmarkManagerFunction>(); |
[email protected] | cb6cf79 | 2010-01-28 00:04:56 | [diff] [blame] | 229 | RegisterFunction<ImportBookmarksFunction>(); |
| 230 | RegisterFunction<ExportBookmarksFunction>(); |
[email protected] | d406e2e | 2010-01-30 21:45:18 | [diff] [blame] | 231 | RegisterFunction<SortChildrenBookmarkManagerFunction>(); |
[email protected] | 9dd97bc | 2010-01-14 01:40:04 | [diff] [blame] | 232 | RegisterFunction<BookmarkManagerGetStringsFunction>(); |
[email protected] | ced90ae1 | 2010-02-20 02:06:16 | [diff] [blame] | 233 | RegisterFunction<StartDragBookmarkManagerFunction>(); |
| 234 | RegisterFunction<DropBookmarkManagerFunction>(); |
[email protected] | 9b07185 | 2010-04-02 06:45:31 | [diff] [blame] | 235 | RegisterFunction<GetSubtreeBookmarkManagerFunction>(); |
[email protected] | 933ebbe | 2011-06-30 12:24:01 | [diff] [blame] | 236 | RegisterFunction<CanEditBookmarkManagerFunction>(); |
[email protected] | 9dd97bc | 2010-01-14 01:40:04 | [diff] [blame] | 237 | |
[email protected] | de768a83 | 2009-10-30 05:25:01 | [diff] [blame] | 238 | // History |
| 239 | RegisterFunction<AddUrlHistoryFunction>(); |
| 240 | RegisterFunction<DeleteAllHistoryFunction>(); |
| 241 | RegisterFunction<DeleteRangeHistoryFunction>(); |
| 242 | RegisterFunction<DeleteUrlHistoryFunction>(); |
| 243 | RegisterFunction<GetVisitsHistoryFunction>(); |
| 244 | RegisterFunction<SearchHistoryFunction>(); |
| 245 | |
[email protected] | f520541 | 2010-03-16 00:19:34 | [diff] [blame] | 246 | // Idle |
| 247 | RegisterFunction<ExtensionIdleQueryStateFunction>(); |
| 248 | |
[email protected] | 198bcfe | 2009-09-09 22:56:28 | [diff] [blame] | 249 | // I18N. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 250 | RegisterFunction<GetAcceptLanguagesFunction>(); |
[email protected] | 198bcfe | 2009-09-09 22:56:28 | [diff] [blame] | 251 | |
[email protected] | 381162b | 2010-01-28 17:29:35 | [diff] [blame] | 252 | // Processes. |
[email protected] | 8a661f8 | 2010-10-19 21:47:11 | [diff] [blame] | 253 | RegisterFunction<GetProcessIdForTabFunction>(); |
[email protected] | 381162b | 2010-01-28 17:29:35 | [diff] [blame] | 254 | |
[email protected] | 438772df | 2010-02-26 18:08:43 | [diff] [blame] | 255 | // Metrics. |
[email protected] | cf25e4d | 2010-03-12 21:19:34 | [diff] [blame] | 256 | RegisterFunction<MetricsRecordUserActionFunction>(); |
| 257 | RegisterFunction<MetricsRecordValueFunction>(); |
| 258 | RegisterFunction<MetricsRecordPercentageFunction>(); |
| 259 | RegisterFunction<MetricsRecordCountFunction>(); |
| 260 | RegisterFunction<MetricsRecordSmallCountFunction>(); |
| 261 | RegisterFunction<MetricsRecordMediumCountFunction>(); |
| 262 | RegisterFunction<MetricsRecordTimeFunction>(); |
| 263 | RegisterFunction<MetricsRecordMediumTimeFunction>(); |
| 264 | RegisterFunction<MetricsRecordLongTimeFunction>(); |
[email protected] | 438772df | 2010-02-26 18:08:43 | [diff] [blame] | 265 | |
[email protected] | 17d40f0 | 2010-07-01 01:18:06 | [diff] [blame] | 266 | // RLZ. |
| 267 | #if defined(OS_WIN) |
| 268 | RegisterFunction<RlzRecordProductEventFunction>(); |
| 269 | RegisterFunction<RlzGetAccessPointRlzFunction>(); |
[email protected] | 3a612be | 2010-07-17 03:11:21 | [diff] [blame] | 270 | RegisterFunction<RlzSendFinancialPingFunction>(); |
[email protected] | 17d40f0 | 2010-07-01 01:18:06 | [diff] [blame] | 271 | RegisterFunction<RlzClearProductStateFunction>(); |
| 272 | #endif |
| 273 | |
[email protected] | 898bbd3 | 2010-05-18 18:52:29 | [diff] [blame] | 274 | // Cookies. |
| 275 | RegisterFunction<GetCookieFunction>(); |
| 276 | RegisterFunction<GetAllCookiesFunction>(); |
| 277 | RegisterFunction<SetCookieFunction>(); |
| 278 | RegisterFunction<RemoveCookieFunction>(); |
| 279 | RegisterFunction<GetAllCookieStoresFunction>(); |
| 280 | |
[email protected] | 25fd1b2e | 2009-08-17 20:57:14 | [diff] [blame] | 281 | // Test. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 282 | RegisterFunction<ExtensionTestPassFunction>(); |
| 283 | RegisterFunction<ExtensionTestFailFunction>(); |
| 284 | RegisterFunction<ExtensionTestLogFunction>(); |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 285 | RegisterFunction<ExtensionTestQuotaResetFunction>(); |
[email protected] | db7331a | 2010-02-25 22:10:50 | [diff] [blame] | 286 | RegisterFunction<ExtensionTestCreateIncognitoTabFunction>(); |
[email protected] | 745feedb | 2010-08-02 04:08:07 | [diff] [blame] | 287 | RegisterFunction<ExtensionTestSendMessageFunction>(); |
[email protected] | 761e716 | 2010-10-18 19:26:39 | [diff] [blame] | 288 | RegisterFunction<ExtensionTestGetConfigFunction>(); |
[email protected] | 5cbe1e2 | 2010-01-30 01:18:56 | [diff] [blame] | 289 | |
| 290 | // Accessibility. |
| 291 | RegisterFunction<GetFocusedControlFunction>(); |
| 292 | RegisterFunction<SetAccessibilityEnabledFunction>(); |
[email protected] | cde158b | 2011-12-21 10:22:49 | [diff] [blame] | 293 | RegisterFunction<GetAlertsForTabFunction>(); |
[email protected] | 44625595 | 2010-03-17 20:41:58 | [diff] [blame] | 294 | |
[email protected] | 8abe0a3 | 2010-08-12 00:40:22 | [diff] [blame] | 295 | // Text-to-speech. |
[email protected] | c63f2b7 | 2011-07-07 05:25:00 | [diff] [blame] | 296 | RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>(); |
| 297 | RegisterFunction<ExtensionTtsGetVoicesFunction>(); |
| 298 | RegisterFunction<ExtensionTtsIsSpeakingFunction>(); |
[email protected] | 8abe0a3 | 2010-08-12 00:40:22 | [diff] [blame] | 299 | RegisterFunction<ExtensionTtsSpeakFunction>(); |
| 300 | RegisterFunction<ExtensionTtsStopSpeakingFunction>(); |
[email protected] | 8abe0a3 | 2010-08-12 00:40:22 | [diff] [blame] | 301 | |
[email protected] | 2e3b520 | 2010-03-23 06:52:41 | [diff] [blame] | 302 | // Context Menus. |
| 303 | RegisterFunction<CreateContextMenuFunction>(); |
[email protected] | 66dbfb2c | 2010-05-12 20:20:15 | [diff] [blame] | 304 | RegisterFunction<UpdateContextMenuFunction>(); |
[email protected] | 2e3b520 | 2010-03-23 06:52:41 | [diff] [blame] | 305 | RegisterFunction<RemoveContextMenuFunction>(); |
[email protected] | 66dbfb2c | 2010-05-12 20:20:15 | [diff] [blame] | 306 | RegisterFunction<RemoveAllContextMenusFunction>(); |
[email protected] | 56ad379 | 2010-05-28 17:45:33 | [diff] [blame] | 307 | |
| 308 | // Omnibox. |
| 309 | RegisterFunction<OmniboxSendSuggestionsFunction>(); |
[email protected] | 1bead071 | 2010-11-27 17:41:53 | [diff] [blame] | 310 | RegisterFunction<OmniboxSetDefaultSuggestionFunction>(); |
[email protected] | a9c23a5 | 2010-08-04 09:13:44 | [diff] [blame] | 311 | |
[email protected] | e06a1fe | 2011-09-29 21:20:44 | [diff] [blame] | 312 | // Speech input. |
| 313 | RegisterFunction<StartSpeechInputFunction>(); |
| 314 | RegisterFunction<StopSpeechInputFunction>(); |
| 315 | RegisterFunction<IsRecordingSpeechInputFunction>(); |
| 316 | |
[email protected] | d683385 | 2010-08-20 18:00:45 | [diff] [blame] | 317 | #if defined(TOOLKIT_VIEWS) |
| 318 | // Input. |
| 319 | RegisterFunction<SendKeyboardEventInputFunction>(); |
| 320 | #endif |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 321 | |
[email protected] | 2cc81d3 | 2011-10-04 17:03:18 | [diff] [blame] | 322 | #if defined(USE_VIRTUAL_KEYBOARD) |
[email protected] | bcde748 | 2011-05-23 19:29:12 | [diff] [blame] | 323 | RegisterFunction<HideKeyboardFunction>(); |
[email protected] | 3c8faef | 2011-06-09 22:56:51 | [diff] [blame] | 324 | RegisterFunction<SetKeyboardHeightFunction>(); |
[email protected] | bcde748 | 2011-05-23 19:29:12 | [diff] [blame] | 325 | #endif |
| 326 | |
[email protected] | 14da67b0 | 2011-08-02 05:49:13 | [diff] [blame] | 327 | #if defined(OS_CHROMEOS) |
[email protected] | 27072cad | 2011-05-09 19:46:40 | [diff] [blame] | 328 | // IME |
[email protected] | 14da67b0 | 2011-08-02 05:49:13 | [diff] [blame] | 329 | RegisterFunction<SetCompositionFunction>(); |
| 330 | RegisterFunction<ClearCompositionFunction>(); |
| 331 | RegisterFunction<CommitTextFunction>(); |
| 332 | RegisterFunction<SetCandidateWindowPropertiesFunction>(); |
| 333 | RegisterFunction<SetCandidatesFunction>(); |
| 334 | RegisterFunction<SetCursorPositionFunction>(); |
| 335 | RegisterFunction<SetMenuItemsFunction>(); |
| 336 | RegisterFunction<UpdateMenuItemsFunction>(); |
[email protected] | cd0b04c9 | 2011-09-08 05:18:06 | [diff] [blame] | 337 | |
| 338 | RegisterFunction<InputEventHandled>(); |
[email protected] | 9a2aebe0 | 2011-12-02 21:54:14 | [diff] [blame] | 339 | #if defined(USE_VIRTUAL_KEYBOARD) |
[email protected] | 27072cad | 2011-05-09 19:46:40 | [diff] [blame] | 340 | RegisterFunction<CandidateClickedInputUiFunction>(); |
| 341 | RegisterFunction<CursorUpInputUiFunction>(); |
| 342 | RegisterFunction<CursorDownInputUiFunction>(); |
| 343 | RegisterFunction<PageUpInputUiFunction>(); |
| 344 | RegisterFunction<PageDownInputUiFunction>(); |
| 345 | RegisterFunction<RegisterInputUiFunction>(); |
| 346 | RegisterFunction<PageUpInputUiFunction>(); |
| 347 | RegisterFunction<PageDownInputUiFunction>(); |
| 348 | #endif |
[email protected] | 14da67b0 | 2011-08-02 05:49:13 | [diff] [blame] | 349 | #endif |
[email protected] | 27072cad | 2011-05-09 19:46:40 | [diff] [blame] | 350 | |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 351 | // Management. |
| 352 | RegisterFunction<GetAllExtensionsFunction>(); |
[email protected] | e78543c | 2010-11-08 22:05:23 | [diff] [blame] | 353 | RegisterFunction<GetExtensionByIdFunction>(); |
[email protected] | 925a54d | 2011-07-29 17:21:00 | [diff] [blame] | 354 | RegisterFunction<GetPermissionWarningsByIdFunction>(); |
| 355 | RegisterFunction<GetPermissionWarningsByManifestFunction>(); |
[email protected] | e558ff8 | 2010-09-23 20:19:56 | [diff] [blame] | 356 | RegisterFunction<LaunchAppFunction>(); |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 357 | RegisterFunction<SetEnabledFunction>(); |
[email protected] | cffd789 | 2010-08-26 17:43:28 | [diff] [blame] | 358 | RegisterFunction<UninstallFunction>(); |
[email protected] | 63cda0c | 2010-09-01 04:41:23 | [diff] [blame] | 359 | |
[email protected] | a65882c | 2010-11-12 15:15:09 | [diff] [blame] | 360 | // Extension module. |
| 361 | RegisterFunction<SetUpdateUrlDataFunction>(); |
[email protected] | c7c401d | 2011-03-16 10:20:01 | [diff] [blame] | 362 | RegisterFunction<IsAllowedIncognitoAccessFunction>(); |
| 363 | RegisterFunction<IsAllowedFileSchemeAccessFunction>(); |
[email protected] | a65882c | 2010-11-12 15:15:09 | [diff] [blame] | 364 | |
[email protected] | 63cda0c | 2010-09-01 04:41:23 | [diff] [blame] | 365 | // WebstorePrivate. |
[email protected] | d688559 | 2010-10-11 19:38:24 | [diff] [blame] | 366 | RegisterFunction<GetBrowserLoginFunction>(); |
[email protected] | 63cda0c | 2010-09-01 04:41:23 | [diff] [blame] | 367 | RegisterFunction<GetStoreLoginFunction>(); |
| 368 | RegisterFunction<SetStoreLoginFunction>(); |
[email protected] | bc070bf | 2012-02-23 16:27:57 | [diff] [blame] | 369 | RegisterFunction<InstallBundleFunction>(); |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 370 | RegisterFunction<BeginInstallWithManifestFunction>(); |
[email protected] | b1f04cc | 2010-11-10 22:59:30 | [diff] [blame] | 371 | RegisterFunction<CompleteInstallFunction>(); |
[email protected] | f66a50a | 2011-11-02 23:53:46 | [diff] [blame] | 372 | RegisterFunction<SilentlyInstallFunction>(); |
[email protected] | 979b69c | 2011-12-08 23:19:55 | [diff] [blame] | 373 | RegisterFunction<GetWebGLStatusFunction>(); |
[email protected] | c41fe66 | 2011-02-15 01:19:26 | [diff] [blame] | 374 | |
[email protected] | 557a51dd | 2011-07-26 12:17:11 | [diff] [blame] | 375 | // WebNavigation. |
| 376 | RegisterFunction<GetFrameFunction>(); |
[email protected] | 5a13067 | 2011-09-09 08:42:29 | [diff] [blame] | 377 | RegisterFunction<GetAllFramesFunction>(); |
[email protected] | 557a51dd | 2011-07-26 12:17:11 | [diff] [blame] | 378 | |
[email protected] | c41fe66 | 2011-02-15 01:19:26 | [diff] [blame] | 379 | // WebRequest. |
| 380 | RegisterFunction<WebRequestAddEventListener>(); |
[email protected] | 05cc4e7 | 2011-03-08 21:29:48 | [diff] [blame] | 381 | RegisterFunction<WebRequestEventHandled>(); |
[email protected] | e81d4d7 | 2011-09-29 16:54:31 | [diff] [blame] | 382 | RegisterFunction<WebRequestHandlerBehaviorChanged>(); |
[email protected] | 598bbcc | 2011-02-24 10:03:25 | [diff] [blame] | 383 | |
| 384 | // Preferences. |
| 385 | RegisterFunction<GetPreferenceFunction>(); |
| 386 | RegisterFunction<SetPreferenceFunction>(); |
[email protected] | c433bcb | 2011-02-24 13:10:27 | [diff] [blame] | 387 | RegisterFunction<ClearPreferenceFunction>(); |
[email protected] | 91ba331 | 2011-03-17 20:39:22 | [diff] [blame] | 388 | |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 389 | // ChromeOS-specific part of the API. |
| 390 | #if defined(OS_CHROMEOS) |
| 391 | // Device Customization. |
| 392 | RegisterFunction<GetChromeosInfoFunction>(); |
| 393 | |
| 394 | // FileBrowserPrivate functions. |
[email protected] | 04ef515 | 2011-11-18 04:05:25 | [diff] [blame] | 395 | // TODO(jamescook): Expose these on non-ChromeOS platforms so we can use |
| 396 | // the extension-based file picker on Aura. crbug.com/97424 |
[email protected] | 94bda20 | 2011-04-18 23:31:00 | [diff] [blame] | 397 | RegisterFunction<CancelFileDialogFunction>(); |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 398 | RegisterFunction<ExecuteTasksFileBrowserFunction>(); |
[email protected] | 94bda20 | 2011-04-18 23:31:00 | [diff] [blame] | 399 | RegisterFunction<FileDialogStringsFunction>(); |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 400 | RegisterFunction<GetFileTasksFileBrowserFunction>(); |
[email protected] | 61334fa | 2011-06-16 01:01:40 | [diff] [blame] | 401 | RegisterFunction<GetVolumeMetadataFunction>(); |
[email protected] | b6b805e9 | 2011-04-16 09:24:14 | [diff] [blame] | 402 | RegisterFunction<RequestLocalFileSystemFunction>(); |
[email protected] | a6d0664 | 2011-06-02 05:55:23 | [diff] [blame] | 403 | RegisterFunction<AddFileWatchBrowserFunction>(); |
| 404 | RegisterFunction<RemoveFileWatchBrowserFunction>(); |
[email protected] | 9d4c2c5 | 2011-04-07 18:53:10 | [diff] [blame] | 405 | RegisterFunction<SelectFileFunction>(); |
| 406 | RegisterFunction<SelectFilesFunction>(); |
[email protected] | 928ae885 | 2011-07-26 01:15:03 | [diff] [blame] | 407 | RegisterFunction<AddMountFunction>(); |
| 408 | RegisterFunction<RemoveMountFunction>(); |
| 409 | RegisterFunction<GetMountPointsFunction>(); |
[email protected] | 694cafac | 2011-09-21 17:41:53 | [diff] [blame] | 410 | RegisterFunction<GetSizeStatsFunction>(); |
[email protected] | 3fd9004c | 2011-08-12 00:58:46 | [diff] [blame] | 411 | RegisterFunction<FormatDeviceFunction>(); |
[email protected] | 94bda20 | 2011-04-18 23:31:00 | [diff] [blame] | 412 | RegisterFunction<ViewFilesFunction>(); |
[email protected] | bce9459 | 2012-03-02 14:02:01 | [diff] [blame] | 413 | RegisterFunction<ToggleFullscreenFunction>(); |
| 414 | RegisterFunction<IsFullscreenFunction>(); |
[email protected] | 594126ba | 2012-03-06 08:56:16 | [diff] [blame] | 415 | RegisterFunction<GetGDataFilePropertiesFunction>(); |
| 416 | RegisterFunction<PinGDataFileFunction>(); |
[email protected] | f1852b5 | 2011-05-17 04:58:08 | [diff] [blame] | 417 | |
[email protected] | ce980204 | 2011-05-27 10:11:40 | [diff] [blame] | 418 | // Mediaplayer |
[email protected] | 7df1dad | 2012-02-27 11:19:51 | [diff] [blame] | 419 | RegisterFunction<PlayMediaplayerFunction>(); |
[email protected] | ce980204 | 2011-05-27 10:11:40 | [diff] [blame] | 420 | RegisterFunction<GetPlaylistMediaplayerFunction>(); |
[email protected] | 7df1dad | 2012-02-27 11:19:51 | [diff] [blame] | 421 | RegisterFunction<SetWindowHeightMediaplayerFunction>(); |
| 422 | RegisterFunction<CloseWindowMediaplayerFunction>(); |
[email protected] | be5bd574 | 2011-07-14 07:21:01 | [diff] [blame] | 423 | |
| 424 | // InputMethod |
| 425 | RegisterFunction<GetInputMethodFunction>(); |
| 426 | |
[email protected] | 8f42798 | 2011-12-13 23:40:23 | [diff] [blame] | 427 | // Terminal |
| 428 | RegisterFunction<OpenTerminalProcessFunction>(); |
| 429 | RegisterFunction<SendInputToTerminalProcessFunction>(); |
| 430 | RegisterFunction<CloseTerminalProcessFunction>(); |
[email protected] | 0d2786c | 2012-02-14 02:36:31 | [diff] [blame] | 431 | RegisterFunction<OnTerminalResizeFunction>(); |
[email protected] | 8f42798 | 2011-12-13 23:40:23 | [diff] [blame] | 432 | |
[email protected] | 9a2aebe0 | 2011-12-02 21:54:14 | [diff] [blame] | 433 | #if defined(USE_VIRTUAL_KEYBOARD) |
[email protected] | f1852b5 | 2011-05-17 04:58:08 | [diff] [blame] | 434 | // Input |
| 435 | RegisterFunction<SendHandwritingStrokeFunction>(); |
| 436 | RegisterFunction<CancelHandwritingStrokesFunction>(); |
| 437 | #endif |
[email protected] | 61b55b6 | 2011-03-24 09:03:10 | [diff] [blame] | 438 | #endif |
| 439 | |
[email protected] | c6e584c | 2011-05-18 11:58:44 | [diff] [blame] | 440 | // Websocket to TCP proxy. Currently noop on anything other than ChromeOS. |
| 441 | RegisterFunction<WebSocketProxyPrivateGetPassportForTCPFunction>(); |
[email protected] | 5ddffb8 | 2011-10-14 17:48:07 | [diff] [blame] | 442 | RegisterFunction<WebSocketProxyPrivateGetURLForTCPFunction>(); |
[email protected] | c6e584c | 2011-05-18 11:58:44 | [diff] [blame] | 443 | |
[email protected] | 91ba331 | 2011-03-17 20:39:22 | [diff] [blame] | 444 | // Debugger |
| 445 | RegisterFunction<AttachDebuggerFunction>(); |
| 446 | RegisterFunction<DetachDebuggerFunction>(); |
[email protected] | c7580b6 | 2011-10-26 08:46:30 | [diff] [blame] | 447 | RegisterFunction<SendCommandDebuggerFunction>(); |
[email protected] | fa062426 | 2011-06-09 14:17:38 | [diff] [blame] | 448 | |
[email protected] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 449 | // Settings |
[email protected] | 0d9a220 | 2011-11-09 13:48:41 | [diff] [blame] | 450 | RegisterFunction<extensions::GetSettingsFunction>(); |
| 451 | RegisterFunction<extensions::SetSettingsFunction>(); |
| 452 | RegisterFunction<extensions::RemoveSettingsFunction>(); |
| 453 | RegisterFunction<extensions::ClearSettingsFunction>(); |
[email protected] | 7b4989f | 2012-01-29 11:19:11 | [diff] [blame] | 454 | RegisterFunction<extensions::GetBytesInUseSettingsFunction>(); |
[email protected] | b7f853e28 | 2011-08-10 09:24:20 | [diff] [blame] | 455 | |
[email protected] | fa062426 | 2011-06-09 14:17:38 | [diff] [blame] | 456 | // Content settings. |
[email protected] | 49ba482 | 2011-06-15 18:41:56 | [diff] [blame] | 457 | RegisterFunction<GetResourceIdentifiersFunction>(); |
[email protected] | fa062426 | 2011-06-09 14:17:38 | [diff] [blame] | 458 | RegisterFunction<ClearContentSettingsFunction>(); |
| 459 | RegisterFunction<GetContentSettingFunction>(); |
| 460 | RegisterFunction<SetContentSettingFunction>(); |
[email protected] | c1d05aa | 2011-06-28 02:07:30 | [diff] [blame] | 461 | |
[email protected] | caedf60c | 2012-02-21 04:24:47 | [diff] [blame] | 462 | // Font settings. |
[email protected] | ab813c43 | 2012-03-02 15:56:05 | [diff] [blame] | 463 | RegisterFunction<GetFontListFunction>(); |
[email protected] | caedf60c | 2012-02-21 04:24:47 | [diff] [blame] | 464 | RegisterFunction<GetFontNameFunction>(); |
[email protected] | a361489 | 2012-02-29 06:16:17 | [diff] [blame] | 465 | RegisterFunction<SetFontNameFunction>(); |
[email protected] | caedf60c | 2012-02-21 04:24:47 | [diff] [blame] | 466 | |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 467 | // ChromeAuth settings. |
| 468 | RegisterFunction<SetCloudPrintCredentialsFunction>(); |
| 469 | |
[email protected] | c1d05aa | 2011-06-28 02:07:30 | [diff] [blame] | 470 | // Experimental App API. |
| 471 | RegisterFunction<AppNotifyFunction>(); |
| 472 | RegisterFunction<AppClearAllNotificationsFunction>(); |
[email protected] | 902fd7b | 2011-07-27 18:42:31 | [diff] [blame] | 473 | |
| 474 | // Permissions |
| 475 | RegisterFunction<ContainsPermissionsFunction>(); |
| 476 | RegisterFunction<GetAllPermissionsFunction>(); |
| 477 | RegisterFunction<RemovePermissionsFunction>(); |
| 478 | RegisterFunction<RequestPermissionsFunction>(); |
[email protected] | 21d7a4e30 | 2011-08-15 16:17:12 | [diff] [blame] | 479 | |
| 480 | // Downloads |
| 481 | RegisterFunction<DownloadsDownloadFunction>(); |
| 482 | RegisterFunction<DownloadsSearchFunction>(); |
| 483 | RegisterFunction<DownloadsPauseFunction>(); |
| 484 | RegisterFunction<DownloadsResumeFunction>(); |
| 485 | RegisterFunction<DownloadsCancelFunction>(); |
| 486 | RegisterFunction<DownloadsEraseFunction>(); |
| 487 | RegisterFunction<DownloadsSetDestinationFunction>(); |
| 488 | RegisterFunction<DownloadsAcceptDangerFunction>(); |
| 489 | RegisterFunction<DownloadsShowFunction>(); |
| 490 | RegisterFunction<DownloadsDragFunction>(); |
[email protected] | 45e4fab2 | 2012-01-09 19:38:02 | [diff] [blame] | 491 | RegisterFunction<DownloadsGetFileIconFunction>(); |
[email protected] | 3a605e8 | 2011-09-26 17:26:16 | [diff] [blame] | 492 | |
[email protected] | 9e4430f | 2011-11-28 07:43:29 | [diff] [blame] | 493 | // PageCapture |
| 494 | RegisterFunction<PageCaptureSaveAsMHTMLFunction>(); |
[email protected] | 6a16dc9b | 2011-10-17 18:28:16 | [diff] [blame] | 495 | |
[email protected] | 5eddc3e | 2011-10-26 04:33:31 | [diff] [blame] | 496 | // TopSites |
| 497 | RegisterFunction<GetTopSitesFunction>(); |
[email protected] | ae7f1ba | 2011-11-28 23:07:31 | [diff] [blame] | 498 | |
[email protected] | 223a93f1 | 2012-01-18 21:17:53 | [diff] [blame] | 499 | // Serial |
| 500 | RegisterFunction<extensions::SerialOpenFunction>(); |
| 501 | RegisterFunction<extensions::SerialCloseFunction>(); |
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 502 | RegisterFunction<extensions::SerialReadFunction>(); |
| 503 | RegisterFunction<extensions::SerialWriteFunction>(); |
[email protected] | 223a93f1 | 2012-01-18 21:17:53 | [diff] [blame] | 504 | |
[email protected] | ae7f1ba | 2011-11-28 23:07:31 | [diff] [blame] | 505 | // Sockets |
| 506 | RegisterFunction<extensions::SocketCreateFunction>(); |
[email protected] | 55afeb5 | 2011-12-06 00:15:39 | [diff] [blame] | 507 | RegisterFunction<extensions::SocketDestroyFunction>(); |
[email protected] | ae7f1ba | 2011-11-28 23:07:31 | [diff] [blame] | 508 | RegisterFunction<extensions::SocketConnectFunction>(); |
[email protected] | d47c11f | 2012-01-26 18:15:04 | [diff] [blame] | 509 | RegisterFunction<extensions::SocketDisconnectFunction>(); |
[email protected] | 64c82073 | 2012-01-05 20:50:34 | [diff] [blame] | 510 | RegisterFunction<extensions::SocketReadFunction>(); |
[email protected] | 55afeb5 | 2011-12-06 00:15:39 | [diff] [blame] | 511 | RegisterFunction<extensions::SocketWriteFunction>(); |
[email protected] | a4f9892 | 2011-12-06 11:32:23 | [diff] [blame] | 512 | |
[email protected] | 14a38f3f | 2012-01-12 16:16:51 | [diff] [blame] | 513 | // DNS |
| 514 | RegisterFunction<extensions::DNSResolveFunction>(); |
| 515 | |
[email protected] | a4f9892 | 2011-12-06 11:32:23 | [diff] [blame] | 516 | // System |
| 517 | RegisterFunction<extensions::GetIncognitoModeAvailabilityFunction>(); |
[email protected] | 1723bdc2 | 2011-12-15 05:04:18 | [diff] [blame] | 518 | RegisterFunction<extensions::GetUpdateStatusFunction>(); |
[email protected] | 8ef650e | 2012-02-08 10:20:59 | [diff] [blame] | 519 | |
| 520 | // Net |
| 521 | RegisterFunction<extensions::AddRulesFunction>(); |
| 522 | RegisterFunction<extensions::RemoveRulesFunction>(); |
| 523 | RegisterFunction<extensions::GetRulesFunction>(); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 524 | } |
| 525 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 526 | void FactoryRegistry::GetAllNames(std::vector<std::string>* names) { |
| 527 | for (FactoryMap::iterator iter = factories_.begin(); |
| 528 | iter != factories_.end(); ++iter) { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 529 | names->push_back(iter->first); |
| 530 | } |
| 531 | } |
| 532 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 533 | bool FactoryRegistry::OverrideFunction(const std::string& name, |
| 534 | ExtensionFunctionFactory factory) { |
| 535 | FactoryMap::iterator iter = factories_.find(name); |
| 536 | if (iter == factories_.end()) { |
| 537 | return false; |
| 538 | } else { |
| 539 | iter->second = factory; |
| 540 | return true; |
| 541 | } |
| 542 | } |
| 543 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 544 | ExtensionFunction* FactoryRegistry::NewFunction(const std::string& name) { |
| 545 | FactoryMap::iterator iter = factories_.find(name); |
| 546 | DCHECK(iter != factories_.end()); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 547 | ExtensionFunction* function = iter->second(); |
[email protected] | 76a3db85 | 2009-07-24 02:14:56 | [diff] [blame] | 548 | function->set_name(name); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 549 | return function; |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 550 | } |
| 551 | |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 552 | const char kAccessDenied[] = "access denied"; |
| 553 | const char kQuotaExceeded[] = "quota exceeded"; |
| 554 | |
| 555 | void LogSuccess(const Extension* extension, |
| 556 | const ExtensionHostMsg_Request_Params& params) { |
| 557 | ExtensionActivityLog* extension_activity_log = |
| 558 | ExtensionActivityLog::GetInstance(); |
| 559 | if (extension_activity_log->HasObservers(extension)) { |
| 560 | std::string call_signature = params.name + "("; |
| 561 | ListValue::const_iterator it = params.arguments.begin(); |
| 562 | for (; it != params.arguments.end(); ++it) { |
| 563 | std::string arg; |
| 564 | JSONStringValueSerializer serializer(&arg); |
| 565 | if (serializer.SerializeAndOmitBinaryValues(**it)) { |
| 566 | if (it != params.arguments.begin()) |
| 567 | call_signature += ", "; |
| 568 | call_signature += arg; |
| 569 | } |
| 570 | } |
| 571 | call_signature += ")"; |
| 572 | |
| 573 | extension_activity_log->Log( |
| 574 | extension, |
| 575 | ExtensionActivityLog::ACTIVITY_EXTENSION_API_CALL, |
| 576 | call_signature); |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | void LogFailure(const Extension* extension, |
| 581 | const std::string& func_name, |
| 582 | const char* reason) { |
| 583 | ExtensionActivityLog* extension_activity_log = |
| 584 | ExtensionActivityLog::GetInstance(); |
| 585 | if (extension_activity_log->HasObservers(extension)) { |
| 586 | extension_activity_log->Log( |
| 587 | extension, |
| 588 | ExtensionActivityLog::ACTIVITY_EXTENSION_API_BLOCK, |
| 589 | func_name + ": " + reason); |
| 590 | } |
| 591 | } |
| 592 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 593 | }; // namespace |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 594 | |
| 595 | // ExtensionFunctionDispatcher ------------------------------------------------- |
| 596 | |
| 597 | void ExtensionFunctionDispatcher::GetAllFunctionNames( |
| 598 | std::vector<std::string>* names) { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 599 | FactoryRegistry::GetInstance()->GetAllNames(names); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 600 | } |
| 601 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 602 | bool ExtensionFunctionDispatcher::OverrideFunction( |
| 603 | const std::string& name, ExtensionFunctionFactory factory) { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 604 | return FactoryRegistry::GetInstance()->OverrideFunction(name, factory); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | void ExtensionFunctionDispatcher::ResetFunctions() { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 608 | FactoryRegistry::GetInstance()->ResetFunctions(); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 609 | } |
| 610 | |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 611 | // static |
| 612 | void ExtensionFunctionDispatcher::DispatchOnIOThread( |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 613 | ExtensionInfoMap* extension_info_map, |
[email protected] | 67351452 | 2011-07-13 18:17:18 | [diff] [blame] | 614 | void* profile, |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 615 | int render_process_id, |
| 616 | base::WeakPtr<ChromeRenderMessageFilter> ipc_sender, |
| 617 | int routing_id, |
| 618 | const ExtensionHostMsg_Request_Params& params) { |
| 619 | const Extension* extension = |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 620 | extension_info_map->extensions().GetByID(params.extension_id); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 621 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 622 | scoped_refptr<ExtensionFunction> function( |
| 623 | CreateExtensionFunction(params, extension, render_process_id, |
| 624 | extension_info_map->process_map(), profile, |
| 625 | ipc_sender, routing_id)); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 626 | if (!function) { |
| 627 | LogFailure(extension, params.name, kAccessDenied); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 628 | return; |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 629 | } |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 630 | |
| 631 | IOThreadExtensionFunction* function_io = |
| 632 | function->AsIOThreadExtensionFunction(); |
| 633 | if (!function_io) { |
| 634 | NOTREACHED(); |
| 635 | return; |
| 636 | } |
| 637 | function_io->set_ipc_sender(ipc_sender, routing_id); |
| 638 | function_io->set_extension_info_map(extension_info_map); |
| 639 | function->set_include_incognito( |
| 640 | extension_info_map->IsIncognitoEnabled(extension->id())); |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 641 | |
| 642 | ExtensionsQuotaService* quota = extension_info_map->quota_service(); |
| 643 | if (quota->Assess(extension->id(), function, ¶ms.arguments, |
| 644 | base::TimeTicks::Now())) { |
| 645 | function->Run(); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 646 | LogSuccess(extension, params); |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 647 | } else { |
| 648 | function->OnQuotaExceeded(); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 649 | LogFailure(extension, params.name, kQuotaExceeded); |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 650 | } |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 651 | } |
| 652 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 653 | ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(Profile* profile, |
| 654 | Delegate* delegate) |
| 655 | : profile_(profile), |
[email protected] | 55ce33071 | 2011-05-24 19:04:27 | [diff] [blame] | 656 | delegate_(delegate) { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 657 | } |
| 658 | |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 659 | ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() { |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 660 | } |
| 661 | |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 662 | Browser* ExtensionFunctionDispatcher::GetCurrentBrowser( |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 663 | RenderViewHost* render_view_host, bool include_incognito) { |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 664 | Browser* browser = delegate_->GetBrowser(); |
[email protected] | 7eecaed5 | 2009-05-07 21:44:12 | [diff] [blame] | 665 | |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 666 | // If the delegate has an associated browser, that is always the right answer. |
| 667 | if (browser) |
| 668 | return browser; |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 669 | |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 670 | // Otherwise, try to default to a reasonable browser. If |include_incognito| |
| 671 | // is true, we will also search browsers in the incognito version of this |
| 672 | // profile. Note that the profile may already be incognito, in which case |
| 673 | // we will search the incognito version only, regardless of the value of |
| 674 | // |include_incognito|. |
[email protected] | 9b62ecf | 2011-07-27 20:23:08 | [diff] [blame] | 675 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 676 | render_view_host->GetProcess()->GetBrowserContext()); |
[email protected] | 8ecca49 | 2012-01-19 17:29:42 | [diff] [blame] | 677 | browser = BrowserList::FindAnyBrowser(profile, include_incognito); |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 678 | |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 679 | // NOTE(rafaelw): This can return NULL in some circumstances. In particular, |
[email protected] | 6d7a604 | 2010-08-12 20:12:42 | [diff] [blame] | 680 | // a background_page onload chrome.tabs api call can make it into here |
| 681 | // before the browser is sufficiently initialized to return here. |
[email protected] | 0ec9203 | 2010-03-24 19:59:41 | [diff] [blame] | 682 | // A similar situation may arise during shutdown. |
| 683 | // TODO(rafaelw): Delay creation of background_page until the browser |
| 684 | // is available. http://code.google.com/p/chromium/issues/detail?id=13284 |
| 685 | return browser; |
[email protected] | b2725756 | 2009-11-16 23:28:26 | [diff] [blame] | 686 | } |
| 687 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 688 | void ExtensionFunctionDispatcher::Dispatch( |
| 689 | const ExtensionHostMsg_Request_Params& params, |
| 690 | RenderViewHost* render_view_host) { |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 691 | ExtensionService* service = profile()->GetExtensionService(); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 692 | extensions::ProcessMap* process_map = service->process_map(); |
| 693 | if (!service || !process_map) |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 694 | return; |
| 695 | |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 696 | const Extension* extension = service->extensions()->GetByID( |
| 697 | params.extension_id); |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 698 | if (!extension) |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 699 | extension = service->extensions()->GetHostedAppByURL(ExtensionURLInfo( |
| 700 | WebSecurityOrigin::createFromString(params.source_origin), |
| 701 | params.source_url)); |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 702 | |
[email protected] | 8add541 | 2011-10-01 21:02:14 | [diff] [blame] | 703 | scoped_refptr<ExtensionFunction> function( |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 704 | CreateExtensionFunction(params, extension, |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 705 | render_view_host->GetProcess()->GetID(), |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 706 | *(service->process_map()), |
| 707 | profile(), render_view_host, |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 708 | render_view_host->GetRoutingID())); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 709 | if (!function) { |
| 710 | LogFailure(extension, params.name, kAccessDenied); |
[email protected] | f82d57b5 | 2011-04-27 19:13:17 | [diff] [blame] | 711 | return; |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 712 | } |
[email protected] | f82d57b5 | 2011-04-27 19:13:17 | [diff] [blame] | 713 | |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 714 | UIThreadExtensionFunction* function_ui = |
| 715 | function->AsUIThreadExtensionFunction(); |
| 716 | if (!function_ui) { |
| 717 | NOTREACHED(); |
| 718 | return; |
| 719 | } |
| 720 | function_ui->SetRenderViewHost(render_view_host); |
| 721 | function_ui->set_dispatcher(AsWeakPtr()); |
| 722 | function_ui->set_profile(profile_); |
[email protected] | 2a8f24e | 2010-11-03 21:37:05 | [diff] [blame] | 723 | function->set_include_incognito(service->CanCrossIncognito(extension)); |
[email protected] | cb0ce1e02 | 2010-03-10 19:54:41 | [diff] [blame] | 724 | |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 725 | ExtensionsQuotaService* quota = service->quota_service(); |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 726 | if (quota->Assess(extension->id(), function, ¶ms.arguments, |
[email protected] | 8b8e7c9 | 2010-08-19 18:05:56 | [diff] [blame] | 727 | base::TimeTicks::Now())) { |
[email protected] | d070ec6 | 2010-07-27 21:28:26 | [diff] [blame] | 728 | // See crbug.com/39178. |
| 729 | ExternalProtocolHandler::PermitLaunchUrl(); |
| 730 | |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 731 | function->Run(); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 732 | LogSuccess(extension, params); |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 733 | } else { |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 734 | function->OnQuotaExceeded(); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 735 | LogFailure(extension, params.name, kQuotaExceeded); |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 736 | } |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 737 | |
| 738 | // We only adjust the keepalive count for UIThreadExtensionFunction for |
| 739 | // now, largely for simplicity's sake. This is OK because currently, only |
| 740 | // the webRequest API uses IOThreadExtensionFunction, and that API is not |
| 741 | // compatible with lazy background pages. |
| 742 | profile()->GetExtensionProcessManager()->IncrementLazyKeepaliveCount( |
| 743 | extension); |
| 744 | } |
| 745 | |
| 746 | void ExtensionFunctionDispatcher::OnExtensionFunctionCompleted( |
| 747 | const Extension* extension) { |
| 748 | profile()->GetExtensionProcessManager()->DecrementLazyKeepaliveCount( |
| 749 | extension); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 750 | } |
| 751 | |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 752 | // static |
| 753 | ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction( |
| 754 | const ExtensionHostMsg_Request_Params& params, |
| 755 | const Extension* extension, |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 756 | int requesting_process_id, |
| 757 | const extensions::ProcessMap& process_map, |
[email protected] | 67351452 | 2011-07-13 18:17:18 | [diff] [blame] | 758 | void* profile, |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 759 | IPC::Message::Sender* ipc_sender, |
| 760 | int routing_id) { |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 761 | if (!extension) { |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 762 | LOG(ERROR) << "Specified extension does not exist."; |
| 763 | SendAccessDenied(ipc_sender, routing_id, params.request_id); |
| 764 | return NULL; |
| 765 | } |
| 766 | |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 767 | if (ExtensionAPI::GetInstance()->IsPrivileged(params.name) && |
| 768 | !process_map.Contains(extension->id(), requesting_process_id)) { |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 769 | LOG(ERROR) << "Extension API called from incorrect process " |
| 770 | << requesting_process_id |
| 771 | << " from URL " << params.source_url.spec(); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 772 | SendAccessDenied(ipc_sender, routing_id, params.request_id); |
| 773 | return NULL; |
| 774 | } |
| 775 | |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 776 | if (!extension->HasAPIPermission(params.name)) { |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 777 | LOG(ERROR) << "Extension " << extension->id() << " does not have " |
| 778 | << "permission to function: " << params.name; |
| 779 | SendAccessDenied(ipc_sender, routing_id, params.request_id); |
| 780 | return NULL; |
| 781 | } |
| 782 | |
| 783 | ExtensionFunction* function = |
| 784 | FactoryRegistry::GetInstance()->NewFunction(params.name); |
| 785 | function->SetArgs(¶ms.arguments); |
| 786 | function->set_source_url(params.source_url); |
| 787 | function->set_request_id(params.request_id); |
| 788 | function->set_has_callback(params.has_callback); |
| 789 | function->set_user_gesture(params.user_gesture); |
| 790 | function->set_extension(extension); |
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 791 | function->set_profile_id(profile); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 792 | return function; |
| 793 | } |
| 794 | |
| 795 | // static |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 796 | void ExtensionFunctionDispatcher::SendAccessDenied( |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 797 | IPC::Message::Sender* ipc_sender, int routing_id, int request_id) { |
| 798 | ipc_sender->Send(new ExtensionMsg_Response( |
| 799 | routing_id, request_id, false, std::string(), |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 800 | "Access to extension API denied.")); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 801 | } |