Index: chrome/browser/ui/views/ash/launcher/launcher_updater.cc |
diff --git a/chrome/browser/ui/views/ash/launcher/launcher_updater.cc b/chrome/browser/ui/views/ash/launcher/launcher_updater.cc |
index 8f3c604710fae8c582a3acac0183eaff55d6780d..541ad14d8905106dd3a99b2cd16f6931f6f07f4e 100644 |
--- a/chrome/browser/ui/views/ash/launcher/launcher_updater.cc |
+++ b/chrome/browser/ui/views/ash/launcher/launcher_updater.cc |
@@ -56,8 +56,11 @@ void LauncherUpdater::Init() { |
ChromeLauncherDelegate::AppType app_type = |
type_ == TYPE_PANEL ? ChromeLauncherDelegate::APP_TYPE_PANEL |
: ChromeLauncherDelegate::APP_TYPE_WINDOW; |
+ ash::LauncherItemStatus app_status = |
+ ash::wm::IsActiveWindow(window_) ? |
+ ash::STATUS_ACTIVE : ash::STATUS_RUNNING; |
item_id_ = launcher_delegate_->CreateAppLauncherItem( |
- this, app_id_, app_type, ash::STATUS_RUNNING); |
+ this, app_id_, app_type, app_status); |
} else { |
// Determine if we have any tabs that should get launcher items. |
std::vector<TabContentsWrapper*> app_tabs; |
@@ -105,10 +108,24 @@ TabContentsWrapper* LauncherUpdater::GetTab(ash::LauncherID id) { |
return NULL; |
} |
+void LauncherUpdater::ActivationChanged(TabContentsWrapper* tab, bool active) { |
+ launcher_delegate_->SetItemStatus( |
sky
2012/03/13 17:14:42
Might tab be NULL here?
DaveMoore
2012/03/13 23:33:56
N/A after changing to BrowserActivationStateChange
|
+ GetLauncherID(tab), |
+ active ? ash::STATUS_ACTIVE : ash::STATUS_RUNNING); |
+} |
+ |
void LauncherUpdater::ActiveTabChanged(TabContentsWrapper* old_contents, |
TabContentsWrapper* new_contents, |
int index, |
bool user_gesture) { |
+ if (ash::wm::IsActiveWindow(window_)) { |
+ ash::LauncherID old_id = GetLauncherID(old_contents); |
+ ash::LauncherID new_id = GetLauncherID(new_contents); |
+ |
+ // The new_contents state will be handled in UpdateLauncher(). |
+ if (old_id != new_id && old_id >= 0) |
+ launcher_delegate_->SetItemStatus(old_id, ash::STATUS_RUNNING); |
+ } |
// Update immediately on a tab change. |
UpdateLauncher(new_contents); |
} |
@@ -186,6 +203,16 @@ void LauncherUpdater::TabDetachedAt(TabContentsWrapper* contents, int index) { |
} |
void LauncherUpdater::UpdateLauncher(TabContentsWrapper* tab) { |
+ |
sky
2012/03/13 17:14:42
nit: remove empty line.
DaveMoore
2012/03/13 23:33:56
Done.
|
+ ash::LauncherID id = GetLauncherID(tab); |
+ if (id >= 0) { |
sky
2012/03/13 17:14:42
When would this return <= 0?
|
+ ash::LauncherItemStatus status = |
+ ash::wm::IsActiveWindow(window_) && |
+ tab == tab_model_->GetActiveTabContents() ? |
+ ash::STATUS_ACTIVE : ash::STATUS_RUNNING; |
+ launcher_delegate_->SetItemStatus(id, status); |
+ } |
+ |
if (type_ == TYPE_APP) |
return; // TYPE_APP is entirely maintained by ChromeLauncherDelegate. |
@@ -297,7 +324,11 @@ void LauncherUpdater::UpdateAppTabState(TabContentsWrapper* tab, |
launcher_delegate_->GetAppID(tab), |
ChromeLauncherDelegate::APP_TYPE_TAB); |
RegisterAppItem(item_id_, tab); |
- launcher_delegate_->SetItemStatus(item_id_, ash::STATUS_RUNNING); |
+ ash::LauncherItemStatus status = |
+ ash::wm::IsActiveWindow(window_) && |
+ tab == tab_model_->GetActiveTabContents() ? |
+ ash::STATUS_ACTIVE : ash::STATUS_RUNNING; |
+ launcher_delegate_->SetItemStatus(item_id_, status); |
} |
item_id_ = -1; |
} else { |
@@ -307,11 +338,15 @@ void LauncherUpdater::UpdateAppTabState(TabContentsWrapper* tab, |
} |
void LauncherUpdater::AddAppItem(TabContentsWrapper* tab) { |
+ ash::LauncherItemStatus status = |
sky
2012/03/13 17:14:42
You have this code in three places. How about a Ge
DaveMoore
2012/03/13 23:33:56
Done.
|
+ ash::wm::IsActiveWindow(window_) && |
+ tab == tab_model_->GetActiveTabContents() ? |
+ ash::STATUS_ACTIVE : ash::STATUS_RUNNING; |
ash::LauncherID id = launcher_delegate_->CreateAppLauncherItem( |
this, |
launcher_delegate_->GetAppID(tab), |
ChromeLauncherDelegate::APP_TYPE_TAB, |
- ash::STATUS_RUNNING); |
+ status); |
RegisterAppItem(id, tab); |
} |
@@ -341,6 +376,15 @@ bool LauncherUpdater::ContainsID(ash::LauncherID id, TabContentsWrapper** tab) { |
return false; |
} |
+ash::LauncherID LauncherUpdater::GetLauncherID(TabContentsWrapper* tab) { |
+ if (type_ == TYPE_APP || type_ == TYPE_PANEL) |
+ return item_id_; |
+ AppTabMap::iterator i = app_map_.find(tab); |
+ if (i == app_map_.end()) |
+ return item_id_; |
+ return i->second.id; |
+} |
+ |
ash::LauncherModel* LauncherUpdater::launcher_model() { |
return launcher_delegate_->model(); |
} |