blob: 1e6bee11ddfe51a86267595bc9965a384d242f64 [file] [log] [blame]
[email protected]f34e79632010-03-17 02:34:081// Copyright (c) 2010 The Chromium Authors. All rights reserved.
[email protected]bfdffe2b2009-04-24 22:05:352// 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]f5205412010-03-16 00:19:3421#include "chrome/browser/extensions/extension_idle_api.h"
[email protected]198bcfe2009-09-09 22:56:2822#include "chrome/browser/extensions/extension_i18n_api.h"
[email protected]f34e79632010-03-17 02:34:0823#include "chrome/browser/extensions/extension_infobar_module.h"
[email protected]e916901c2009-05-07 00:14:3124#include "chrome/browser/extensions/extension_message_service.h"
[email protected]438772df2010-02-26 18:08:4325#include "chrome/browser/extensions/extension_metrics_module.h"
[email protected]f7f3a5f2009-05-01 22:02:3426#include "chrome/browser/extensions/extension_page_actions_module.h"
[email protected]f93914852009-05-26 06:05:4027#include "chrome/browser/extensions/extension_page_actions_module_constants.h"
[email protected]1c1c77a52009-11-03 00:37:3128#include "chrome/browser/extensions/extension_popup_api.h"
[email protected]45776222009-07-15 20:21:5829#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]381162b2010-01-28 17:29:3530#include "chrome/browser/extensions/extension_processes_api.h"
[email protected]bfdffe2b2009-04-24 22:05:3531#include "chrome/browser/extensions/extension_tabs_module.h"
[email protected]f93914852009-05-26 06:05:4032#include "chrome/browser/extensions/extension_tabs_module_constants.h"
[email protected]25fd1b2e2009-08-17 20:57:1433#include "chrome/browser/extensions/extension_test_api.h"
[email protected]9c45b7182009-08-04 16:44:4334#include "chrome/browser/extensions/extension_toolstrip_api.h"
[email protected]d13950e2009-12-04 01:43:0235#include "chrome/browser/extensions/extensions_quota_service.h"
[email protected]b1748b1d82009-11-30 20:32:5636#include "chrome/browser/extensions/extensions_service.h"
[email protected]e916901c2009-05-07 00:14:3137#include "chrome/browser/profile.h"
[email protected]bfdffe2b2009-04-24 22:05:3538#include "chrome/browser/renderer_host/render_process_host.h"
39#include "chrome/browser/renderer_host/render_view_host.h"
[email protected]35506352009-08-07 18:58:1940#include "chrome/common/render_messages.h"
[email protected]bfdffe2b2009-04-24 22:05:3541#include "chrome/common/result_codes.h"
[email protected]9c45b7182009-08-04 16:44:4342#include "chrome/common/url_constants.h"
[email protected]bfdffe2b2009-04-24 22:05:3543
44// FactoryRegistry -------------------------------------------------------------
45
46namespace {
47
[email protected]b83e4602009-05-15 22:58:3348// Template for defining ExtensionFunctionFactory.
49template<class T>
50ExtensionFunction* NewExtensionFunction() {
51 return new T();
52}
[email protected]bfdffe2b2009-04-24 22:05:3553
[email protected]b83e4602009-05-15 22:58:3354// Contains a list of all known extension functions and allows clients to
55// create instances of them.
[email protected]bfdffe2b2009-04-24 22:05:3556class FactoryRegistry {
57 public:
58 static FactoryRegistry* instance();
[email protected]b83e4602009-05-15 22:58:3359 FactoryRegistry() { ResetFunctions(); }
60
61 // Resets all functions to their default values.
62 void ResetFunctions();
63
64 // Adds all function names to 'names'.
[email protected]bfdffe2b2009-04-24 22:05:3565 void GetAllNames(std::vector<std::string>* names);
[email protected]b83e4602009-05-15 22:58:3366
67 // Allows overriding of specific functions (e.g. for testing). Functions
68 // must be previously registered. Returns true if successful.
69 bool OverrideFunction(const std::string& name,
70 ExtensionFunctionFactory factory);
71
72 // Factory method for the ExtensionFunction registered as 'name'.
[email protected]bfdffe2b2009-04-24 22:05:3573 ExtensionFunction* NewFunction(const std::string& name);
74
75 private:
[email protected]61424c062009-10-14 23:14:5976 template<class T>
77 void RegisterFunction() {
78 factories_[T::function_name()] = &NewExtensionFunction<T>;
79 }
80
[email protected]bfdffe2b2009-04-24 22:05:3581 typedef std::map<std::string, ExtensionFunctionFactory> FactoryMap;
82 FactoryMap factories_;
83};
84
[email protected]bfdffe2b2009-04-24 22:05:3585FactoryRegistry* FactoryRegistry::instance() {
86 return Singleton<FactoryRegistry>::get();
87}
88
[email protected]b83e4602009-05-15 22:58:3389void FactoryRegistry::ResetFunctions() {
[email protected]bfdffe2b2009-04-24 22:05:3590 // Register all functions here.
91
[email protected]e515f5d2009-05-05 03:05:0092 // Windows
[email protected]61424c062009-10-14 23:14:5993 RegisterFunction<GetWindowFunction>();
94 RegisterFunction<GetCurrentWindowFunction>();
95 RegisterFunction<GetLastFocusedWindowFunction>();
96 RegisterFunction<GetAllWindowsFunction>();
97 RegisterFunction<CreateWindowFunction>();
98 RegisterFunction<UpdateWindowFunction>();
99 RegisterFunction<RemoveWindowFunction>();
[email protected]b83e4602009-05-15 22:58:33100
[email protected]e515f5d2009-05-05 03:05:00101 // Tabs
[email protected]61424c062009-10-14 23:14:59102 RegisterFunction<GetTabFunction>();
103 RegisterFunction<GetSelectedTabFunction>();
104 RegisterFunction<GetAllTabsInWindowFunction>();
105 RegisterFunction<CreateTabFunction>();
106 RegisterFunction<UpdateTabFunction>();
107 RegisterFunction<MoveTabFunction>();
108 RegisterFunction<RemoveTabFunction>();
109 RegisterFunction<DetectTabLanguageFunction>();
110 RegisterFunction<CaptureVisibleTabFunction>();
111 RegisterFunction<TabsExecuteScriptFunction>();
112 RegisterFunction<TabsInsertCSSFunction>();
[email protected]bfdffe2b2009-04-24 22:05:35113
[email protected]f7f3a5f2009-05-01 22:02:34114 // Page Actions.
[email protected]61424c062009-10-14 23:14:59115 RegisterFunction<EnablePageActionFunction>();
116 RegisterFunction<DisablePageActionFunction>();
[email protected]744ef172009-10-16 21:53:46117 RegisterFunction<PageActionShowFunction>();
118 RegisterFunction<PageActionHideFunction>();
119 RegisterFunction<PageActionSetIconFunction>();
120 RegisterFunction<PageActionSetTitleFunction>();
[email protected]e478d6702010-01-28 00:10:29121 RegisterFunction<PageActionSetPopupFunction>();
[email protected]f7f3a5f2009-05-01 22:02:34122
[email protected]ec9ac0df2009-10-01 18:06:47123 // Browser Actions.
[email protected]61424c062009-10-14 23:14:59124 RegisterFunction<BrowserActionSetIconFunction>();
[email protected]1288ba02009-10-15 00:02:24125 RegisterFunction<BrowserActionSetTitleFunction>();
[email protected]61424c062009-10-14 23:14:59126 RegisterFunction<BrowserActionSetBadgeTextFunction>();
127 RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>();
[email protected]85ae9592010-02-03 20:58:50128 RegisterFunction<BrowserActionSetPopupFunction>();
[email protected]ec9ac0df2009-10-01 18:06:47129
[email protected]f7f3a5f2009-05-01 22:02:34130 // Bookmarks.
[email protected]61424c062009-10-14 23:14:59131 RegisterFunction<GetBookmarksFunction>();
132 RegisterFunction<GetBookmarkChildrenFunction>();
[email protected]a3c94c712009-12-18 19:23:55133 RegisterFunction<GetBookmarkRecentFunction>();
[email protected]61424c062009-10-14 23:14:59134 RegisterFunction<GetBookmarkTreeFunction>();
135 RegisterFunction<SearchBookmarksFunction>();
136 RegisterFunction<RemoveBookmarkFunction>();
137 RegisterFunction<RemoveTreeBookmarkFunction>();
138 RegisterFunction<CreateBookmarkFunction>();
139 RegisterFunction<MoveBookmarkFunction>();
140 RegisterFunction<UpdateBookmarkFunction>();
[email protected]9c45b7182009-08-04 16:44:43141
[email protected]f34e79632010-03-17 02:34:08142 // Infobars.
143 RegisterFunction<ShowInfoBarFunction>();
144
[email protected]9dd97bc2010-01-14 01:40:04145 // BookmarkManager
146 RegisterFunction<CopyBookmarkManagerFunction>();
147 RegisterFunction<CutBookmarkManagerFunction>();
148 RegisterFunction<PasteBookmarkManagerFunction>();
[email protected]03b3bbf2010-01-29 23:54:57149 RegisterFunction<CanPasteBookmarkManagerFunction>();
[email protected]cb6cf792010-01-28 00:04:56150 RegisterFunction<ImportBookmarksFunction>();
151 RegisterFunction<ExportBookmarksFunction>();
[email protected]d406e2e2010-01-30 21:45:18152 RegisterFunction<SortChildrenBookmarkManagerFunction>();
[email protected]9dd97bc2010-01-14 01:40:04153 RegisterFunction<BookmarkManagerGetStringsFunction>();
[email protected]ced90ae12010-02-20 02:06:16154 RegisterFunction<StartDragBookmarkManagerFunction>();
155 RegisterFunction<DropBookmarkManagerFunction>();
[email protected]9dd97bc2010-01-14 01:40:04156
[email protected]de768a832009-10-30 05:25:01157 // History
158 RegisterFunction<AddUrlHistoryFunction>();
159 RegisterFunction<DeleteAllHistoryFunction>();
160 RegisterFunction<DeleteRangeHistoryFunction>();
161 RegisterFunction<DeleteUrlHistoryFunction>();
162 RegisterFunction<GetVisitsHistoryFunction>();
163 RegisterFunction<SearchHistoryFunction>();
164
[email protected]f5205412010-03-16 00:19:34165 // Idle
166 RegisterFunction<ExtensionIdleQueryStateFunction>();
167
[email protected]9c45b7182009-08-04 16:44:43168 // Toolstrips.
[email protected]61424c062009-10-14 23:14:59169 RegisterFunction<ToolstripExpandFunction>();
170 RegisterFunction<ToolstripCollapseFunction>();
[email protected]25fd1b2e2009-08-17 20:57:14171
[email protected]198bcfe2009-09-09 22:56:28172 // I18N.
[email protected]61424c062009-10-14 23:14:59173 RegisterFunction<GetAcceptLanguagesFunction>();
[email protected]198bcfe2009-09-09 22:56:28174
[email protected]1c1c77a52009-11-03 00:37:31175 // Popup API.
176 RegisterFunction<PopupShowFunction>();
177
[email protected]381162b2010-01-28 17:29:35178 // Processes.
179 RegisterFunction<GetProcessForTabFunction>();
180
[email protected]438772df2010-02-26 18:08:43181 // Metrics.
[email protected]cf25e4d2010-03-12 21:19:34182 RegisterFunction<MetricsRecordUserActionFunction>();
183 RegisterFunction<MetricsRecordValueFunction>();
184 RegisterFunction<MetricsRecordPercentageFunction>();
185 RegisterFunction<MetricsRecordCountFunction>();
186 RegisterFunction<MetricsRecordSmallCountFunction>();
187 RegisterFunction<MetricsRecordMediumCountFunction>();
188 RegisterFunction<MetricsRecordTimeFunction>();
189 RegisterFunction<MetricsRecordMediumTimeFunction>();
190 RegisterFunction<MetricsRecordLongTimeFunction>();
[email protected]438772df2010-02-26 18:08:43191
[email protected]25fd1b2e2009-08-17 20:57:14192 // Test.
[email protected]61424c062009-10-14 23:14:59193 RegisterFunction<ExtensionTestPassFunction>();
194 RegisterFunction<ExtensionTestFailFunction>();
195 RegisterFunction<ExtensionTestLogFunction>();
[email protected]d13950e2009-12-04 01:43:02196 RegisterFunction<ExtensionTestQuotaResetFunction>();
[email protected]db7331a2010-02-25 22:10:50197 RegisterFunction<ExtensionTestCreateIncognitoTabFunction>();
[email protected]5cbe1e22010-01-30 01:18:56198
199 // Accessibility.
200 RegisterFunction<GetFocusedControlFunction>();
201 RegisterFunction<SetAccessibilityEnabledFunction>();
[email protected]bfdffe2b2009-04-24 22:05:35202}
203
[email protected]b83e4602009-05-15 22:58:33204void FactoryRegistry::GetAllNames(std::vector<std::string>* names) {
205 for (FactoryMap::iterator iter = factories_.begin();
206 iter != factories_.end(); ++iter) {
[email protected]bfdffe2b2009-04-24 22:05:35207 names->push_back(iter->first);
208 }
209}
210
[email protected]b83e4602009-05-15 22:58:33211bool FactoryRegistry::OverrideFunction(const std::string& name,
212 ExtensionFunctionFactory factory) {
213 FactoryMap::iterator iter = factories_.find(name);
214 if (iter == factories_.end()) {
215 return false;
216 } else {
217 iter->second = factory;
218 return true;
219 }
220}
221
[email protected]bfdffe2b2009-04-24 22:05:35222ExtensionFunction* FactoryRegistry::NewFunction(const std::string& name) {
223 FactoryMap::iterator iter = factories_.find(name);
224 DCHECK(iter != factories_.end());
[email protected]b83e4602009-05-15 22:58:33225 ExtensionFunction* function = iter->second();
[email protected]76a3db852009-07-24 02:14:56226 function->set_name(name);
[email protected]b83e4602009-05-15 22:58:33227 return function;
[email protected]bfdffe2b2009-04-24 22:05:35228}
229
[email protected]b83e4602009-05-15 22:58:33230}; // namespace
[email protected]bfdffe2b2009-04-24 22:05:35231
[email protected]a95631cb2009-12-10 01:59:11232// ExtensionFunctionDispatcher::Delegate ---------------------------------------
233
234gfx::NativeWindow ExtensionFunctionDispatcher::Delegate::
235 GetFrameNativeWindow() {
[email protected]db7331a2010-02-25 22:10:50236 Browser* browser = GetBrowser(true);
[email protected]a95631cb2009-12-10 01:59:11237 // If a browser is bound to this dispatcher, then return the widget hosting
238 // the window. Extensions hosted in ExternalTabContainer objects may not
239 // have a running browser instance.
240 if (browser)
241 return browser->window()->GetNativeHandle();
242
243 return NULL;
244}
245
[email protected]bfdffe2b2009-04-24 22:05:35246// ExtensionFunctionDispatcher -------------------------------------------------
247
248void ExtensionFunctionDispatcher::GetAllFunctionNames(
249 std::vector<std::string>* names) {
250 FactoryRegistry::instance()->GetAllNames(names);
251}
252
[email protected]b83e4602009-05-15 22:58:33253bool ExtensionFunctionDispatcher::OverrideFunction(
254 const std::string& name, ExtensionFunctionFactory factory) {
255 return FactoryRegistry::instance()->OverrideFunction(name, factory);
256}
257
258void ExtensionFunctionDispatcher::ResetFunctions() {
259 FactoryRegistry::instance()->ResetFunctions();
260}
261
[email protected]811bfe32009-07-01 08:46:25262std::set<ExtensionFunctionDispatcher*>*
263 ExtensionFunctionDispatcher::all_instances() {
264 static std::set<ExtensionFunctionDispatcher*> instances;
265 return &instances;
266}
267
[email protected]bfdffe2b2009-04-24 22:05:35268ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
269 RenderViewHost* render_view_host,
[email protected]7eecaed52009-05-07 21:44:12270 Delegate* delegate,
[email protected]811bfe32009-07-01 08:46:25271 const GURL& url)
[email protected]ebc1b682010-03-06 00:22:30272 : profile_(render_view_host->process()->profile()),
[email protected]68f07912010-03-05 18:33:58273 render_view_host_(render_view_host),
[email protected]7eecaed52009-05-07 21:44:12274 delegate_(delegate),
[email protected]811bfe32009-07-01 08:46:25275 url_(url),
[email protected]32dda362009-06-05 19:07:01276 ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) {
[email protected]9c45b7182009-08-04 16:44:43277 // TODO(erikkay) should we do something for these errors in Release?
278 DCHECK(url.SchemeIs(chrome::kExtensionScheme));
[email protected]35506352009-08-07 18:58:19279
280 Extension* extension =
281 profile()->GetExtensionsService()->GetExtensionByURL(url);
282 DCHECK(extension);
[email protected]9c45b7182009-08-04 16:44:43283
[email protected]811bfe32009-07-01 08:46:25284 all_instances()->insert(this);
[email protected]0f6053962009-07-09 19:26:35285
[email protected]45776222009-07-15 20:21:58286 // Notify the ExtensionProcessManager that the view was created.
287 ExtensionProcessManager* epm = profile()->GetExtensionProcessManager();
288 epm->RegisterExtensionProcess(extension_id(),
[email protected]76543b92009-08-31 17:27:45289 render_view_host->process()->id());
[email protected]35506352009-08-07 18:58:19290
[email protected]db7331a2010-02-25 22:10:50291 bool incognito_enabled =
[email protected]cb0ce1e022010-03-10 19:54:41292 profile()->GetExtensionsService()->IsIncognitoEnabled(extension);
[email protected]db7331a2010-02-25 22:10:50293
[email protected]35506352009-08-07 18:58:19294 // Update the extension permissions. Doing this each time we create an EFD
295 // ensures that new processes are informed of permissions for newly installed
296 // extensions.
[email protected]cccf90932009-08-23 17:56:25297 render_view_host->Send(new ViewMsg_Extension_SetAPIPermissions(
[email protected]35506352009-08-07 18:58:19298 extension->id(), extension->api_permissions()));
[email protected]cccf90932009-08-23 17:56:25299 render_view_host->Send(new ViewMsg_Extension_SetHostPermissions(
300 extension->url(), extension->host_permissions()));
[email protected]db7331a2010-02-25 22:10:50301 render_view_host->Send(new ViewMsg_Extension_ExtensionSetIncognitoEnabled(
302 extension->id(), incognito_enabled));
[email protected]68f07912010-03-05 18:33:58303
304 NotificationService::current()->Notify(
305 NotificationType::EXTENSION_FUNCTION_DISPATCHER_CREATED,
306 Source<Profile>(profile_),
307 Details<ExtensionFunctionDispatcher>(this));
[email protected]bfdffe2b2009-04-24 22:05:35308}
309
[email protected]32dda362009-06-05 19:07:01310ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() {
[email protected]811bfe32009-07-01 08:46:25311 all_instances()->erase(this);
[email protected]32dda362009-06-05 19:07:01312 peer_->dispatcher_ = NULL;
[email protected]68f07912010-03-05 18:33:58313
314 NotificationService::current()->Notify(
315 NotificationType::EXTENSION_FUNCTION_DISPATCHER_DESTROYED,
316 Source<Profile>(profile_),
317 Details<ExtensionFunctionDispatcher>(this));
[email protected]32dda362009-06-05 19:07:01318}
319
[email protected]db7331a2010-02-25 22:10:50320Browser* ExtensionFunctionDispatcher::GetBrowser(bool include_incognito) {
321 return delegate_->GetBrowser(include_incognito);
[email protected]7eecaed52009-05-07 21:44:12322}
323
[email protected]b27257562009-11-16 23:28:26324ExtensionPopupHost* ExtensionFunctionDispatcher::GetPopupHost() {
325 ExtensionHost* extension_host = GetExtensionHost();
326 if (extension_host) {
327 DCHECK(!GetExtensionDOMUI()) <<
328 "Function dispatcher registered in too many environments.";
329 return extension_host->popup_host();
330 } else {
331 ExtensionDOMUI* dom_ui = GetExtensionDOMUI();
332 return dom_ui->popup_host();
333 }
334}
335
[email protected]9c45b7182009-08-04 16:44:43336ExtensionHost* ExtensionFunctionDispatcher::GetExtensionHost() {
[email protected]9c45b7182009-08-04 16:44:43337 return delegate_->GetExtensionHost();
338}
339
[email protected]b27257562009-11-16 23:28:26340ExtensionDOMUI* ExtensionFunctionDispatcher::GetExtensionDOMUI() {
341 return delegate_->GetExtensionDOMUI();
342}
343
[email protected]c7ad50f2009-09-11 06:28:15344Extension* ExtensionFunctionDispatcher::GetExtension() {
345 ExtensionsService* service = profile()->GetExtensionsService();
346 DCHECK(service);
347
[email protected]61b411612009-11-10 23:17:41348 Extension* extension = service->GetExtensionById(extension_id(), false);
[email protected]c7ad50f2009-09-11 06:28:15349 DCHECK(extension);
350
351 return extension;
352}
353
[email protected]bfdffe2b2009-04-24 22:05:35354void ExtensionFunctionDispatcher::HandleRequest(const std::string& name,
[email protected]e4dad9fb2009-10-06 18:15:58355 const Value* args,
[email protected]c6619182009-05-12 14:59:32356 int request_id,
357 bool has_callback) {
[email protected]32dda362009-06-05 19:07:01358 scoped_refptr<ExtensionFunction> function(
[email protected]bfdffe2b2009-04-24 22:05:35359 FactoryRegistry::instance()->NewFunction(name));
[email protected]32dda362009-06-05 19:07:01360 function->set_dispatcher_peer(peer_);
[email protected]b83e4602009-05-15 22:58:33361 function->SetArgs(args);
[email protected]c6619182009-05-12 14:59:32362 function->set_request_id(request_id);
363 function->set_has_callback(has_callback);
[email protected]d13950e2009-12-04 01:43:02364 ExtensionsService* service = profile()->GetExtensionsService();
365 DCHECK(service);
[email protected]cb0ce1e022010-03-10 19:54:41366 Extension* extension = service->GetExtensionById(extension_id(), false);
367 DCHECK(extension);
368 function->set_include_incognito(service->IsIncognitoEnabled(extension));
369
[email protected]d13950e2009-12-04 01:43:02370 ExtensionsQuotaService* quota = service->quota_service();
371 if (quota->Assess(extension_id(), function, args, base::TimeTicks::Now())) {
372 function->Run();
373 } else {
374 render_view_host_->SendExtensionResponse(function->request_id(), false,
375 std::string(), QuotaLimitHeuristic::kGenericOverQuotaError);
376 }
[email protected]bfdffe2b2009-04-24 22:05:35377}
378
[email protected]c6619182009-05-12 14:59:32379void ExtensionFunctionDispatcher::SendResponse(ExtensionFunction* function,
380 bool success) {
[email protected]c6619182009-05-12 14:59:32381 render_view_host_->SendExtensionResponse(function->request_id(), success,
[email protected]b83e4602009-05-15 22:58:33382 function->GetResult(), function->GetError());
[email protected]bfdffe2b2009-04-24 22:05:35383}
384
385void ExtensionFunctionDispatcher::HandleBadMessage(ExtensionFunction* api) {
[email protected]25fd1b2e2009-08-17 20:57:14386 LOG(ERROR) << "bad extension message " <<
[email protected]76543b92009-08-31 17:27:45387 api->name() <<
[email protected]bfdffe2b2009-04-24 22:05:35388 " : terminating renderer.";
389 if (RenderProcessHost::run_renderer_in_process()) {
390 // In single process mode it is better if we don't suicide but just crash.
391 CHECK(false);
392 } else {
393 NOTREACHED();
[email protected]201b2732009-11-13 18:57:46394 base::KillProcess(render_view_host_->process()->GetHandle(),
[email protected]bfdffe2b2009-04-24 22:05:35395 ResultCodes::KILLED_BAD_MESSAGE, false);
396 }
397}
398
399Profile* ExtensionFunctionDispatcher::profile() {
[email protected]68f07912010-03-05 18:33:58400 return profile_;
[email protected]bfdffe2b2009-04-24 22:05:35401}
[email protected]a95631cb2009-12-10 01:59:11402
403gfx::NativeWindow ExtensionFunctionDispatcher::GetFrameNativeWindow() {
404 return delegate_ ? delegate_->GetFrameNativeWindow() : NULL;
405}