summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc7
-rw-r--r--chrome/browser/ui/ash/launcher/browser_status_monitor.cc25
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc3
3 files changed, 26 insertions, 9 deletions
diff --git a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
index 706356e..5e1e8c5 100644
--- a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
@@ -272,7 +272,7 @@ void BrowserShortcutLauncherItemController::ActivateOrAdvanceToNextBrowser() {
items.push_back(*it);
}
// If there are no suitable browsers we create a new one.
- if (!items.size()) {
+ if (items.empty()) {
launcher_controller()->CreateNewWindow();
return;
}
@@ -288,8 +288,8 @@ void BrowserShortcutLauncherItemController::ActivateOrAdvanceToNextBrowser() {
browser = items[0];
} else {
// If there is more then one suitable browser, we advance to the next if
- // |current_browser| is already active - or - check the last used browser
- // if it can be used.
+ // |browser| is already active - or - check the last used browser if it can
+ // be used.
std::vector<Browser*>::iterator i =
std::find(items.begin(), items.end(), browser);
if (i != items.end()) {
@@ -311,6 +311,7 @@ void BrowserShortcutLauncherItemController::ActivateOrAdvanceToNextBrowser() {
bool BrowserShortcutLauncherItemController::IsBrowserRepresentedInBrowserList(
Browser* browser) {
return (browser &&
+ browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH &&
(browser->is_type_tabbed() ||
!browser->is_app() ||
!browser->is_type_popup() ||
diff --git a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
index 738e2fb..c9965ed 100644
--- a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
+++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
@@ -27,10 +27,7 @@ BrowserStatusMonitor::BrowserStatusMonitor(
observed_activation_clients_(this),
observed_root_windows_(this) {
DCHECK(launcher_controller_);
- BrowserList* browser_list =
- BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
-
- browser_list->AddObserver(this);
+ BrowserList::AddObserver(this);
// This check needs for win7_aura. Without this, all tests in
// ChromeLauncherController will fail in win7_aura.
@@ -57,10 +54,14 @@ BrowserStatusMonitor::~BrowserStatusMonitor() {
if (ash::Shell::HasInstance())
ash::Shell::GetInstance()->GetScreen()->RemoveObserver(this);
+ BrowserList::RemoveObserver(this);
+
BrowserList* browser_list =
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
-
- browser_list->RemoveObserver(this);
+ for (BrowserList::const_iterator i = browser_list->begin();
+ i != browser_list->end(); ++i) {
+ OnBrowserRemoved(*i);
+ }
}
void BrowserStatusMonitor::OnWindowActivated(aura::Window* gained_active,
@@ -86,6 +87,9 @@ void BrowserStatusMonitor::OnWindowDestroyed(aura::Window* window) {
}
void BrowserStatusMonitor::OnBrowserAdded(Browser* browser) {
+ if (browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH)
+ return;
+
browser->tab_strip_model()->AddObserver(this);
if (browser->is_type_popup() && browser->is_app()) {
@@ -99,6 +103,9 @@ void BrowserStatusMonitor::OnBrowserAdded(Browser* browser) {
}
void BrowserStatusMonitor::OnBrowserRemoved(Browser* browser) {
+ if (browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH)
+ return;
+
browser->tab_strip_model()->RemoveObserver(this);
if (browser_to_app_id_map_.find(browser) != browser_to_app_id_map_.end()) {
@@ -141,6 +148,9 @@ void BrowserStatusMonitor::ActiveTabChanged(content::WebContents* old_contents,
if (old_contents)
browser = chrome::FindBrowserWithWebContents(old_contents);
+ if (browser && browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH)
+ return;
+
// Update immediately on a tab change.
if (browser &&
(TabStripModel::kNoTab !=
@@ -190,6 +200,9 @@ void BrowserStatusMonitor::UpdateAppAndBrowserState(
ChromeLauncherController::APP_STATE_INACTIVE;
Browser* browser = chrome::FindBrowserWithWebContents(contents);
+ DCHECK(browser);
+ if (browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH)
+ return;
if (browser->tab_strip_model()->GetActiveWebContents() == contents) {
if (browser->window()->IsActive())
app_state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE;
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
index 4fb9cdd..8648b1f 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -253,6 +253,9 @@ ChromeLauncherController::ChromeLauncherController(
}
ChromeLauncherController::~ChromeLauncherController() {
+ // Reset the BrowserStatusMonitor as it has a weak pointer to this.
+ browser_status_monitor_.reset();
+
// Reset the shell window controller here since it has a weak pointer to this.
shell_window_controller_.reset();