Chromium Code Reviews| 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..8e80e38211bd35cc1bb773f21c7cccfe7496be3e 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,23 @@ ash::MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( |
| : app_title; |
| items.push_back(std::move(item)); |
| } |
| + |
| return items; |
| } |
| + |
| +void ArcAppWindowLauncherItemController::UpdateLauncherItem() { |
| + const ArcAppWindow* arc_app_window = |
| + static_cast<const ArcAppWindow*>(GetLastActiveWindow()); |
| + if (!arc_app_window || arc_app_window->image_skia().isNull()) { |
|
Luis Héctor Chávez
2017/05/18 18:09:40
nit: use the guard clause pattern:
if (!arc_app_w
khmel
2017/05/18 20:27:52
Done.
|
| + 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); |
| + } |
| +} |