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

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

Issue 9977021: Add ExtensionSytem::Get(Profile*) as a wrapper around (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" 18 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/extensions/extension_system_factory.h"
20 #include "chrome/browser/extensions/extension_tabs_module.h" 19 #include "chrome/browser/extensions/extension_tabs_module.h"
21 #include "chrome/browser/extensions/lazy_background_task_queue.h" 20 #include "chrome/browser/extensions/lazy_background_task_queue.h"
22 #include "chrome/browser/extensions/process_map.h" 21 #include "chrome/browser/extensions/process_map.h"
23 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/chrome_view_type.h" 25 #include "chrome/common/chrome_view_type.h"
27 #include "chrome/common/extensions/extension.h" 26 #include "chrome/common/extensions/extension.h"
28 #include "chrome/common/extensions/extension_messages.h" 27 #include "chrome/common/extensions/extension_messages.h"
29 #include "chrome/common/extensions/api/extension_api.h" 28 #include "chrome/common/extensions/api/extension_api.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 args.Set(0, Value::CreateStringValue(event_name)); 96 args.Set(0, Value::CreateStringValue(event_name));
98 args.Set(1, Value::CreateStringValue(event_args)); 97 args.Set(1, Value::CreateStringValue(event_args));
99 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL, 98 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL,
100 extension_id, kDispatchEvent, args, event_url, 99 extension_id, kDispatchEvent, args, event_url,
101 user_gesture == USER_GESTURE_ENABLED)); 100 user_gesture == USER_GESTURE_ENABLED));
102 } 101 }
103 102
104 ExtensionEventRouter::ExtensionEventRouter(Profile* profile) 103 ExtensionEventRouter::ExtensionEventRouter(Profile* profile)
105 : profile_(profile), 104 : profile_(profile),
106 extension_devtools_manager_( 105 extension_devtools_manager_(
107 ExtensionSystemFactory::GetForProfile(profile)->devtools_manager()) { 106 ExtensionSystem::Get(profile)->devtools_manager()) {
108 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 107 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
109 content::NotificationService::AllSources()); 108 content::NotificationService::AllSources());
110 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 109 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
111 content::NotificationService::AllSources()); 110 content::NotificationService::AllSources());
112 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 111 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
113 content::Source<Profile>(profile_)); 112 content::Source<Profile>(profile_));
114 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 113 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
115 content::Source<Profile>(profile_)); 114 content::Source<Profile>(profile_));
116 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, 115 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
117 content::Source<Profile>(profile_)); 116 content::Source<Profile>(profile_));
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 388
390 void ExtensionEventRouter::MaybeLoadLazyBackgroundPage( 389 void ExtensionEventRouter::MaybeLoadLazyBackgroundPage(
391 Profile* profile, 390 Profile* profile,
392 const Extension* extension, 391 const Extension* extension,
393 const linked_ptr<ExtensionEvent>& event) { 392 const linked_ptr<ExtensionEvent>& event) {
394 const std::string* event_args; 393 const std::string* event_args;
395 if (!CanDispatchEventToProfile(profile, extension, event, &event_args)) 394 if (!CanDispatchEventToProfile(profile, extension, event, &event_args))
396 return; 395 return;
397 396
398 LazyBackgroundTaskQueue* queue = 397 LazyBackgroundTaskQueue* queue =
399 ExtensionSystemFactory::GetForProfile(profile)-> 398 ExtensionSystem::Get(profile)->lazy_background_task_queue();
400 lazy_background_task_queue();
401 if (queue->ShouldEnqueueTask(profile, extension)) { 399 if (queue->ShouldEnqueueTask(profile, extension)) {
402 queue->AddPendingTask( 400 queue->AddPendingTask(
403 profile, extension->id(), 401 profile, extension->id(),
404 base::Bind(&ExtensionEventRouter::DispatchPendingEvent, 402 base::Bind(&ExtensionEventRouter::DispatchPendingEvent,
405 base::Unretained(this), event)); 403 base::Unretained(this), event));
406 } 404 }
407 } 405 }
408 406
409 void ExtensionEventRouter::IncrementInFlightEvents( 407 void ExtensionEventRouter::IncrementInFlightEvents(
410 Profile* profile, const Extension* extension) { 408 Profile* profile, const Extension* extension) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 ExtensionModuleEventRouter::DispatchOnInstalledEvent(profile_, extension); 493 ExtensionModuleEventRouter::DispatchOnInstalledEvent(profile_, extension);
496 break; 494 break;
497 } 495 }
498 496
499 // TODO(tessamac): if background page crashed/failed clear queue. 497 // TODO(tessamac): if background page crashed/failed clear queue.
500 default: 498 default:
501 NOTREACHED(); 499 NOTREACHED();
502 return; 500 return;
503 } 501 }
504 } 502 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698