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

Side by Side Diff: chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: fix mac compile Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller .h" 5 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller .h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/app_icon_loader.h" 12 #include "chrome/browser/ui/app_icon_loader.h"
13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
14 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 14 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
15 #include "chrome/browser/ui/ash/launcher/arc_app_window.h" 15 #include "chrome/browser/ui/ash/launcher/arc_app_window.h"
16 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" 16 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
18 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 18 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/base/base_window.h" 20 #include "ui/base/base_window.h"
21 21
22 ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController( 22 ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController(
23 const std::string& arc_app_id, 23 const std::string& arc_app_id)
24 ChromeLauncherController* owner) 24 : AppWindowLauncherItemController(ash::ShelfID(arc_app_id)) {}
25 : AppWindowLauncherItemController(ash::ShelfID(arc_app_id)),
26 owner_(owner) {}
27 25
28 ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {} 26 ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {}
29 27
30 void ArcAppWindowLauncherItemController::AddTaskId(int task_id) { 28 void ArcAppWindowLauncherItemController::AddTaskId(int task_id) {
31 task_ids_.insert(task_id); 29 task_ids_.insert(task_id);
32 } 30 }
33 31
34 void ArcAppWindowLauncherItemController::RemoveTaskId(int task_id) { 32 void ArcAppWindowLauncherItemController::RemoveTaskId(int task_id) {
35 task_ids_.erase(task_id); 33 task_ids_.erase(task_id);
36 } 34 }
(...skipping 23 matching lines...) Expand all
60 } 58 }
61 59
62 void ArcAppWindowLauncherItemController::ExecuteCommand(uint32_t command_id, 60 void ArcAppWindowLauncherItemController::ExecuteCommand(uint32_t command_id,
63 int32_t event_flags) { 61 int32_t event_flags) {
64 ActivateIndexedApp(command_id); 62 ActivateIndexedApp(command_id);
65 } 63 }
66 64
67 ash::MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( 65 ash::MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems(
68 int event_flags) { 66 int event_flags) {
69 ash::MenuItemList items; 67 ash::MenuItemList items;
70 base::string16 app_title = 68 base::string16 app_title = LauncherControllerHelper::GetAppTitle(
71 LauncherControllerHelper::GetAppTitle(owner_->profile(), app_id()); 69 ChromeLauncherController::instance()->profile(), app_id());
72 for (auto it = windows().begin(); it != windows().end(); ++it) { 70 for (auto it = windows().begin(); it != windows().end(); ++it) {
73 // TODO(khmel): resolve correct icon here. 71 // TODO(khmel): resolve correct icon here.
74 size_t i = std::distance(windows().begin(), it); 72 size_t i = std::distance(windows().begin(), it);
75 aura::Window* window = (*it)->GetNativeWindow(); 73 aura::Window* window = (*it)->GetNativeWindow();
76 ash::mojom::MenuItemPtr item = ash::mojom::MenuItem::New(); 74 ash::mojom::MenuItemPtr item = ash::mojom::MenuItem::New();
77 item->command_id = base::checked_cast<uint32_t>(i); 75 item->command_id = base::checked_cast<uint32_t>(i);
78 item->label = (window && !window->GetTitle().empty()) ? window->GetTitle() 76 item->label = (window && !window->GetTitle().empty()) ? window->GetTitle()
79 : app_title; 77 : app_title;
80 items.push_back(std::move(item)); 78 items.push_back(std::move(item));
81 } 79 }
82 80
83 return items; 81 return items;
84 } 82 }
85
86 void ArcAppWindowLauncherItemController::UpdateLauncherItem() {
87 const ArcAppWindow* arc_app_window =
88 static_cast<const ArcAppWindow*>(GetLastActiveWindow());
89 if (!arc_app_window || arc_app_window->icon().isNull()) {
90 if (!image_set_by_controller())
91 return;
92 set_image_set_by_controller(false);
93 owner_->SetLauncherItemImage(shelf_id(), gfx::ImageSkia());
94 AppIconLoader* icon_loader = owner_->GetAppIconLoaderForApp(app_id());
95 if (icon_loader)
96 icon_loader->UpdateImage(app_id());
97 return;
98 }
99
100 owner_->SetLauncherItemImage(shelf_id(), arc_app_window->icon());
101 set_image_set_by_controller(true);
102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698