OLD | NEW |
---|---|
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/extension_app_window_launcher_controlle r.h" | 5 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_controlle r.h" |
6 | 6 |
7 #include "ash/common/shelf/shelf_delegate.h" | 7 #include "ash/common/shelf/shelf_delegate.h" |
8 #include "ash/common/wm_window.h" | 8 #include "ash/common/wm_window.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/window_properties.h" | 10 #include "ash/wm/window_properties.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 registry->AddObserver(this); | 85 registry->AddObserver(this); |
86 registry_.insert(registry); | 86 registry_.insert(registry); |
87 } | 87 } |
88 | 88 |
89 void ExtensionAppWindowLauncherController::OnAppWindowIconChanged( | 89 void ExtensionAppWindowLauncherController::OnAppWindowIconChanged( |
90 AppWindow* app_window) { | 90 AppWindow* app_window) { |
91 const std::string app_shelf_id = GetAppShelfId(app_window); | 91 const std::string app_shelf_id = GetAppShelfId(app_window); |
92 AppControllerMap::iterator iter = app_controller_map_.find(app_shelf_id); | 92 AppControllerMap::iterator iter = app_controller_map_.find(app_shelf_id); |
93 if (iter == app_controller_map_.end()) | 93 if (iter == app_controller_map_.end()) |
94 return; | 94 return; |
95 | |
96 // Check if the window actually overrides its default icon. Otherwise use app | |
97 // icon loader provided by owner. | |
98 if (!app_window->HasCustomIcon() || app_window->app_icon().IsEmpty()) | |
msw
2017/04/06 20:23:34
Should HasCustomIcon also check !app_window->app_i
khmel
2017/04/06 20:39:15
Not sure, that means custom icon is set but might
msw
2017/04/06 20:48:22
What you have is fine for now.
| |
99 return; | |
100 | |
95 ExtensionAppWindowLauncherItemController* controller = iter->second; | 101 ExtensionAppWindowLauncherItemController* controller = iter->second; |
96 controller->set_image_set_by_controller(true); | 102 controller->set_image_set_by_controller(true); |
97 owner()->SetLauncherItemImage(controller->shelf_id(), | 103 owner()->SetLauncherItemImage(controller->shelf_id(), |
98 app_window->app_icon().AsImageSkia()); | 104 app_window->app_icon().AsImageSkia()); |
99 } | 105 } |
100 | 106 |
101 void ExtensionAppWindowLauncherController::OnAppWindowShown( | 107 void ExtensionAppWindowLauncherController::OnAppWindowShown( |
102 AppWindow* app_window, | 108 AppWindow* app_window, |
103 bool was_hidden) { | 109 bool was_hidden) { |
104 aura::Window* window = app_window->GetNativeWindow(); | 110 aura::Window* window = app_window->GetNativeWindow(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 controller->AddAppWindow(app_window); | 181 controller->AddAppWindow(app_window); |
176 // If there is already a shelf id mapped to this AppLaunchId (e.g. pinned), | 182 // If there is already a shelf id mapped to this AppLaunchId (e.g. pinned), |
177 // use that shelf item. | 183 // use that shelf item. |
178 shelf_id = | 184 shelf_id = |
179 ash::Shell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( | 185 ash::Shell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( |
180 app_id, launch_id); | 186 app_id, launch_id); |
181 | 187 |
182 if (shelf_id == 0) { | 188 if (shelf_id == 0) { |
183 shelf_id = owner()->CreateAppLauncherItem(std::move(controller), status); | 189 shelf_id = owner()->CreateAppLauncherItem(std::move(controller), status); |
184 // Restore any existing app icon and flag as set. | 190 // Restore any existing app icon and flag as set. |
185 const gfx::Image& app_icon = app_window->app_icon(); | 191 if (app_window->HasCustomIcon() && !app_window->app_icon().IsEmpty()) { |
186 if (!app_icon.IsEmpty()) { | 192 const gfx::Image& app_icon = app_window->app_icon(); |
187 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia()); | 193 if (!app_icon.IsEmpty()) { |
msw
2017/04/06 20:23:34
This check is now redundant with the one on line 1
khmel
2017/04/06 20:39:15
Done.
| |
188 item_controller->set_image_set_by_controller(true); | 194 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia()); |
195 item_controller->set_image_set_by_controller(true); | |
196 } | |
189 } | 197 } |
190 } else { | 198 } else { |
191 owner()->SetShelfItemDelegate(shelf_id, std::move(controller)); | 199 owner()->SetShelfItemDelegate(shelf_id, std::move(controller)); |
192 } | 200 } |
193 | 201 |
194 // We need to change the controller associated with app_shelf_id. | 202 // We need to change the controller associated with app_shelf_id. |
195 app_controller_map_[app_shelf_id] = item_controller; | 203 app_controller_map_[app_shelf_id] = item_controller; |
196 } | 204 } |
197 owner()->SetItemStatus(shelf_id, status); | 205 owner()->SetItemStatus(shelf_id, status); |
198 ash::WmWindow::Get(window)->aura_window()->SetProperty(ash::kShelfIDKey, | 206 ash::WmWindow::Get(window)->aura_window()->SetProperty(ash::kShelfIDKey, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 WindowToAppShelfIdMap::iterator window_iter = | 245 WindowToAppShelfIdMap::iterator window_iter = |
238 window_to_app_shelf_id_map_.find(window); | 246 window_to_app_shelf_id_map_.find(window); |
239 if (window_iter == window_to_app_shelf_id_map_.end()) | 247 if (window_iter == window_to_app_shelf_id_map_.end()) |
240 return nullptr; | 248 return nullptr; |
241 AppControllerMap::iterator app_controller_iter = | 249 AppControllerMap::iterator app_controller_iter = |
242 app_controller_map_.find(window_iter->second); | 250 app_controller_map_.find(window_iter->second); |
243 if (app_controller_iter == app_controller_map_.end()) | 251 if (app_controller_iter == app_controller_map_.end()) |
244 return nullptr; | 252 return nullptr; |
245 return app_controller_iter->second; | 253 return app_controller_iter->second; |
246 } | 254 } |
OLD | NEW |