Index: chrome/browser/extensions/extension_browser_event_router.cc |
=================================================================== |
--- chrome/browser/extensions/extension_browser_event_router.cc (revision 71520) |
+++ chrome/browser/extensions/extension_browser_event_router.cc (working copy) |
@@ -61,10 +61,6 @@ |
return changed_properties; |
} |
-ExtensionBrowserEventRouter* ExtensionBrowserEventRouter::GetInstance() { |
- return Singleton<ExtensionBrowserEventRouter>::get(); |
-} |
- |
static void DispatchEvent(Profile* profile, |
const char* event_name, |
const std::string& json_args) { |
@@ -111,11 +107,9 @@ |
DispatchEvent(profile, event_name, json_args); |
} |
-void ExtensionBrowserEventRouter::Init(Profile* profile) { |
+void ExtensionBrowserEventRouter::Init() { |
if (initialized_) |
return; |
- DCHECK(!profile->IsOffTheRecord()); |
- profile_ = profile; |
BrowserList::AddObserver(this); |
#if defined(TOOLKIT_VIEWS) |
views::FocusManager::GetWidgetFocusManager()->AddFocusChangeListener(this); |
@@ -148,12 +142,21 @@ |
initialized_ = true; |
} |
-ExtensionBrowserEventRouter::ExtensionBrowserEventRouter() |
+ExtensionBrowserEventRouter::ExtensionBrowserEventRouter(Profile* profile) |
: initialized_(false), |
focused_window_id_(extension_misc::kUnknownWindowId), |
- profile_(NULL) { } |
+ profile_(profile) { |
+ DCHECK(!profile->IsOffTheRecord()); |
+} |
-ExtensionBrowserEventRouter::~ExtensionBrowserEventRouter() {} |
+ExtensionBrowserEventRouter::~ExtensionBrowserEventRouter() { |
+ BrowserList::RemoveObserver(this); |
+#if defined(TOOLKIT_VIEWS) |
+ views::FocusManager::GetWidgetFocusManager()->RemoveFocusChangeListener(this); |
+#elif defined(TOOLKIT_GTK) |
+ ActiveWindowWatcherX::RemoveObserver(this); |
+#endif |
+} |
void ExtensionBrowserEventRouter::OnBrowserAdded(const Browser* browser) { |
RegisterForBrowserNotifications(browser); |