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

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: nit 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..876875922dc6137045610a7a493550cdd4c2f0eb 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() {}
@@ -27,7 +30,7 @@ void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) {
aura::Window* window = app_window->GetNativeWindow();
if (window)
observed_windows_.Add(window);
- UpdateLauncherItem();
+ UpdateShelfItemIcon();
}
AppWindowLauncherItemController::WindowList::iterator
@@ -51,7 +54,7 @@ void AppWindowLauncherItemController::RemoveWindow(ui::BaseWindow* app_window) {
return;
}
windows_.erase(iter);
- UpdateLauncherItem();
+ UpdateShelfItemIcon();
}
ui::BaseWindow* AppWindowLauncherItemController::GetAppWindow(
@@ -66,7 +69,7 @@ void AppWindowLauncherItemController::SetActiveWindow(aura::Window* window) {
ui::BaseWindow* app_window = GetAppWindow(window);
if (app_window)
last_active_window_ = app_window;
- UpdateLauncherItem();
+ UpdateShelfItemIcon();
}
AppWindowLauncherItemController*
@@ -143,6 +146,8 @@ void AppWindowLauncherItemController::OnWindowPropertyChanged(
status = ash::STATUS_RUNNING;
}
ChromeLauncherController::instance()->SetItemStatus(shelf_id(), status);
+ } else if (key == aura::client::kAppIconKey) {
+ UpdateShelfItemIcon();
}
}
@@ -174,3 +179,19 @@ AppWindowLauncherItemController::ActivateOrAdvanceToNextAppWindow(
}
return ash::SHELF_ACTION_NONE;
}
+
+void AppWindowLauncherItemController::UpdateShelfItemIcon() {
+ const gfx::ImageSkia* app_icon = nullptr;
+ ui::BaseWindow* last_active_window = GetLastActiveWindow();
stevenjb 2017/05/23 17:00:19 Could you add a comment briefly explaining the log
khmel 2017/05/23 17:35:00 Done.
+ 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);
msw 2017/05/23 17:17:40 q: can we get rid of image_set_by_controller? (may
khmel 2017/05/23 17:35:00 I think so. We still have a goal to get rid of App
+ owner()->SetLauncherItemImage(shelf_id(), *app_icon);
+ } else if (image_set_by_controller()) {
+ set_image_set_by_controller(false);
+ owner()->UpdateLauncherItemImage(shelf_id().app_id);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698