OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_browser_event_router.h" | 5 #include "chrome/browser/extensions/extension_browser_event_router.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_event_names.h" | 9 #include "chrome/browser/extensions/extension_event_names.h" |
10 #include "chrome/browser/extensions/extension_event_router.h" | 10 #include "chrome/browser/extensions/extension_event_router.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 ExtensionBrowserEventRouter::~ExtensionBrowserEventRouter() { | 108 ExtensionBrowserEventRouter::~ExtensionBrowserEventRouter() { |
109 BrowserList::RemoveObserver(this); | 109 BrowserList::RemoveObserver(this); |
110 #if defined(TOOLKIT_VIEWS) | 110 #if defined(TOOLKIT_VIEWS) |
111 views::FocusManager::GetWidgetFocusManager()->RemoveFocusChangeListener(this); | 111 views::FocusManager::GetWidgetFocusManager()->RemoveFocusChangeListener(this); |
112 #elif defined(TOOLKIT_GTK) | 112 #elif defined(TOOLKIT_GTK) |
113 ui::ActiveWindowWatcherX::RemoveObserver(this); | 113 ui::ActiveWindowWatcherX::RemoveObserver(this); |
114 #endif | 114 #endif |
115 } | 115 } |
116 | 116 |
117 void ExtensionBrowserEventRouter::OnBrowserAdded(const Browser* browser) { | 117 void ExtensionBrowserEventRouter::OnBrowserAdded(const Browser* browser) { |
118 if (!profile_->IsSameProfile(browser->profile())) | |
119 return; | |
120 RegisterForBrowserNotifications(browser); | 118 RegisterForBrowserNotifications(browser); |
121 } | 119 } |
122 | 120 |
123 void ExtensionBrowserEventRouter::RegisterForBrowserNotifications( | 121 void ExtensionBrowserEventRouter::RegisterForBrowserNotifications( |
124 const Browser* browser) { | 122 const Browser* browser) { |
| 123 if (!profile_->IsSameProfile(browser->profile())) |
| 124 return; |
125 // Start listening to TabStripModel events for this browser. | 125 // Start listening to TabStripModel events for this browser. |
126 browser->tabstrip_model()->AddObserver(this); | 126 browser->tabstrip_model()->AddObserver(this); |
127 | 127 |
128 // If this is a new window, it isn't ready at this point, so we register to be | 128 // If this is a new window, it isn't ready at this point, so we register to be |
129 // notified when it is. If this is an existing window, this is a no-op that we | 129 // notified when it is. If this is an existing window, this is a no-op that we |
130 // just do to reduce code complexity. | 130 // just do to reduce code complexity. |
131 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 131 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
132 Source<const Browser>(browser)); | 132 Source<const Browser>(browser)); |
133 | 133 |
134 for (int i = 0; i < browser->tabstrip_model()->count(); ++i) | 134 for (int i = 0; i < browser->tabstrip_model()->count(); ++i) |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 588 |
589 void ExtensionBrowserEventRouter::BrowserActionExecuted( | 589 void ExtensionBrowserEventRouter::BrowserActionExecuted( |
590 Profile* profile, const std::string& extension_id, Browser* browser) { | 590 Profile* profile, const std::string& extension_id, Browser* browser) { |
591 TabContentsWrapper* tab_contents = NULL; | 591 TabContentsWrapper* tab_contents = NULL; |
592 int tab_id = 0; | 592 int tab_id = 0; |
593 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) | 593 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) |
594 return; | 594 return; |
595 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", | 595 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", |
596 tab_contents->tab_contents(), true); | 596 tab_contents->tab_contents(), true); |
597 } | 597 } |
OLD | NEW |