Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/extensions/extension_event_router.cc

Issue 9959040: Reland 125805 - Reland 124817 - A profile-keyed service for Extensions, ExtensionSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_event_router.h" 5 #include "chrome/browser/extensions/extension_event_router.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/api/web_request/web_request_api.h" 10 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
11 #include "chrome/browser/extensions/extension_devtools_manager.h" 11 #include "chrome/browser/extensions/extension_devtools_manager.h"
12 #include "chrome/browser/extensions/extension_host.h" 12 #include "chrome/browser/extensions/extension_host.h"
13 #include "chrome/browser/extensions/extension_module.h" 13 #include "chrome/browser/extensions/extension_module.h"
14 #include "chrome/browser/extensions/extension_process_manager.h" 14 #include "chrome/browser/extensions/extension_process_manager.h"
15 #include "chrome/browser/extensions/extension_processes_api.h" 15 #include "chrome/browser/extensions/extension_processes_api.h"
16 #include "chrome/browser/extensions/extension_processes_api_constants.h" 16 #include "chrome/browser/extensions/extension_processes_api_constants.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/extensions/extension_system_factory.h"
18 #include "chrome/browser/extensions/extension_tabs_module.h" 20 #include "chrome/browser/extensions/extension_tabs_module.h"
19 #include "chrome/browser/extensions/lazy_background_task_queue.h" 21 #include "chrome/browser/extensions/lazy_background_task_queue.h"
20 #include "chrome/browser/extensions/process_map.h" 22 #include "chrome/browser/extensions/process_map.h"
21 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
23 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/chrome_view_type.h" 26 #include "chrome/common/chrome_view_type.h"
25 #include "chrome/common/extensions/extension.h" 27 #include "chrome/common/extensions/extension.h"
26 #include "chrome/common/extensions/extension_messages.h" 28 #include "chrome/common/extensions/extension_messages.h"
27 #include "chrome/common/extensions/api/extension_api.h" 29 #include "chrome/common/extensions/api/extension_api.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 ListValue args; 96 ListValue args;
95 args.Set(0, Value::CreateStringValue(event_name)); 97 args.Set(0, Value::CreateStringValue(event_name));
96 args.Set(1, Value::CreateStringValue(event_args)); 98 args.Set(1, Value::CreateStringValue(event_args));
97 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL, 99 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL,
98 extension_id, kDispatchEvent, args, event_url, 100 extension_id, kDispatchEvent, args, event_url,
99 user_gesture == USER_GESTURE_ENABLED)); 101 user_gesture == USER_GESTURE_ENABLED));
100 } 102 }
101 103
102 ExtensionEventRouter::ExtensionEventRouter(Profile* profile) 104 ExtensionEventRouter::ExtensionEventRouter(Profile* profile)
103 : profile_(profile), 105 : profile_(profile),
104 extension_devtools_manager_(profile->GetExtensionDevToolsManager()) { 106 extension_devtools_manager_(
107 ExtensionSystemFactory::GetForProfile(profile)->devtools_manager()) {
105 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 108 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
106 content::NotificationService::AllSources()); 109 content::NotificationService::AllSources());
107 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 110 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
108 content::NotificationService::AllSources()); 111 content::NotificationService::AllSources());
109 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 112 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
110 content::Source<Profile>(profile_)); 113 content::Source<Profile>(profile_));
111 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 114 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
112 content::Source<Profile>(profile_)); 115 content::Source<Profile>(profile_));
113 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, 116 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
114 content::Source<Profile>(profile_)); 117 content::Source<Profile>(profile_));
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 389
387 void ExtensionEventRouter::MaybeLoadLazyBackgroundPage( 390 void ExtensionEventRouter::MaybeLoadLazyBackgroundPage(
388 Profile* profile, 391 Profile* profile,
389 const Extension* extension, 392 const Extension* extension,
390 const linked_ptr<ExtensionEvent>& event) { 393 const linked_ptr<ExtensionEvent>& event) {
391 const std::string* event_args; 394 const std::string* event_args;
392 if (!CanDispatchEventToProfile(profile, extension, event, &event_args)) 395 if (!CanDispatchEventToProfile(profile, extension, event, &event_args))
393 return; 396 return;
394 397
395 if (!CanDispatchEventNow(profile, extension)) { 398 if (!CanDispatchEventNow(profile, extension)) {
396 profile->GetLazyBackgroundTaskQueue()->AddPendingTask( 399 ExtensionSystemFactory::GetForProfile(profile)->
400 lazy_background_task_queue()->AddPendingTask(
397 profile, extension->id(), 401 profile, extension->id(),
398 base::Bind(&ExtensionEventRouter::DispatchPendingEvent, 402 base::Bind(&ExtensionEventRouter::DispatchPendingEvent,
399 base::Unretained(this), event)); 403 base::Unretained(this), event));
400 } 404 }
401 } 405 }
402 406
403 bool ExtensionEventRouter::CanDispatchEventNow( 407 bool ExtensionEventRouter::CanDispatchEventNow(
404 Profile* profile, const Extension* extension) { 408 Profile* profile, const Extension* extension) {
405 DCHECK(extension); 409 DCHECK(extension);
406 if (extension->has_lazy_background_page()) { 410 if (extension->has_lazy_background_page()) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 ExtensionModuleEventRouter::DispatchOnInstalledEvent(profile_, extension); 502 ExtensionModuleEventRouter::DispatchOnInstalledEvent(profile_, extension);
499 break; 503 break;
500 } 504 }
501 505
502 // TODO(tessamac): if background page crashed/failed clear queue. 506 // TODO(tessamac): if background page crashed/failed clear queue.
503 default: 507 default:
504 NOTREACHED(); 508 NOTREACHED();
505 return; 509 return;
506 } 510 }
507 } 511 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_devtools_bridge.cc ('k') | chrome/browser/extensions/extension_function_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698