Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Unified Diff: chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: cleanup Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc
index 41d5953e1cda765dc682a8263440d1ea3a7683d6..89489f620dedb97f7ec9d4acae03fac4a5dbd1cb 100644
--- a/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc
@@ -17,8 +17,11 @@
#include "ui/wm/core/window_animations.h"
AppWindowLauncherItemController::AppWindowLauncherItemController(
- const ash::ShelfID& shelf_id)
- : ash::ShelfItemDelegate(shelf_id), observed_windows_(this) {}
+ const ash::ShelfID& shelf_id,
+ ChromeLauncherController* owner)
+ : ash::ShelfItemDelegate(shelf_id),
+ owner_(owner),
+ observed_windows_(this) {}
AppWindowLauncherItemController::~AppWindowLauncherItemController() {}
@@ -143,6 +146,8 @@ void AppWindowLauncherItemController::OnWindowPropertyChanged(
status = ash::STATUS_RUNNING;
}
ChromeLauncherController::instance()->SetItemStatus(shelf_id(), status);
+ } else if (key == aura::client::kAppIconKey) {
+ UpdateLauncherItem();
}
}
@@ -174,3 +179,19 @@ AppWindowLauncherItemController::ActivateOrAdvanceToNextAppWindow(
}
return ash::SHELF_ACTION_NONE;
}
+
+void AppWindowLauncherItemController::UpdateLauncherItem() {
+ const gfx::ImageSkia* app_icon = nullptr;
+ ui::BaseWindow* last_active_window = GetLastActiveWindow();
+ if (last_active_window && last_active_window->GetNativeWindow()) {
+ app_icon = last_active_window->GetNativeWindow()->GetProperty(
+ aura::client::kAppIconKey);
+ }
+ if (app_icon && !app_icon->isNull()) {
+ set_image_set_by_controller(true);
+ owner()->SetLauncherItemImage(shelf_id(), *app_icon);
+ } else if (image_set_by_controller()) {
+ set_image_set_by_controller(false);
+ owner()->UpdateAppItemImage(shelf_id().app_id);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698