[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 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] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 7 | #include "base/process_util.h" |
| 8 | #include "base/singleton.h" |
| 9 | #include "base/values.h" |
[email protected] | 912256b3 | 2009-09-18 09:47:35 | [diff] [blame] | 10 | #include "chrome/browser/extensions/execute_code_in_tab_function.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 11 | #include "chrome/browser/extensions/extension_bookmarks_module.h" |
[email protected] | f9391485 | 2009-05-26 06:05:40 | [diff] [blame] | 12 | #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 13 | #include "chrome/browser/extensions/extension_browser_actions_api.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 14 | #include "chrome/browser/extensions/extension_function.h" |
[email protected] | de768a83 | 2009-10-30 05:25:01 | [diff] [blame] | 15 | #include "chrome/browser/extensions/extension_history_api.h" |
[email protected] | 198bcfe | 2009-09-09 22:56:28 | [diff] [blame] | 16 | #include "chrome/browser/extensions/extension_i18n_api.h" |
[email protected] | e916901c | 2009-05-07 00:14:31 | [diff] [blame] | 17 | #include "chrome/browser/extensions/extension_message_service.h" |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 18 | #include "chrome/browser/extensions/extension_page_actions_module.h" |
[email protected] | f9391485 | 2009-05-26 06:05:40 | [diff] [blame] | 19 | #include "chrome/browser/extensions/extension_page_actions_module_constants.h" |
[email protected] | 1c1c77a5 | 2009-11-03 00:37:31 | [diff] [blame^] | 20 | #include "chrome/browser/extensions/extension_popup_api.h" |
[email protected] | 4577622 | 2009-07-15 20:21:58 | [diff] [blame] | 21 | #include "chrome/browser/extensions/extension_process_manager.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 22 | #include "chrome/browser/extensions/extension_tabs_module.h" |
[email protected] | f9391485 | 2009-05-26 06:05:40 | [diff] [blame] | 23 | #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
[email protected] | 25fd1b2e | 2009-08-17 20:57:14 | [diff] [blame] | 24 | #include "chrome/browser/extensions/extension_test_api.h" |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 25 | #include "chrome/browser/extensions/extension_toolstrip_api.h" |
[email protected] | e916901c | 2009-05-07 00:14:31 | [diff] [blame] | 26 | #include "chrome/browser/profile.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 27 | #include "chrome/browser/renderer_host/render_process_host.h" |
| 28 | #include "chrome/browser/renderer_host/render_view_host.h" |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 29 | #include "chrome/common/render_messages.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 30 | #include "chrome/common/result_codes.h" |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 31 | #include "chrome/common/url_constants.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 32 | |
| 33 | // FactoryRegistry ------------------------------------------------------------- |
| 34 | |
| 35 | namespace { |
| 36 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 37 | // Template for defining ExtensionFunctionFactory. |
| 38 | template<class T> |
| 39 | ExtensionFunction* NewExtensionFunction() { |
| 40 | return new T(); |
| 41 | } |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 42 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 43 | // Contains a list of all known extension functions and allows clients to |
| 44 | // create instances of them. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 45 | class FactoryRegistry { |
| 46 | public: |
| 47 | static FactoryRegistry* instance(); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 48 | FactoryRegistry() { ResetFunctions(); } |
| 49 | |
| 50 | // Resets all functions to their default values. |
| 51 | void ResetFunctions(); |
| 52 | |
| 53 | // Adds all function names to 'names'. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 54 | void GetAllNames(std::vector<std::string>* names); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 55 | |
| 56 | // Allows overriding of specific functions (e.g. for testing). Functions |
| 57 | // must be previously registered. Returns true if successful. |
| 58 | bool OverrideFunction(const std::string& name, |
| 59 | ExtensionFunctionFactory factory); |
| 60 | |
| 61 | // Factory method for the ExtensionFunction registered as 'name'. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 62 | ExtensionFunction* NewFunction(const std::string& name); |
| 63 | |
| 64 | private: |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 65 | template<class T> |
| 66 | void RegisterFunction() { |
| 67 | factories_[T::function_name()] = &NewExtensionFunction<T>; |
| 68 | } |
| 69 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 70 | typedef std::map<std::string, ExtensionFunctionFactory> FactoryMap; |
| 71 | FactoryMap factories_; |
| 72 | }; |
| 73 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 74 | FactoryRegistry* FactoryRegistry::instance() { |
| 75 | return Singleton<FactoryRegistry>::get(); |
| 76 | } |
| 77 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 78 | void FactoryRegistry::ResetFunctions() { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 79 | // Register all functions here. |
| 80 | |
[email protected] | e515f5d | 2009-05-05 03:05:00 | [diff] [blame] | 81 | // Windows |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 82 | RegisterFunction<GetWindowFunction>(); |
| 83 | RegisterFunction<GetCurrentWindowFunction>(); |
| 84 | RegisterFunction<GetLastFocusedWindowFunction>(); |
| 85 | RegisterFunction<GetAllWindowsFunction>(); |
| 86 | RegisterFunction<CreateWindowFunction>(); |
| 87 | RegisterFunction<UpdateWindowFunction>(); |
| 88 | RegisterFunction<RemoveWindowFunction>(); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 89 | |
[email protected] | e515f5d | 2009-05-05 03:05:00 | [diff] [blame] | 90 | // Tabs |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 91 | RegisterFunction<GetTabFunction>(); |
| 92 | RegisterFunction<GetSelectedTabFunction>(); |
| 93 | RegisterFunction<GetAllTabsInWindowFunction>(); |
| 94 | RegisterFunction<CreateTabFunction>(); |
| 95 | RegisterFunction<UpdateTabFunction>(); |
| 96 | RegisterFunction<MoveTabFunction>(); |
| 97 | RegisterFunction<RemoveTabFunction>(); |
| 98 | RegisterFunction<DetectTabLanguageFunction>(); |
| 99 | RegisterFunction<CaptureVisibleTabFunction>(); |
| 100 | RegisterFunction<TabsExecuteScriptFunction>(); |
| 101 | RegisterFunction<TabsInsertCSSFunction>(); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 102 | |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 103 | // Page Actions. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 104 | RegisterFunction<EnablePageActionFunction>(); |
| 105 | RegisterFunction<DisablePageActionFunction>(); |
[email protected] | 744ef17 | 2009-10-16 21:53:46 | [diff] [blame] | 106 | RegisterFunction<PageActionShowFunction>(); |
| 107 | RegisterFunction<PageActionHideFunction>(); |
| 108 | RegisterFunction<PageActionSetIconFunction>(); |
| 109 | RegisterFunction<PageActionSetTitleFunction>(); |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 110 | |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 111 | // Browser Actions. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 112 | RegisterFunction<BrowserActionSetIconFunction>(); |
[email protected] | 1288ba0 | 2009-10-15 00:02:24 | [diff] [blame] | 113 | RegisterFunction<BrowserActionSetTitleFunction>(); |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 114 | RegisterFunction<BrowserActionSetBadgeTextFunction>(); |
| 115 | RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>(); |
[email protected] | ec9ac0df | 2009-10-01 18:06:47 | [diff] [blame] | 116 | |
[email protected] | f7f3a5f | 2009-05-01 22:02:34 | [diff] [blame] | 117 | // Bookmarks. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 118 | RegisterFunction<GetBookmarksFunction>(); |
| 119 | RegisterFunction<GetBookmarkChildrenFunction>(); |
| 120 | RegisterFunction<GetBookmarkTreeFunction>(); |
| 121 | RegisterFunction<SearchBookmarksFunction>(); |
| 122 | RegisterFunction<RemoveBookmarkFunction>(); |
| 123 | RegisterFunction<RemoveTreeBookmarkFunction>(); |
| 124 | RegisterFunction<CreateBookmarkFunction>(); |
| 125 | RegisterFunction<MoveBookmarkFunction>(); |
| 126 | RegisterFunction<UpdateBookmarkFunction>(); |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 127 | |
[email protected] | de768a83 | 2009-10-30 05:25:01 | [diff] [blame] | 128 | // History |
| 129 | RegisterFunction<AddUrlHistoryFunction>(); |
| 130 | RegisterFunction<DeleteAllHistoryFunction>(); |
| 131 | RegisterFunction<DeleteRangeHistoryFunction>(); |
| 132 | RegisterFunction<DeleteUrlHistoryFunction>(); |
| 133 | RegisterFunction<GetVisitsHistoryFunction>(); |
| 134 | RegisterFunction<SearchHistoryFunction>(); |
| 135 | |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 136 | // Toolstrips. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 137 | RegisterFunction<ToolstripExpandFunction>(); |
| 138 | RegisterFunction<ToolstripCollapseFunction>(); |
[email protected] | 25fd1b2e | 2009-08-17 20:57:14 | [diff] [blame] | 139 | |
[email protected] | 198bcfe | 2009-09-09 22:56:28 | [diff] [blame] | 140 | // I18N. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 141 | RegisterFunction<GetAcceptLanguagesFunction>(); |
[email protected] | 198bcfe | 2009-09-09 22:56:28 | [diff] [blame] | 142 | |
[email protected] | 1c1c77a5 | 2009-11-03 00:37:31 | [diff] [blame^] | 143 | // Popup API. |
| 144 | RegisterFunction<PopupShowFunction>(); |
| 145 | |
[email protected] | 25fd1b2e | 2009-08-17 20:57:14 | [diff] [blame] | 146 | // Test. |
[email protected] | 61424c06 | 2009-10-14 23:14:59 | [diff] [blame] | 147 | RegisterFunction<ExtensionTestPassFunction>(); |
| 148 | RegisterFunction<ExtensionTestFailFunction>(); |
| 149 | RegisterFunction<ExtensionTestLogFunction>(); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 150 | } |
| 151 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 152 | void FactoryRegistry::GetAllNames(std::vector<std::string>* names) { |
| 153 | for (FactoryMap::iterator iter = factories_.begin(); |
| 154 | iter != factories_.end(); ++iter) { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 155 | names->push_back(iter->first); |
| 156 | } |
| 157 | } |
| 158 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 159 | bool FactoryRegistry::OverrideFunction(const std::string& name, |
| 160 | ExtensionFunctionFactory factory) { |
| 161 | FactoryMap::iterator iter = factories_.find(name); |
| 162 | if (iter == factories_.end()) { |
| 163 | return false; |
| 164 | } else { |
| 165 | iter->second = factory; |
| 166 | return true; |
| 167 | } |
| 168 | } |
| 169 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 170 | ExtensionFunction* FactoryRegistry::NewFunction(const std::string& name) { |
| 171 | FactoryMap::iterator iter = factories_.find(name); |
| 172 | DCHECK(iter != factories_.end()); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 173 | ExtensionFunction* function = iter->second(); |
[email protected] | 76a3db85 | 2009-07-24 02:14:56 | [diff] [blame] | 174 | function->set_name(name); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 175 | return function; |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 176 | } |
| 177 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 178 | }; // namespace |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 179 | |
| 180 | // ExtensionFunctionDispatcher ------------------------------------------------- |
| 181 | |
| 182 | void ExtensionFunctionDispatcher::GetAllFunctionNames( |
| 183 | std::vector<std::string>* names) { |
| 184 | FactoryRegistry::instance()->GetAllNames(names); |
| 185 | } |
| 186 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 187 | bool ExtensionFunctionDispatcher::OverrideFunction( |
| 188 | const std::string& name, ExtensionFunctionFactory factory) { |
| 189 | return FactoryRegistry::instance()->OverrideFunction(name, factory); |
| 190 | } |
| 191 | |
| 192 | void ExtensionFunctionDispatcher::ResetFunctions() { |
| 193 | FactoryRegistry::instance()->ResetFunctions(); |
| 194 | } |
| 195 | |
[email protected] | 811bfe3 | 2009-07-01 08:46:25 | [diff] [blame] | 196 | std::set<ExtensionFunctionDispatcher*>* |
| 197 | ExtensionFunctionDispatcher::all_instances() { |
| 198 | static std::set<ExtensionFunctionDispatcher*> instances; |
| 199 | return &instances; |
| 200 | } |
| 201 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 202 | ExtensionFunctionDispatcher::ExtensionFunctionDispatcher( |
| 203 | RenderViewHost* render_view_host, |
[email protected] | 7eecaed5 | 2009-05-07 21:44:12 | [diff] [blame] | 204 | Delegate* delegate, |
[email protected] | 811bfe3 | 2009-07-01 08:46:25 | [diff] [blame] | 205 | const GURL& url) |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 206 | : render_view_host_(render_view_host), |
[email protected] | 7eecaed5 | 2009-05-07 21:44:12 | [diff] [blame] | 207 | delegate_(delegate), |
[email protected] | 811bfe3 | 2009-07-01 08:46:25 | [diff] [blame] | 208 | url_(url), |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 209 | ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) { |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 210 | // TODO(erikkay) should we do something for these errors in Release? |
| 211 | DCHECK(url.SchemeIs(chrome::kExtensionScheme)); |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 212 | |
| 213 | Extension* extension = |
| 214 | profile()->GetExtensionsService()->GetExtensionByURL(url); |
| 215 | DCHECK(extension); |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 216 | |
[email protected] | 811bfe3 | 2009-07-01 08:46:25 | [diff] [blame] | 217 | all_instances()->insert(this); |
[email protected] | 0f605396 | 2009-07-09 19:26:35 | [diff] [blame] | 218 | |
[email protected] | 4577622 | 2009-07-15 20:21:58 | [diff] [blame] | 219 | // Notify the ExtensionProcessManager that the view was created. |
| 220 | ExtensionProcessManager* epm = profile()->GetExtensionProcessManager(); |
| 221 | epm->RegisterExtensionProcess(extension_id(), |
[email protected] | 76543b9 | 2009-08-31 17:27:45 | [diff] [blame] | 222 | render_view_host->process()->id()); |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 223 | |
| 224 | // Update the extension permissions. Doing this each time we create an EFD |
| 225 | // ensures that new processes are informed of permissions for newly installed |
| 226 | // extensions. |
[email protected] | cccf9093 | 2009-08-23 17:56:25 | [diff] [blame] | 227 | render_view_host->Send(new ViewMsg_Extension_SetAPIPermissions( |
[email protected] | 3550635 | 2009-08-07 18:58:19 | [diff] [blame] | 228 | extension->id(), extension->api_permissions())); |
[email protected] | cccf9093 | 2009-08-23 17:56:25 | [diff] [blame] | 229 | render_view_host->Send(new ViewMsg_Extension_SetHostPermissions( |
| 230 | extension->url(), extension->host_permissions())); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 231 | } |
| 232 | |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 233 | ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() { |
[email protected] | 811bfe3 | 2009-07-01 08:46:25 | [diff] [blame] | 234 | all_instances()->erase(this); |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 235 | peer_->dispatcher_ = NULL; |
| 236 | } |
| 237 | |
[email protected] | 7eecaed5 | 2009-05-07 21:44:12 | [diff] [blame] | 238 | Browser* ExtensionFunctionDispatcher::GetBrowser() { |
[email protected] | 4ba60e2 | 2009-08-14 21:02:11 | [diff] [blame] | 239 | return delegate_->GetBrowser(); |
[email protected] | 7eecaed5 | 2009-05-07 21:44:12 | [diff] [blame] | 240 | } |
| 241 | |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 242 | ExtensionHost* ExtensionFunctionDispatcher::GetExtensionHost() { |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 243 | return delegate_->GetExtensionHost(); |
| 244 | } |
| 245 | |
[email protected] | c7ad50f | 2009-09-11 06:28:15 | [diff] [blame] | 246 | Extension* ExtensionFunctionDispatcher::GetExtension() { |
| 247 | ExtensionsService* service = profile()->GetExtensionsService(); |
| 248 | DCHECK(service); |
| 249 | |
| 250 | Extension* extension = service->GetExtensionById(extension_id()); |
| 251 | DCHECK(extension); |
| 252 | |
| 253 | return extension; |
| 254 | } |
| 255 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 256 | void ExtensionFunctionDispatcher::HandleRequest(const std::string& name, |
[email protected] | e4dad9fb | 2009-10-06 18:15:58 | [diff] [blame] | 257 | const Value* args, |
[email protected] | c661918 | 2009-05-12 14:59:32 | [diff] [blame] | 258 | int request_id, |
| 259 | bool has_callback) { |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 260 | scoped_refptr<ExtensionFunction> function( |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 261 | FactoryRegistry::instance()->NewFunction(name)); |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 262 | function->set_dispatcher_peer(peer_); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 263 | function->SetArgs(args); |
[email protected] | c661918 | 2009-05-12 14:59:32 | [diff] [blame] | 264 | function->set_request_id(request_id); |
| 265 | function->set_has_callback(has_callback); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 266 | function->Run(); |
| 267 | } |
| 268 | |
[email protected] | c661918 | 2009-05-12 14:59:32 | [diff] [blame] | 269 | void ExtensionFunctionDispatcher::SendResponse(ExtensionFunction* function, |
| 270 | bool success) { |
[email protected] | c661918 | 2009-05-12 14:59:32 | [diff] [blame] | 271 | render_view_host_->SendExtensionResponse(function->request_id(), success, |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 272 | function->GetResult(), function->GetError()); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | void ExtensionFunctionDispatcher::HandleBadMessage(ExtensionFunction* api) { |
[email protected] | 25fd1b2e | 2009-08-17 20:57:14 | [diff] [blame] | 276 | LOG(ERROR) << "bad extension message " << |
[email protected] | 76543b9 | 2009-08-31 17:27:45 | [diff] [blame] | 277 | api->name() << |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 278 | " : terminating renderer."; |
| 279 | if (RenderProcessHost::run_renderer_in_process()) { |
| 280 | // In single process mode it is better if we don't suicide but just crash. |
| 281 | CHECK(false); |
| 282 | } else { |
| 283 | NOTREACHED(); |
| 284 | base::KillProcess(render_view_host_->process()->process().handle(), |
| 285 | ResultCodes::KILLED_BAD_MESSAGE, false); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | Profile* ExtensionFunctionDispatcher::profile() { |
| 290 | return render_view_host_->process()->profile(); |
| 291 | } |