blob: 546205c7d39ae4c15a24f0a0ce999e7ab6cad4b9 [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]446255952010-03-17 20:41:5818#include "chrome/browser/extensions/extension_clipboard_api.h"
[email protected]2e3b5202010-03-23 06:52:4119#include "chrome/browser/extensions/extension_context_menu_api.h"
[email protected]b27257562009-11-16 23:28:2620#include "chrome/browser/extensions/extension_dom_ui.h"
[email protected]bfdffe2b2009-04-24 22:05:3521#include "chrome/browser/extensions/extension_function.h"
[email protected]de768a832009-10-30 05:25:0122#include "chrome/browser/extensions/extension_history_api.h"
[email protected]f5205412010-03-16 00:19:3423#include "chrome/browser/extensions/extension_idle_api.h"
[email protected]198bcfe2009-09-09 22:56:2824#include "chrome/browser/extensions/extension_i18n_api.h"
[email protected]f34e79632010-03-17 02:34:0825#include "chrome/browser/extensions/extension_infobar_module.h"
[email protected]e916901c2009-05-07 00:14:3126#include "chrome/browser/extensions/extension_message_service.h"
[email protected]438772df2010-02-26 18:08:4327#include "chrome/browser/extensions/extension_metrics_module.h"
[email protected]f7f3a5f2009-05-01 22:02:3428#include "chrome/browser/extensions/extension_page_actions_module.h"
[email protected]f93914852009-05-26 06:05:4029#include "chrome/browser/extensions/extension_page_actions_module_constants.h"
[email protected]1c1c77a52009-11-03 00:37:3130#include "chrome/browser/extensions/extension_popup_api.h"
[email protected]45776222009-07-15 20:21:5831#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]381162b2010-01-28 17:29:3532#include "chrome/browser/extensions/extension_processes_api.h"
[email protected]bfdffe2b2009-04-24 22:05:3533#include "chrome/browser/extensions/extension_tabs_module.h"
[email protected]f93914852009-05-26 06:05:4034#include "chrome/browser/extensions/extension_tabs_module_constants.h"
[email protected]25fd1b2e2009-08-17 20:57:1435#include "chrome/browser/extensions/extension_test_api.h"
[email protected]9c45b7182009-08-04 16:44:4336#include "chrome/browser/extensions/extension_toolstrip_api.h"
[email protected]d13950e2009-12-04 01:43:0237#include "chrome/browser/extensions/extensions_quota_service.h"
[email protected]b1748b1d82009-11-30 20:32:5638#include "chrome/browser/extensions/extensions_service.h"
[email protected]e916901c2009-05-07 00:14:3139#include "chrome/browser/profile.h"
[email protected]bfdffe2b2009-04-24 22:05:3540#include "chrome/browser/renderer_host/render_process_host.h"
41#include "chrome/browser/renderer_host/render_view_host.h"
[email protected]35506352009-08-07 18:58:1942#include "chrome/common/render_messages.h"
[email protected]bfdffe2b2009-04-24 22:05:3543#include "chrome/common/result_codes.h"
[email protected]9c45b7182009-08-04 16:44:4344#include "chrome/common/url_constants.h"
[email protected]bfdffe2b2009-04-24 22:05:3545
46// FactoryRegistry -------------------------------------------------------------
47
48namespace {
49
[email protected]b83e4602009-05-15 22:58:3350// Template for defining ExtensionFunctionFactory.
51template<class T>
52ExtensionFunction* NewExtensionFunction() {
53 return new T();
54}
[email protected]bfdffe2b2009-04-24 22:05:3555
[email protected]b83e4602009-05-15 22:58:3356// Contains a list of all known extension functions and allows clients to
57// create instances of them.
[email protected]bfdffe2b2009-04-24 22:05:3558class FactoryRegistry {
59 public:
60 static FactoryRegistry* instance();
[email protected]b83e4602009-05-15 22:58:3361 FactoryRegistry() { ResetFunctions(); }
62
63 // Resets all functions to their default values.
64 void ResetFunctions();
65
66 // Adds all function names to 'names'.
[email protected]bfdffe2b2009-04-24 22:05:3567 void GetAllNames(std::vector<std::string>* names);
[email protected]b83e4602009-05-15 22:58:3368
69 // Allows overriding of specific functions (e.g. for testing). Functions
70 // must be previously registered. Returns true if successful.
71 bool OverrideFunction(const std::string& name,
72 ExtensionFunctionFactory factory);
73
74 // Factory method for the ExtensionFunction registered as 'name'.
[email protected]bfdffe2b2009-04-24 22:05:3575 ExtensionFunction* NewFunction(const std::string& name);
76
77 private:
[email protected]61424c062009-10-14 23:14:5978 template<class T>
79 void RegisterFunction() {
80 factories_[T::function_name()] = &NewExtensionFunction<T>;
81 }
82
[email protected]bfdffe2b2009-04-24 22:05:3583 typedef std::map<std::string, ExtensionFunctionFactory> FactoryMap;
84 FactoryMap factories_;
85};
86
[email protected]bfdffe2b2009-04-24 22:05:3587FactoryRegistry* FactoryRegistry::instance() {
88 return Singleton<FactoryRegistry>::get();
89}
90
[email protected]b83e4602009-05-15 22:58:3391void FactoryRegistry::ResetFunctions() {
[email protected]bfdffe2b2009-04-24 22:05:3592 // Register all functions here.
93
[email protected]e515f5d2009-05-05 03:05:0094 // Windows
[email protected]61424c062009-10-14 23:14:5995 RegisterFunction<GetWindowFunction>();
96 RegisterFunction<GetCurrentWindowFunction>();
97 RegisterFunction<GetLastFocusedWindowFunction>();
98 RegisterFunction<GetAllWindowsFunction>();
99 RegisterFunction<CreateWindowFunction>();
100 RegisterFunction<UpdateWindowFunction>();
101 RegisterFunction<RemoveWindowFunction>();
[email protected]b83e4602009-05-15 22:58:33102
[email protected]e515f5d2009-05-05 03:05:00103 // Tabs
[email protected]61424c062009-10-14 23:14:59104 RegisterFunction<GetTabFunction>();
105 RegisterFunction<GetSelectedTabFunction>();
106 RegisterFunction<GetAllTabsInWindowFunction>();
107 RegisterFunction<CreateTabFunction>();
108 RegisterFunction<UpdateTabFunction>();
109 RegisterFunction<MoveTabFunction>();
110 RegisterFunction<RemoveTabFunction>();
111 RegisterFunction<DetectTabLanguageFunction>();
112 RegisterFunction<CaptureVisibleTabFunction>();
113 RegisterFunction<TabsExecuteScriptFunction>();
114 RegisterFunction<TabsInsertCSSFunction>();
[email protected]bfdffe2b2009-04-24 22:05:35115
[email protected]f7f3a5f2009-05-01 22:02:34116 // Page Actions.
[email protected]61424c062009-10-14 23:14:59117 RegisterFunction<EnablePageActionFunction>();
118 RegisterFunction<DisablePageActionFunction>();
[email protected]744ef172009-10-16 21:53:46119 RegisterFunction<PageActionShowFunction>();
120 RegisterFunction<PageActionHideFunction>();
121 RegisterFunction<PageActionSetIconFunction>();
122 RegisterFunction<PageActionSetTitleFunction>();
[email protected]e478d6702010-01-28 00:10:29123 RegisterFunction<PageActionSetPopupFunction>();
[email protected]f7f3a5f2009-05-01 22:02:34124
[email protected]ec9ac0df2009-10-01 18:06:47125 // Browser Actions.
[email protected]61424c062009-10-14 23:14:59126 RegisterFunction<BrowserActionSetIconFunction>();
[email protected]1288ba02009-10-15 00:02:24127 RegisterFunction<BrowserActionSetTitleFunction>();
[email protected]61424c062009-10-14 23:14:59128 RegisterFunction<BrowserActionSetBadgeTextFunction>();
129 RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>();
[email protected]85ae9592010-02-03 20:58:50130 RegisterFunction<BrowserActionSetPopupFunction>();
[email protected]ec9ac0df2009-10-01 18:06:47131
[email protected]f7f3a5f2009-05-01 22:02:34132 // Bookmarks.
[email protected]61424c062009-10-14 23:14:59133 RegisterFunction<GetBookmarksFunction>();
134 RegisterFunction<GetBookmarkChildrenFunction>();
[email protected]a3c94c712009-12-18 19:23:55135 RegisterFunction<GetBookmarkRecentFunction>();
[email protected]61424c062009-10-14 23:14:59136 RegisterFunction<GetBookmarkTreeFunction>();
137 RegisterFunction<SearchBookmarksFunction>();
138 RegisterFunction<RemoveBookmarkFunction>();
139 RegisterFunction<RemoveTreeBookmarkFunction>();
140 RegisterFunction<CreateBookmarkFunction>();
141 RegisterFunction<MoveBookmarkFunction>();
142 RegisterFunction<UpdateBookmarkFunction>();
[email protected]9c45b7182009-08-04 16:44:43143
[email protected]f34e79632010-03-17 02:34:08144 // Infobars.
145 RegisterFunction<ShowInfoBarFunction>();
146
[email protected]9dd97bc2010-01-14 01:40:04147 // BookmarkManager
148 RegisterFunction<CopyBookmarkManagerFunction>();
149 RegisterFunction<CutBookmarkManagerFunction>();
150 RegisterFunction<PasteBookmarkManagerFunction>();
[email protected]03b3bbf2010-01-29 23:54:57151 RegisterFunction<CanPasteBookmarkManagerFunction>();
[email protected]cb6cf792010-01-28 00:04:56152 RegisterFunction<ImportBookmarksFunction>();
153 RegisterFunction<ExportBookmarksFunction>();
[email protected]d406e2e2010-01-30 21:45:18154 RegisterFunction<SortChildrenBookmarkManagerFunction>();
[email protected]9dd97bc2010-01-14 01:40:04155 RegisterFunction<BookmarkManagerGetStringsFunction>();
[email protected]ced90ae12010-02-20 02:06:16156 RegisterFunction<StartDragBookmarkManagerFunction>();
157 RegisterFunction<DropBookmarkManagerFunction>();
[email protected]9dd97bc2010-01-14 01:40:04158
[email protected]de768a832009-10-30 05:25:01159 // History
160 RegisterFunction<AddUrlHistoryFunction>();
161 RegisterFunction<DeleteAllHistoryFunction>();
162 RegisterFunction<DeleteRangeHistoryFunction>();
163 RegisterFunction<DeleteUrlHistoryFunction>();
164 RegisterFunction<GetVisitsHistoryFunction>();
165 RegisterFunction<SearchHistoryFunction>();
166
[email protected]f5205412010-03-16 00:19:34167 // Idle
168 RegisterFunction<ExtensionIdleQueryStateFunction>();
169
[email protected]9c45b7182009-08-04 16:44:43170 // Toolstrips.
[email protected]61424c062009-10-14 23:14:59171 RegisterFunction<ToolstripExpandFunction>();
172 RegisterFunction<ToolstripCollapseFunction>();
[email protected]25fd1b2e2009-08-17 20:57:14173
[email protected]198bcfe2009-09-09 22:56:28174 // I18N.
[email protected]61424c062009-10-14 23:14:59175 RegisterFunction<GetAcceptLanguagesFunction>();
[email protected]198bcfe2009-09-09 22:56:28176
[email protected]1c1c77a52009-11-03 00:37:31177 // Popup API.
178 RegisterFunction<PopupShowFunction>();
179
[email protected]381162b2010-01-28 17:29:35180 // Processes.
181 RegisterFunction<GetProcessForTabFunction>();
182
[email protected]438772df2010-02-26 18:08:43183 // Metrics.
[email protected]cf25e4d2010-03-12 21:19:34184 RegisterFunction<MetricsRecordUserActionFunction>();
185 RegisterFunction<MetricsRecordValueFunction>();
186 RegisterFunction<MetricsRecordPercentageFunction>();
187 RegisterFunction<MetricsRecordCountFunction>();
188 RegisterFunction<MetricsRecordSmallCountFunction>();
189 RegisterFunction<MetricsRecordMediumCountFunction>();
190 RegisterFunction<MetricsRecordTimeFunction>();
191 RegisterFunction<MetricsRecordMediumTimeFunction>();
192 RegisterFunction<MetricsRecordLongTimeFunction>();
[email protected]438772df2010-02-26 18:08:43193
[email protected]25fd1b2e2009-08-17 20:57:14194 // Test.
[email protected]61424c062009-10-14 23:14:59195 RegisterFunction<ExtensionTestPassFunction>();
196 RegisterFunction<ExtensionTestFailFunction>();
197 RegisterFunction<ExtensionTestLogFunction>();
[email protected]d13950e2009-12-04 01:43:02198 RegisterFunction<ExtensionTestQuotaResetFunction>();
[email protected]db7331a2010-02-25 22:10:50199 RegisterFunction<ExtensionTestCreateIncognitoTabFunction>();
[email protected]5cbe1e22010-01-30 01:18:56200
201 // Accessibility.
202 RegisterFunction<GetFocusedControlFunction>();
203 RegisterFunction<SetAccessibilityEnabledFunction>();
[email protected]446255952010-03-17 20:41:58204
205 // Clipboard.
206 RegisterFunction<ExecuteCopyClipboardFunction>();
207 RegisterFunction<ExecuteCutClipboardFunction>();
208 RegisterFunction<ExecutePasteClipboardFunction>();
[email protected]2e3b5202010-03-23 06:52:41209
210 // Context Menus.
211 RegisterFunction<CreateContextMenuFunction>();
212 RegisterFunction<RemoveContextMenuFunction>();
[email protected]bfdffe2b2009-04-24 22:05:35213}
214
[email protected]b83e4602009-05-15 22:58:33215void FactoryRegistry::GetAllNames(std::vector<std::string>* names) {
216 for (FactoryMap::iterator iter = factories_.begin();
217 iter != factories_.end(); ++iter) {
[email protected]bfdffe2b2009-04-24 22:05:35218 names->push_back(iter->first);
219 }
220}
221
[email protected]b83e4602009-05-15 22:58:33222bool FactoryRegistry::OverrideFunction(const std::string& name,
223 ExtensionFunctionFactory factory) {
224 FactoryMap::iterator iter = factories_.find(name);
225 if (iter == factories_.end()) {
226 return false;
227 } else {
228 iter->second = factory;
229 return true;
230 }
231}
232
[email protected]bfdffe2b2009-04-24 22:05:35233ExtensionFunction* FactoryRegistry::NewFunction(const std::string& name) {
234 FactoryMap::iterator iter = factories_.find(name);
235 DCHECK(iter != factories_.end());
[email protected]b83e4602009-05-15 22:58:33236 ExtensionFunction* function = iter->second();
[email protected]76a3db852009-07-24 02:14:56237 function->set_name(name);
[email protected]b83e4602009-05-15 22:58:33238 return function;
[email protected]bfdffe2b2009-04-24 22:05:35239}
240
[email protected]b83e4602009-05-15 22:58:33241}; // namespace
[email protected]bfdffe2b2009-04-24 22:05:35242
[email protected]a95631cb2009-12-10 01:59:11243// ExtensionFunctionDispatcher::Delegate ---------------------------------------
244
245gfx::NativeWindow ExtensionFunctionDispatcher::Delegate::
246 GetFrameNativeWindow() {
[email protected]db7331a2010-02-25 22:10:50247 Browser* browser = GetBrowser(true);
[email protected]a95631cb2009-12-10 01:59:11248 // If a browser is bound to this dispatcher, then return the widget hosting
249 // the window. Extensions hosted in ExternalTabContainer objects may not
250 // have a running browser instance.
251 if (browser)
252 return browser->window()->GetNativeHandle();
253
254 return NULL;
255}
256
[email protected]bfdffe2b2009-04-24 22:05:35257// ExtensionFunctionDispatcher -------------------------------------------------
258
259void ExtensionFunctionDispatcher::GetAllFunctionNames(
260 std::vector<std::string>* names) {
261 FactoryRegistry::instance()->GetAllNames(names);
262}
263
[email protected]b83e4602009-05-15 22:58:33264bool ExtensionFunctionDispatcher::OverrideFunction(
265 const std::string& name, ExtensionFunctionFactory factory) {
266 return FactoryRegistry::instance()->OverrideFunction(name, factory);
267}
268
269void ExtensionFunctionDispatcher::ResetFunctions() {
270 FactoryRegistry::instance()->ResetFunctions();
271}
272
[email protected]811bfe32009-07-01 08:46:25273std::set<ExtensionFunctionDispatcher*>*
274 ExtensionFunctionDispatcher::all_instances() {
275 static std::set<ExtensionFunctionDispatcher*> instances;
276 return &instances;
277}
278
[email protected]bfdffe2b2009-04-24 22:05:35279ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
280 RenderViewHost* render_view_host,
[email protected]7eecaed52009-05-07 21:44:12281 Delegate* delegate,
[email protected]811bfe32009-07-01 08:46:25282 const GURL& url)
[email protected]ebc1b682010-03-06 00:22:30283 : profile_(render_view_host->process()->profile()),
[email protected]68f07912010-03-05 18:33:58284 render_view_host_(render_view_host),
[email protected]7eecaed52009-05-07 21:44:12285 delegate_(delegate),
[email protected]811bfe32009-07-01 08:46:25286 url_(url),
[email protected]32dda362009-06-05 19:07:01287 ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) {
[email protected]9c45b7182009-08-04 16:44:43288 // TODO(erikkay) should we do something for these errors in Release?
289 DCHECK(url.SchemeIs(chrome::kExtensionScheme));
[email protected]35506352009-08-07 18:58:19290
291 Extension* extension =
292 profile()->GetExtensionsService()->GetExtensionByURL(url);
293 DCHECK(extension);
[email protected]9c45b7182009-08-04 16:44:43294
[email protected]811bfe32009-07-01 08:46:25295 all_instances()->insert(this);
[email protected]0f6053962009-07-09 19:26:35296
[email protected]45776222009-07-15 20:21:58297 // Notify the ExtensionProcessManager that the view was created.
298 ExtensionProcessManager* epm = profile()->GetExtensionProcessManager();
299 epm->RegisterExtensionProcess(extension_id(),
[email protected]76543b92009-08-31 17:27:45300 render_view_host->process()->id());
[email protected]35506352009-08-07 18:58:19301
[email protected]db7331a2010-02-25 22:10:50302 bool incognito_enabled =
[email protected]cb0ce1e022010-03-10 19:54:41303 profile()->GetExtensionsService()->IsIncognitoEnabled(extension);
[email protected]db7331a2010-02-25 22:10:50304
[email protected]35506352009-08-07 18:58:19305 // Update the extension permissions. Doing this each time we create an EFD
306 // ensures that new processes are informed of permissions for newly installed
307 // extensions.
[email protected]cccf90932009-08-23 17:56:25308 render_view_host->Send(new ViewMsg_Extension_SetAPIPermissions(
[email protected]35506352009-08-07 18:58:19309 extension->id(), extension->api_permissions()));
[email protected]cccf90932009-08-23 17:56:25310 render_view_host->Send(new ViewMsg_Extension_SetHostPermissions(
311 extension->url(), extension->host_permissions()));
[email protected]db7331a2010-02-25 22:10:50312 render_view_host->Send(new ViewMsg_Extension_ExtensionSetIncognitoEnabled(
313 extension->id(), incognito_enabled));
[email protected]68f07912010-03-05 18:33:58314
315 NotificationService::current()->Notify(
316 NotificationType::EXTENSION_FUNCTION_DISPATCHER_CREATED,
317 Source<Profile>(profile_),
318 Details<ExtensionFunctionDispatcher>(this));
[email protected]bfdffe2b2009-04-24 22:05:35319}
320
[email protected]32dda362009-06-05 19:07:01321ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() {
[email protected]811bfe32009-07-01 08:46:25322 all_instances()->erase(this);
[email protected]32dda362009-06-05 19:07:01323 peer_->dispatcher_ = NULL;
[email protected]68f07912010-03-05 18:33:58324
325 NotificationService::current()->Notify(
326 NotificationType::EXTENSION_FUNCTION_DISPATCHER_DESTROYED,
327 Source<Profile>(profile_),
328 Details<ExtensionFunctionDispatcher>(this));
[email protected]32dda362009-06-05 19:07:01329}
330
[email protected]db7331a2010-02-25 22:10:50331Browser* ExtensionFunctionDispatcher::GetBrowser(bool include_incognito) {
332 return delegate_->GetBrowser(include_incognito);
[email protected]7eecaed52009-05-07 21:44:12333}
334
[email protected]9c45b7182009-08-04 16:44:43335ExtensionHost* ExtensionFunctionDispatcher::GetExtensionHost() {
[email protected]9c45b7182009-08-04 16:44:43336 return delegate_->GetExtensionHost();
337}
338
[email protected]b27257562009-11-16 23:28:26339ExtensionDOMUI* ExtensionFunctionDispatcher::GetExtensionDOMUI() {
340 return delegate_->GetExtensionDOMUI();
341}
342
[email protected]c7ad50f2009-09-11 06:28:15343Extension* ExtensionFunctionDispatcher::GetExtension() {
344 ExtensionsService* service = profile()->GetExtensionsService();
345 DCHECK(service);
346
[email protected]61b411612009-11-10 23:17:41347 Extension* extension = service->GetExtensionById(extension_id(), false);
[email protected]c7ad50f2009-09-11 06:28:15348 DCHECK(extension);
349
350 return extension;
351}
352
[email protected]bfdffe2b2009-04-24 22:05:35353void ExtensionFunctionDispatcher::HandleRequest(const std::string& name,
[email protected]e4dad9fb2009-10-06 18:15:58354 const Value* args,
[email protected]c6619182009-05-12 14:59:32355 int request_id,
356 bool has_callback) {
[email protected]32dda362009-06-05 19:07:01357 scoped_refptr<ExtensionFunction> function(
[email protected]bfdffe2b2009-04-24 22:05:35358 FactoryRegistry::instance()->NewFunction(name));
[email protected]32dda362009-06-05 19:07:01359 function->set_dispatcher_peer(peer_);
[email protected]b83e4602009-05-15 22:58:33360 function->SetArgs(args);
[email protected]c6619182009-05-12 14:59:32361 function->set_request_id(request_id);
362 function->set_has_callback(has_callback);
[email protected]d13950e2009-12-04 01:43:02363 ExtensionsService* service = profile()->GetExtensionsService();
364 DCHECK(service);
[email protected]cb0ce1e022010-03-10 19:54:41365 Extension* extension = service->GetExtensionById(extension_id(), false);
366 DCHECK(extension);
367 function->set_include_incognito(service->IsIncognitoEnabled(extension));
368
[email protected]d13950e2009-12-04 01:43:02369 ExtensionsQuotaService* quota = service->quota_service();
370 if (quota->Assess(extension_id(), function, args, base::TimeTicks::Now())) {
371 function->Run();
372 } else {
373 render_view_host_->SendExtensionResponse(function->request_id(), false,
374 std::string(), QuotaLimitHeuristic::kGenericOverQuotaError);
375 }
[email protected]bfdffe2b2009-04-24 22:05:35376}
377
[email protected]c6619182009-05-12 14:59:32378void ExtensionFunctionDispatcher::SendResponse(ExtensionFunction* function,
379 bool success) {
[email protected]c6619182009-05-12 14:59:32380 render_view_host_->SendExtensionResponse(function->request_id(), success,
[email protected]b83e4602009-05-15 22:58:33381 function->GetResult(), function->GetError());
[email protected]bfdffe2b2009-04-24 22:05:35382}
383
384void ExtensionFunctionDispatcher::HandleBadMessage(ExtensionFunction* api) {
[email protected]25fd1b2e2009-08-17 20:57:14385 LOG(ERROR) << "bad extension message " <<
[email protected]76543b92009-08-31 17:27:45386 api->name() <<
[email protected]bfdffe2b2009-04-24 22:05:35387 " : terminating renderer.";
388 if (RenderProcessHost::run_renderer_in_process()) {
389 // In single process mode it is better if we don't suicide but just crash.
390 CHECK(false);
391 } else {
392 NOTREACHED();
[email protected]201b2732009-11-13 18:57:46393 base::KillProcess(render_view_host_->process()->GetHandle(),
[email protected]bfdffe2b2009-04-24 22:05:35394 ResultCodes::KILLED_BAD_MESSAGE, false);
395 }
396}
397
398Profile* ExtensionFunctionDispatcher::profile() {
[email protected]68f07912010-03-05 18:33:58399 return profile_;
[email protected]bfdffe2b2009-04-24 22:05:35400}
[email protected]a95631cb2009-12-10 01:59:11401
402gfx::NativeWindow ExtensionFunctionDispatcher::GetFrameNativeWindow() {
403 return delegate_ ? delegate_->GetFrameNativeWindow() : NULL;
404}