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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/app_window_launcher_item_controller.h" 5 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
13 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 13 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
14 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
16 #include "ui/base/base_window.h" 16 #include "ui/base/base_window.h"
17 #include "ui/wm/core/window_animations.h" 17 #include "ui/wm/core/window_animations.h"
18 18
19 AppWindowLauncherItemController::AppWindowLauncherItemController( 19 AppWindowLauncherItemController::AppWindowLauncherItemController(
20 const ash::ShelfID& shelf_id) 20 const ash::ShelfID& shelf_id,
21 : ash::ShelfItemDelegate(shelf_id), observed_windows_(this) {} 21 ChromeLauncherController* owner)
22 : ash::ShelfItemDelegate(shelf_id),
23 owner_(owner),
24 observed_windows_(this) {}
22 25
23 AppWindowLauncherItemController::~AppWindowLauncherItemController() {} 26 AppWindowLauncherItemController::~AppWindowLauncherItemController() {}
24 27
25 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) { 28 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) {
26 windows_.push_front(app_window); 29 windows_.push_front(app_window);
27 aura::Window* window = app_window->GetNativeWindow(); 30 aura::Window* window = app_window->GetNativeWindow();
28 if (window) 31 if (window)
29 observed_windows_.Add(window); 32 observed_windows_.Add(window);
30 UpdateLauncherItem(); 33 UpdateLauncherItem();
31 } 34 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 if (key == aura::client::kDrawAttentionKey) { 139 if (key == aura::client::kDrawAttentionKey) {
137 ash::ShelfItemStatus status; 140 ash::ShelfItemStatus status;
138 if (ash::wm::IsActiveWindow(window)) { 141 if (ash::wm::IsActiveWindow(window)) {
139 status = ash::STATUS_ACTIVE; 142 status = ash::STATUS_ACTIVE;
140 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { 143 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) {
141 status = ash::STATUS_ATTENTION; 144 status = ash::STATUS_ATTENTION;
142 } else { 145 } else {
143 status = ash::STATUS_RUNNING; 146 status = ash::STATUS_RUNNING;
144 } 147 }
145 ChromeLauncherController::instance()->SetItemStatus(shelf_id(), status); 148 ChromeLauncherController::instance()->SetItemStatus(shelf_id(), status);
149 } else if (key == aura::client::kAppIconKey) {
150 UpdateLauncherItem();
146 } 151 }
147 } 152 }
148 153
149 ash::ShelfAction AppWindowLauncherItemController::ShowAndActivateOrMinimize( 154 ash::ShelfAction AppWindowLauncherItemController::ShowAndActivateOrMinimize(
150 ui::BaseWindow* app_window) { 155 ui::BaseWindow* app_window) {
151 // Either show or minimize windows when shown from the launcher. 156 // Either show or minimize windows when shown from the launcher.
152 return ChromeLauncherController::instance()->ActivateWindowOrMinimizeIfActive( 157 return ChromeLauncherController::instance()->ActivateWindowOrMinimizeIfActive(
153 app_window, GetAppMenuItems(ui::EF_NONE).size() == 1); 158 app_window, GetAppMenuItems(ui::EF_NONE).size() == 1);
154 } 159 }
155 160
(...skipping 11 matching lines...) Expand all
167 if (window_to_show->IsActive()) { 172 if (window_to_show->IsActive()) {
168 // Coming here, only a single window is active. For keyboard activations 173 // Coming here, only a single window is active. For keyboard activations
169 // the window gets animated. 174 // the window gets animated.
170 AnimateWindow(window_to_show->GetNativeWindow(), 175 AnimateWindow(window_to_show->GetNativeWindow(),
171 wm::WINDOW_ANIMATION_TYPE_BOUNCE); 176 wm::WINDOW_ANIMATION_TYPE_BOUNCE);
172 } else { 177 } else {
173 return ShowAndActivateOrMinimize(window_to_show); 178 return ShowAndActivateOrMinimize(window_to_show);
174 } 179 }
175 return ash::SHELF_ACTION_NONE; 180 return ash::SHELF_ACTION_NONE;
176 } 181 }
182
183 void AppWindowLauncherItemController::UpdateLauncherItem() {
184 const gfx::ImageSkia* app_icon = nullptr;
185 ui::BaseWindow* last_active_window = GetLastActiveWindow();
186 if (last_active_window && last_active_window->GetNativeWindow()) {
187 app_icon = last_active_window->GetNativeWindow()->GetProperty(
188 aura::client::kAppIconKey);
189 }
190 if (app_icon && !app_icon->isNull()) {
191 set_image_set_by_controller(true);
192 owner()->SetLauncherItemImage(shelf_id(), *app_icon);
193 } else if (image_set_by_controller()) {
194 set_image_set_by_controller(false);
195 owner()->UpdateAppItemImage(shelf_id().app_id);
196 }
197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698