blob: 02facbdf3221c7369349ebcbc00d40773970e298 [file] [log] [blame]
[email protected]bfdffe2b2009-04-24 22:05:351// 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]bfdffe2b2009-04-24 22:05:357#include "base/process_util.h"
8#include "base/singleton.h"
9#include "base/values.h"
[email protected]a95631cb2009-12-10 01:59:1110#include "chrome/browser/browser.h"
11#include "chrome/browser/browser_window.h"
[email protected]912256b32009-09-18 09:47:3512#include "chrome/browser/extensions/execute_code_in_tab_function.h"
[email protected]5cbe1e22010-01-30 01:18:5613#include "chrome/browser/extensions/extension_accessibility_api.h"
[email protected]9dd97bc2010-01-14 01:40:0414#include "chrome/browser/extensions/extension_bookmark_manager_api.h"
[email protected]bfdffe2b2009-04-24 22:05:3515#include "chrome/browser/extensions/extension_bookmarks_module.h"
[email protected]f93914852009-05-26 06:05:4016#include "chrome/browser/extensions/extension_bookmarks_module_constants.h"
[email protected]ec9ac0df2009-10-01 18:06:4717#include "chrome/browser/extensions/extension_browser_actions_api.h"
[email protected]b27257562009-11-16 23:28:2618#include "chrome/browser/extensions/extension_dom_ui.h"
[email protected]bfdffe2b2009-04-24 22:05:3519#include "chrome/browser/extensions/extension_function.h"
[email protected]de768a832009-10-30 05:25:0120#include "chrome/browser/extensions/extension_history_api.h"
[email protected]198bcfe2009-09-09 22:56:2821#include "chrome/browser/extensions/extension_i18n_api.h"
[email protected]e916901c2009-05-07 00:14:3122#include "chrome/browser/extensions/extension_message_service.h"
[email protected]438772df2010-02-26 18:08:4323#include "chrome/browser/extensions/extension_metrics_module.h"
[email protected]f7f3a5f2009-05-01 22:02:3424#include "chrome/browser/extensions/extension_page_actions_module.h"
[email protected]f93914852009-05-26 06:05:4025#include "chrome/browser/extensions/extension_page_actions_module_constants.h"
[email protected]1c1c77a52009-11-03 00:37:3126#include "chrome/browser/extensions/extension_popup_api.h"
[email protected]45776222009-07-15 20:21:5827#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]381162b2010-01-28 17:29:3528#include "chrome/browser/extensions/extension_processes_api.h"
[email protected]bfdffe2b2009-04-24 22:05:3529#include "chrome/browser/extensions/extension_tabs_module.h"
[email protected]f93914852009-05-26 06:05:4030#include "chrome/browser/extensions/extension_tabs_module_constants.h"
[email protected]25fd1b2e2009-08-17 20:57:1431#include "chrome/browser/extensions/extension_test_api.h"
[email protected]9c45b7182009-08-04 16:44:4332#include "chrome/browser/extensions/extension_toolstrip_api.h"
[email protected]d13950e2009-12-04 01:43:0233#include "chrome/browser/extensions/extensions_quota_service.h"
[email protected]b1748b1d82009-11-30 20:32:5634#include "chrome/browser/extensions/extensions_service.h"
[email protected]e916901c2009-05-07 00:14:3135#include "chrome/browser/profile.h"
[email protected]bfdffe2b2009-04-24 22:05:3536#include "chrome/browser/renderer_host/render_process_host.h"
37#include "chrome/browser/renderer_host/render_view_host.h"
[email protected]35506352009-08-07 18:58:1938#include "chrome/common/render_messages.h"
[email protected]bfdffe2b2009-04-24 22:05:3539#include "chrome/common/result_codes.h"
[email protected]9c45b7182009-08-04 16:44:4340#include "chrome/common/url_constants.h"
[email protected]bfdffe2b2009-04-24 22:05:3541
42// FactoryRegistry -------------------------------------------------------------
43
44namespace {
45
[email protected]b83e4602009-05-15 22:58:3346// Template for defining ExtensionFunctionFactory.
47template<class T>
48ExtensionFunction* NewExtensionFunction() {
49 return new T();
50}
[email protected]bfdffe2b2009-04-24 22:05:3551
[email protected]b83e4602009-05-15 22:58:3352// Contains a list of all known extension functions and allows clients to
53// create instances of them.
[email protected]bfdffe2b2009-04-24 22:05:3554class FactoryRegistry {
55 public:
56 static FactoryRegistry* instance();
[email protected]b83e4602009-05-15 22:58:3357 FactoryRegistry() { ResetFunctions(); }
58
59 // Resets all functions to their default values.
60 void ResetFunctions();
61
62 // Adds all function names to 'names'.
[email protected]bfdffe2b2009-04-24 22:05:3563 void GetAllNames(std::vector<std::string>* names);
[email protected]b83e4602009-05-15 22:58:3364
65 // Allows overriding of specific functions (e.g. for testing). Functions
66 // must be previously registered. Returns true if successful.
67 bool OverrideFunction(const std::string& name,
68 ExtensionFunctionFactory factory);
69
70 // Factory method for the ExtensionFunction registered as 'name'.
[email protected]bfdffe2b2009-04-24 22:05:3571 ExtensionFunction* NewFunction(const std::string& name);
72
73 private:
[email protected]61424c062009-10-14 23:14:5974 template<class T>
75 void RegisterFunction() {
76 factories_[T::function_name()] = &NewExtensionFunction<T>;
77 }
78
[email protected]bfdffe2b2009-04-24 22:05:3579 typedef std::map<std::string, ExtensionFunctionFactory> FactoryMap;
80 FactoryMap factories_;
81};
82
[email protected]bfdffe2b2009-04-24 22:05:3583FactoryRegistry* FactoryRegistry::instance() {
84 return Singleton<FactoryRegistry>::get();
85}
86
[email protected]b83e4602009-05-15 22:58:3387void FactoryRegistry::ResetFunctions() {
[email protected]bfdffe2b2009-04-24 22:05:3588 // Register all functions here.
89
[email protected]e515f5d2009-05-05 03:05:0090 // Windows
[email protected]61424c062009-10-14 23:14:5991 RegisterFunction<GetWindowFunction>();
92 RegisterFunction<GetCurrentWindowFunction>();
93 RegisterFunction<GetLastFocusedWindowFunction>();
94 RegisterFunction<GetAllWindowsFunction>();
95 RegisterFunction<CreateWindowFunction>();
96 RegisterFunction<UpdateWindowFunction>();
97 RegisterFunction<RemoveWindowFunction>();
[email protected]b83e4602009-05-15 22:58:3398
[email protected]e515f5d2009-05-05 03:05:0099 // Tabs
[email protected]61424c062009-10-14 23:14:59100 RegisterFunction<GetTabFunction>();
101 RegisterFunction<GetSelectedTabFunction>();
102 RegisterFunction<GetAllTabsInWindowFunction>();
103 RegisterFunction<CreateTabFunction>();
104 RegisterFunction<UpdateTabFunction>();
105 RegisterFunction<MoveTabFunction>();
106 RegisterFunction<RemoveTabFunction>();
107 RegisterFunction<DetectTabLanguageFunction>();
108 RegisterFunction<CaptureVisibleTabFunction>();
109 RegisterFunction<TabsExecuteScriptFunction>();
110 RegisterFunction<TabsInsertCSSFunction>();
[email protected]bfdffe2b2009-04-24 22:05:35111
[email protected]f7f3a5f2009-05-01 22:02:34112 // Page Actions.
[email protected]61424c062009-10-14 23:14:59113 RegisterFunction<EnablePageActionFunction>();
114 RegisterFunction<DisablePageActionFunction>();
[email protected]744ef172009-10-16 21:53:46115 RegisterFunction<PageActionShowFunction>();
116 RegisterFunction<PageActionHideFunction>();
117 RegisterFunction<PageActionSetIconFunction>();
118 RegisterFunction<PageActionSetTitleFunction>();
[email protected]e478d6702010-01-28 00:10:29119 RegisterFunction<PageActionSetPopupFunction>();
[email protected]f7f3a5f2009-05-01 22:02:34120
[email protected]ec9ac0df2009-10-01 18:06:47121 // Browser Actions.
[email protected]61424c062009-10-14 23:14:59122 RegisterFunction<BrowserActionSetIconFunction>();
[email protected]1288ba02009-10-15 00:02:24123 RegisterFunction<BrowserActionSetTitleFunction>();
[email protected]61424c062009-10-14 23:14:59124 RegisterFunction<BrowserActionSetBadgeTextFunction>();
125 RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>();
[email protected]85ae9592010-02-03 20:58:50126 RegisterFunction<BrowserActionSetPopupFunction>();
[email protected]ec9ac0df2009-10-01 18:06:47127
[email protected]f7f3a5f2009-05-01 22:02:34128 // Bookmarks.
[email protected]61424c062009-10-14 23:14:59129 RegisterFunction<GetBookmarksFunction>();
130 RegisterFunction<GetBookmarkChildrenFunction>();
[email protected]a3c94c712009-12-18 19:23:55131 RegisterFunction<GetBookmarkRecentFunction>();
[email protected]61424c062009-10-14 23:14:59132 RegisterFunction<GetBookmarkTreeFunction>();
133 RegisterFunction<SearchBookmarksFunction>();
134 RegisterFunction<RemoveBookmarkFunction>();
135 RegisterFunction<RemoveTreeBookmarkFunction>();
136 RegisterFunction<CreateBookmarkFunction>();
137 RegisterFunction<MoveBookmarkFunction>();
138 RegisterFunction<UpdateBookmarkFunction>();
[email protected]9c45b7182009-08-04 16:44:43139
[email protected]9dd97bc2010-01-14 01:40:04140 // BookmarkManager
141 RegisterFunction<CopyBookmarkManagerFunction>();
142 RegisterFunction<CutBookmarkManagerFunction>();
143 RegisterFunction<PasteBookmarkManagerFunction>();
[email protected]03b3bbf2010-01-29 23:54:57144 RegisterFunction<CanPasteBookmarkManagerFunction>();
[email protected]cb6cf792010-01-28 00:04:56145 RegisterFunction<ImportBookmarksFunction>();
146 RegisterFunction<ExportBookmarksFunction>();
[email protected]d406e2e2010-01-30 21:45:18147 RegisterFunction<SortChildrenBookmarkManagerFunction>();
[email protected]9dd97bc2010-01-14 01:40:04148 RegisterFunction<BookmarkManagerGetStringsFunction>();
[email protected]ced90ae12010-02-20 02:06:16149 RegisterFunction<StartDragBookmarkManagerFunction>();
150 RegisterFunction<DropBookmarkManagerFunction>();
[email protected]9dd97bc2010-01-14 01:40:04151
[email protected]de768a832009-10-30 05:25:01152 // History
153 RegisterFunction<AddUrlHistoryFunction>();
154 RegisterFunction<DeleteAllHistoryFunction>();
155 RegisterFunction<DeleteRangeHistoryFunction>();
156 RegisterFunction<DeleteUrlHistoryFunction>();
157 RegisterFunction<GetVisitsHistoryFunction>();
158 RegisterFunction<SearchHistoryFunction>();
159
[email protected]9c45b7182009-08-04 16:44:43160 // Toolstrips.
[email protected]61424c062009-10-14 23:14:59161 RegisterFunction<ToolstripExpandFunction>();
162 RegisterFunction<ToolstripCollapseFunction>();
[email protected]25fd1b2e2009-08-17 20:57:14163
[email protected]198bcfe2009-09-09 22:56:28164 // I18N.
[email protected]61424c062009-10-14 23:14:59165 RegisterFunction<GetAcceptLanguagesFunction>();
[email protected]198bcfe2009-09-09 22:56:28166
[email protected]1c1c77a52009-11-03 00:37:31167 // Popup API.
168 RegisterFunction<PopupShowFunction>();
169
[email protected]381162b2010-01-28 17:29:35170 // Processes.
171 RegisterFunction<GetProcessForTabFunction>();
172
[email protected]438772df2010-02-26 18:08:43173 // Metrics.
[email protected]cf25e4d2010-03-12 21:19:34174 RegisterFunction<MetricsRecordUserActionFunction>();
175 RegisterFunction<MetricsRecordValueFunction>();
176 RegisterFunction<MetricsRecordPercentageFunction>();
177 RegisterFunction<MetricsRecordCountFunction>();
178 RegisterFunction<MetricsRecordSmallCountFunction>();
179 RegisterFunction<MetricsRecordMediumCountFunction>();
180 RegisterFunction<MetricsRecordTimeFunction>();
181 RegisterFunction<MetricsRecordMediumTimeFunction>();
182 RegisterFunction<MetricsRecordLongTimeFunction>();
[email protected]438772df2010-02-26 18:08:43183
[email protected]25fd1b2e2009-08-17 20:57:14184 // Test.
[email protected]61424c062009-10-14 23:14:59185 RegisterFunction<ExtensionTestPassFunction>();
186 RegisterFunction<ExtensionTestFailFunction>();
187 RegisterFunction<ExtensionTestLogFunction>();
[email protected]d13950e2009-12-04 01:43:02188 RegisterFunction<ExtensionTestQuotaResetFunction>();
[email protected]db7331a2010-02-25 22:10:50189 RegisterFunction<ExtensionTestCreateIncognitoTabFunction>();
[email protected]5cbe1e22010-01-30 01:18:56190
191 // Accessibility.
192 RegisterFunction<GetFocusedControlFunction>();
193 RegisterFunction<SetAccessibilityEnabledFunction>();
[email protected]bfdffe2b2009-04-24 22:05:35194}
195
[email protected]b83e4602009-05-15 22:58:33196void FactoryRegistry::GetAllNames(std::vector<std::string>* names) {
197 for (FactoryMap::iterator iter = factories_.begin();
198 iter != factories_.end(); ++iter) {
[email protected]bfdffe2b2009-04-24 22:05:35199 names->push_back(iter->first);
200 }
201}
202
[email protected]b83e4602009-05-15 22:58:33203bool FactoryRegistry::OverrideFunction(const std::string& name,
204 ExtensionFunctionFactory factory) {
205 FactoryMap::iterator iter = factories_.find(name);
206 if (iter == factories_.end()) {
207 return false;
208 } else {
209 iter->second = factory;
210 return true;
211 }
212}
213
[email protected]bfdffe2b2009-04-24 22:05:35214ExtensionFunction* FactoryRegistry::NewFunction(const std::string& name) {
215 FactoryMap::iterator iter = factories_.find(name);
216 DCHECK(iter != factories_.end());
[email protected]b83e4602009-05-15 22:58:33217 ExtensionFunction* function = iter->second();
[email protected]76a3db852009-07-24 02:14:56218 function->set_name(name);
[email protected]b83e4602009-05-15 22:58:33219 return function;
[email protected]bfdffe2b2009-04-24 22:05:35220}
221
[email protected]b83e4602009-05-15 22:58:33222}; // namespace
[email protected]bfdffe2b2009-04-24 22:05:35223
[email protected]a95631cb2009-12-10 01:59:11224// ExtensionFunctionDispatcher::Delegate ---------------------------------------
225
226gfx::NativeWindow ExtensionFunctionDispatcher::Delegate::
227 GetFrameNativeWindow() {
[email protected]db7331a2010-02-25 22:10:50228 Browser* browser = GetBrowser(true);
[email protected]a95631cb2009-12-10 01:59:11229 // If a browser is bound to this dispatcher, then return the widget hosting
230 // the window. Extensions hosted in ExternalTabContainer objects may not
231 // have a running browser instance.
232 if (browser)
233 return browser->window()->GetNativeHandle();
234
235 return NULL;
236}
237
[email protected]bfdffe2b2009-04-24 22:05:35238// ExtensionFunctionDispatcher -------------------------------------------------
239
240void ExtensionFunctionDispatcher::GetAllFunctionNames(
241 std::vector<std::string>* names) {
242 FactoryRegistry::instance()->GetAllNames(names);
243}
244
[email protected]b83e4602009-05-15 22:58:33245bool ExtensionFunctionDispatcher::OverrideFunction(
246 const std::string& name, ExtensionFunctionFactory factory) {
247 return FactoryRegistry::instance()->OverrideFunction(name, factory);
248}
249
250void ExtensionFunctionDispatcher::ResetFunctions() {
251 FactoryRegistry::instance()->ResetFunctions();
252}
253
[email protected]811bfe32009-07-01 08:46:25254std::set<ExtensionFunctionDispatcher*>*
255 ExtensionFunctionDispatcher::all_instances() {
256 static std::set<ExtensionFunctionDispatcher*> instances;
257 return &instances;
258}
259
[email protected]bfdffe2b2009-04-24 22:05:35260ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
261 RenderViewHost* render_view_host,
[email protected]7eecaed52009-05-07 21:44:12262 Delegate* delegate,
[email protected]811bfe32009-07-01 08:46:25263 const GURL& url)
[email protected]ebc1b682010-03-06 00:22:30264 : profile_(render_view_host->process()->profile()),
[email protected]68f07912010-03-05 18:33:58265 render_view_host_(render_view_host),
[email protected]7eecaed52009-05-07 21:44:12266 delegate_(delegate),
[email protected]811bfe32009-07-01 08:46:25267 url_(url),
[email protected]32dda362009-06-05 19:07:01268 ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) {
[email protected]9c45b7182009-08-04 16:44:43269 // TODO(erikkay) should we do something for these errors in Release?
270 DCHECK(url.SchemeIs(chrome::kExtensionScheme));
[email protected]35506352009-08-07 18:58:19271
272 Extension* extension =
273 profile()->GetExtensionsService()->GetExtensionByURL(url);
274 DCHECK(extension);
[email protected]9c45b7182009-08-04 16:44:43275
[email protected]811bfe32009-07-01 08:46:25276 all_instances()->insert(this);
[email protected]0f6053962009-07-09 19:26:35277
[email protected]45776222009-07-15 20:21:58278 // Notify the ExtensionProcessManager that the view was created.
279 ExtensionProcessManager* epm = profile()->GetExtensionProcessManager();
280 epm->RegisterExtensionProcess(extension_id(),
[email protected]76543b92009-08-31 17:27:45281 render_view_host->process()->id());
[email protected]35506352009-08-07 18:58:19282
[email protected]db7331a2010-02-25 22:10:50283 bool incognito_enabled =
[email protected]cb0ce1e022010-03-10 19:54:41284 profile()->GetExtensionsService()->IsIncognitoEnabled(extension);
[email protected]db7331a2010-02-25 22:10:50285
[email protected]35506352009-08-07 18:58:19286 // Update the extension permissions. Doing this each time we create an EFD
287 // ensures that new processes are informed of permissions for newly installed
288 // extensions.
[email protected]cccf90932009-08-23 17:56:25289 render_view_host->Send(new ViewMsg_Extension_SetAPIPermissions(
[email protected]35506352009-08-07 18:58:19290 extension->id(), extension->api_permissions()));
[email protected]cccf90932009-08-23 17:56:25291 render_view_host->Send(new ViewMsg_Extension_SetHostPermissions(
292 extension->url(), extension->host_permissions()));
[email protected]db7331a2010-02-25 22:10:50293 render_view_host->Send(new ViewMsg_Extension_ExtensionSetIncognitoEnabled(
294 extension->id(), incognito_enabled));
[email protected]68f07912010-03-05 18:33:58295
296 NotificationService::current()->Notify(
297 NotificationType::EXTENSION_FUNCTION_DISPATCHER_CREATED,
298 Source<Profile>(profile_),
299 Details<ExtensionFunctionDispatcher>(this));
[email protected]bfdffe2b2009-04-24 22:05:35300}
301
[email protected]32dda362009-06-05 19:07:01302ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() {
[email protected]811bfe32009-07-01 08:46:25303 all_instances()->erase(this);
[email protected]32dda362009-06-05 19:07:01304 peer_->dispatcher_ = NULL;
[email protected]68f07912010-03-05 18:33:58305
306 NotificationService::current()->Notify(
307 NotificationType::EXTENSION_FUNCTION_DISPATCHER_DESTROYED,
308 Source<Profile>(profile_),
309 Details<ExtensionFunctionDispatcher>(this));
[email protected]32dda362009-06-05 19:07:01310}
311
[email protected]db7331a2010-02-25 22:10:50312Browser* ExtensionFunctionDispatcher::GetBrowser(bool include_incognito) {
313 return delegate_->GetBrowser(include_incognito);
[email protected]7eecaed52009-05-07 21:44:12314}
315
[email protected]b27257562009-11-16 23:28:26316ExtensionPopupHost* ExtensionFunctionDispatcher::GetPopupHost() {
317 ExtensionHost* extension_host = GetExtensionHost();
318 if (extension_host) {
319 DCHECK(!GetExtensionDOMUI()) <<
320 "Function dispatcher registered in too many environments.";
321 return extension_host->popup_host();
322 } else {
323 ExtensionDOMUI* dom_ui = GetExtensionDOMUI();
324 return dom_ui->popup_host();
325 }
326}
327
[email protected]9c45b7182009-08-04 16:44:43328ExtensionHost* ExtensionFunctionDispatcher::GetExtensionHost() {
[email protected]9c45b7182009-08-04 16:44:43329 return delegate_->GetExtensionHost();
330}
331
[email protected]b27257562009-11-16 23:28:26332ExtensionDOMUI* ExtensionFunctionDispatcher::GetExtensionDOMUI() {
333 return delegate_->GetExtensionDOMUI();
334}
335
[email protected]c7ad50f2009-09-11 06:28:15336Extension* ExtensionFunctionDispatcher::GetExtension() {
337 ExtensionsService* service = profile()->GetExtensionsService();
338 DCHECK(service);
339
[email protected]61b411612009-11-10 23:17:41340 Extension* extension = service->GetExtensionById(extension_id(), false);
[email protected]c7ad50f2009-09-11 06:28:15341 DCHECK(extension);
342
343 return extension;
344}
345
[email protected]bfdffe2b2009-04-24 22:05:35346void ExtensionFunctionDispatcher::HandleRequest(const std::string& name,
[email protected]e4dad9fb2009-10-06 18:15:58347 const Value* args,
[email protected]c6619182009-05-12 14:59:32348 int request_id,
349 bool has_callback) {
[email protected]32dda362009-06-05 19:07:01350 scoped_refptr<ExtensionFunction> function(
[email protected]bfdffe2b2009-04-24 22:05:35351 FactoryRegistry::instance()->NewFunction(name));
[email protected]32dda362009-06-05 19:07:01352 function->set_dispatcher_peer(peer_);
[email protected]b83e4602009-05-15 22:58:33353 function->SetArgs(args);
[email protected]c6619182009-05-12 14:59:32354 function->set_request_id(request_id);
355 function->set_has_callback(has_callback);
[email protected]d13950e2009-12-04 01:43:02356 ExtensionsService* service = profile()->GetExtensionsService();
357 DCHECK(service);
[email protected]cb0ce1e022010-03-10 19:54:41358 Extension* extension = service->GetExtensionById(extension_id(), false);
359 DCHECK(extension);
360 function->set_include_incognito(service->IsIncognitoEnabled(extension));
361
[email protected]d13950e2009-12-04 01:43:02362 ExtensionsQuotaService* quota = service->quota_service();
363 if (quota->Assess(extension_id(), function, args, base::TimeTicks::Now())) {
364 function->Run();
365 } else {
366 render_view_host_->SendExtensionResponse(function->request_id(), false,
367 std::string(), QuotaLimitHeuristic::kGenericOverQuotaError);
368 }
[email protected]bfdffe2b2009-04-24 22:05:35369}
370
[email protected]c6619182009-05-12 14:59:32371void ExtensionFunctionDispatcher::SendResponse(ExtensionFunction* function,
372 bool success) {
[email protected]c6619182009-05-12 14:59:32373 render_view_host_->SendExtensionResponse(function->request_id(), success,
[email protected]b83e4602009-05-15 22:58:33374 function->GetResult(), function->GetError());
[email protected]bfdffe2b2009-04-24 22:05:35375}
376
377void ExtensionFunctionDispatcher::HandleBadMessage(ExtensionFunction* api) {
[email protected]25fd1b2e2009-08-17 20:57:14378 LOG(ERROR) << "bad extension message " <<
[email protected]76543b92009-08-31 17:27:45379 api->name() <<
[email protected]bfdffe2b2009-04-24 22:05:35380 " : terminating renderer.";
381 if (RenderProcessHost::run_renderer_in_process()) {
382 // In single process mode it is better if we don't suicide but just crash.
383 CHECK(false);
384 } else {
385 NOTREACHED();
[email protected]201b2732009-11-13 18:57:46386 base::KillProcess(render_view_host_->process()->GetHandle(),
[email protected]bfdffe2b2009-04-24 22:05:35387 ResultCodes::KILLED_BAD_MESSAGE, false);
388 }
389}
390
391Profile* ExtensionFunctionDispatcher::profile() {
[email protected]68f07912010-03-05 18:33:58392 return profile_;
[email protected]bfdffe2b2009-04-24 22:05:35393}
[email protected]a95631cb2009-12-10 01:59:11394
395gfx::NativeWindow ExtensionFunctionDispatcher::GetFrameNativeWindow() {
396 return delegate_ ? delegate_->GetFrameNativeWindow() : NULL;
397}