Chromium Code Reviews| Index: chrome/browser/extensions/extension_event_router_forwarder.cc |
| diff --git a/chrome/browser/extensions/extension_event_router_forwarder.cc b/chrome/browser/extensions/extension_event_router_forwarder.cc |
| index b0189081ce1192a7a6372947f0c639b0e9dd22b5..a158e9e056f43078e320a5e56f95c7126a8bfeae 100644 |
| --- a/chrome/browser/extensions/extension_event_router_forwarder.cc |
| +++ b/chrome/browser/extensions/extension_event_router_forwarder.cc |
| @@ -6,7 +6,6 @@ |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/extensions/extension_event_router.h" |
| -#include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "googleurl/src/gurl.h" |
| @@ -19,15 +18,16 @@ ExtensionEventRouterForwarder::~ExtensionEventRouterForwarder() { |
| void ExtensionEventRouterForwarder::BroadcastEventToRenderers( |
| const std::string& event_name, const std::string& event_args, |
| const GURL& event_url) { |
| - HandleEvent("", event_name, event_args, NULL, true, event_url); |
| + HandleEvent("", event_name, event_args, 0, true, event_url); |
| } |
| void ExtensionEventRouterForwarder::DispatchEventToRenderers( |
| const std::string& event_name, const std::string& event_args, |
| - Profile* profile, bool use_profile_to_restrict_events, |
| + ProfileId profile_id, bool use_profile_to_restrict_events, |
| const GURL& event_url) { |
| - DCHECK(profile); |
| - HandleEvent("", event_name, event_args, profile, |
| + if (profile_id == Profile::InvalidProfileId) |
| + return; |
| + HandleEvent("", event_name, event_args, profile_id, |
| use_profile_to_restrict_events, event_url); |
| } |
| @@ -35,23 +35,24 @@ void ExtensionEventRouterForwarder::BroadcastEventToExtension( |
| const std::string& extension_id, |
| const std::string& event_name, const std::string& event_args, |
| const GURL& event_url) { |
| - HandleEvent(extension_id, event_name, event_args, NULL, true, event_url); |
| + HandleEvent(extension_id, event_name, event_args, 0, true, event_url); |
| } |
| void ExtensionEventRouterForwarder::DispatchEventToExtension( |
| const std::string& extension_id, |
| const std::string& event_name, const std::string& event_args, |
| - Profile* profile, bool use_profile_to_restrict_events, |
| + ProfileId profile_id, bool use_profile_to_restrict_events, |
| const GURL& event_url) { |
| - DCHECK(profile); |
| - HandleEvent(extension_id, event_name, event_args, profile, |
| + if (profile_id == Profile::InvalidProfileId) |
| + return; |
| + HandleEvent(extension_id, event_name, event_args, profile_id, |
| use_profile_to_restrict_events, event_url); |
| } |
| void ExtensionEventRouterForwarder::HandleEvent( |
| const std::string& extension_id, |
| const std::string& event_name, const std::string& event_args, |
| - Profile* profile, bool use_profile_to_restrict_events, |
| + ProfileId profile_id, bool use_profile_to_restrict_events, |
| const GURL& event_url) { |
| if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| BrowserThread::PostTask( |
| @@ -59,7 +60,7 @@ void ExtensionEventRouterForwarder::HandleEvent( |
| NewRunnableMethod( |
| this, |
| &ExtensionEventRouterForwarder::HandleEvent, |
| - extension_id, event_name, event_args, profile, |
| + extension_id, event_name, event_args, profile_id, |
| use_profile_to_restrict_events, event_url)); |
| return; |
| } |
| @@ -68,9 +69,10 @@ void ExtensionEventRouterForwarder::HandleEvent( |
| return; |
| ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| + Profile* profile = profile_manager->GetProfileWithId(profile_id); |
| + if (profile_id != Profile::InvalidProfileId && !profile) |
|
willchan no longer on Chromium
2011/02/28 21:48:41
Shouldn't we only call GetProfileWithId() if profi
|
| + return; |
| if (profile) { |
| - if (!profile_manager->IsValidProfile(profile)) |
| - return; |
| CallExtensionEventRouter( |
| profile, extension_id, event_name, event_args, |
| use_profile_to_restrict_events ? profile : NULL, event_url); |