Index: chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc |
diff --git a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc |
index 6f6bfb7a4f07a6c27efdccf5922a245de6ea3bc1..9e698323a17e5f3b286a345fac9201b9562f8200 100644 |
--- a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc |
+++ b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc |
@@ -9,8 +9,10 @@ |
#include "base/memory/ptr_util.h" |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/ui/app_icon_loader.h" |
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
+#include "chrome/browser/ui/ash/launcher/arc_app_window.h" |
#include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
#include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
@@ -18,8 +20,10 @@ |
#include "ui/base/base_window.h" |
ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController( |
- const std::string& arc_app_id) |
- : AppWindowLauncherItemController(ash::ShelfID(arc_app_id)) {} |
+ const std::string& arc_app_id, |
+ ChromeLauncherController* owner) |
+ : AppWindowLauncherItemController(ash::ShelfID(arc_app_id)), |
+ owner_(owner) {} |
ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {} |
@@ -63,8 +67,8 @@ void ArcAppWindowLauncherItemController::ExecuteCommand(uint32_t command_id, |
ash::MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( |
int event_flags) { |
ash::MenuItemList items; |
- base::string16 app_title = LauncherControllerHelper::GetAppTitle( |
- ChromeLauncherController::instance()->profile(), app_id()); |
+ base::string16 app_title = |
+ LauncherControllerHelper::GetAppTitle(owner_->profile(), app_id()); |
for (auto it = windows().begin(); it != windows().end(); ++it) { |
// TODO(khmel): resolve correct icon here. |
size_t i = std::distance(windows().begin(), it); |
@@ -75,5 +79,34 @@ ash::MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( |
: app_title; |
items.push_back(std::move(item)); |
} |
+ |
return items; |
} |
+ |
+void ArcAppWindowLauncherItemController::OnWindowChanged( |
+ ArcAppWindow* arc_app_window) { |
+ DCHECK(arc_app_window && arc_app_window->controller() == this); |
+ if (GetLastActiveWindow() == arc_app_window) |
+ UpdateIcon(arc_app_window); |
+} |
+ |
+void ArcAppWindowLauncherItemController::UpdateIcon( |
+ ArcAppWindow* arc_app_window) { |
+ if (!arc_app_window || arc_app_window->image_skia().isNull()) { |
+ if (image_set_by_controller()) { |
+ set_image_set_by_controller(false); |
+ owner_->SetLauncherItemImage(shelf_id(), gfx::ImageSkia()); |
+ AppIconLoader* icon_loader = owner_->GetAppIconLoaderForApp(app_id()); |
+ if (icon_loader) |
+ icon_loader->UpdateImage(app_id()); |
+ } |
+ } else { |
+ owner_->SetLauncherItemImage(shelf_id(), arc_app_window->image_skia()); |
+ set_image_set_by_controller(true); |
+ } |
+} |
+ |
+void ArcAppWindowLauncherItemController::OnActiveWindowChanged( |
+ ui::BaseWindow* active_window) { |
+ UpdateIcon(static_cast<ArcAppWindow*>(active_window)); |
+} |