Chromium Code Reviews| 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_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "ash/shelf/shelf_util.h" | 9 #include "ash/shelf/shelf_util.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ExtensionAppWindowLauncherController::OnAppWindowIconChanged( | 80 void ExtensionAppWindowLauncherController::OnAppWindowIconChanged( |
| 81 AppWindow* app_window) { | 81 AppWindow* app_window) { |
| 82 const std::string app_shelf_id = GetAppShelfId(app_window); | 82 const std::string app_shelf_id = GetAppShelfId(app_window); |
| 83 AppControllerMap::iterator iter = app_controller_map_.find(app_shelf_id); | 83 AppControllerMap::iterator iter = app_controller_map_.find(app_shelf_id); |
| 84 if (iter == app_controller_map_.end()) | 84 if (iter == app_controller_map_.end()) |
| 85 return; | 85 return; |
| 86 ExtensionAppWindowLauncherItemController* controller = iter->second; | 86 ExtensionAppWindowLauncherItemController* controller = iter->second; |
| 87 controller->set_image_set_by_controller(true); | 87 controller->set_image_set_by_controller(true); |
| 88 // Set window icon for showInShelf=true window. | |
| 89 if (app_window->show_in_shelf() && !app_window->window_icon().IsEmpty()) { | |
| 90 owner()->SetLauncherItemImage(controller->shelf_id(), | |
| 91 app_window->window_icon().AsImageSkia()); | |
| 92 return; | |
|
stevenjb
2016/08/04 21:00:47
nit: I would use an else here instead of an early
Andra Paraschiv
2016/08/08 13:34:12
Done.
| |
| 93 } | |
| 88 owner()->SetLauncherItemImage(controller->shelf_id(), | 94 owner()->SetLauncherItemImage(controller->shelf_id(), |
| 89 app_window->app_icon().AsImageSkia()); | 95 app_window->app_icon().AsImageSkia()); |
| 90 } | 96 } |
| 91 | 97 |
| 92 void ExtensionAppWindowLauncherController::OnAppWindowShown( | 98 void ExtensionAppWindowLauncherController::OnAppWindowShown( |
| 93 AppWindow* app_window, | 99 AppWindow* app_window, |
| 94 bool was_hidden) { | 100 bool was_hidden) { |
| 95 aura::Window* window = app_window->GetNativeWindow(); | 101 aura::Window* window = app_window->GetNativeWindow(); |
| 96 if (!IsRegisteredApp(window)) | 102 if (!IsRegisteredApp(window)) |
| 97 RegisterApp(app_window); | 103 RegisterApp(app_window); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 id_map.begin(), id_map.end(), | 179 id_map.begin(), id_map.end(), |
| 174 [shelf_id](const AppShelfIdToShelfIdMap::value_type& pair) { | 180 [shelf_id](const AppShelfIdToShelfIdMap::value_type& pair) { |
| 175 return pair.second == shelf_id; | 181 return pair.second == shelf_id; |
| 176 }) != id_map.end()) { | 182 }) != id_map.end()) { |
| 177 shelf_id = 0; | 183 shelf_id = 0; |
| 178 } | 184 } |
| 179 } | 185 } |
| 180 | 186 |
| 181 if (shelf_id == 0) { | 187 if (shelf_id == 0) { |
| 182 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status); | 188 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status); |
| 183 // Restore any existing app icon and flag as set. | |
| 184 const gfx::Image& app_icon = app_window->app_icon(); | 189 const gfx::Image& app_icon = app_window->app_icon(); |
| 185 if (!app_icon.IsEmpty()) { | 190 const gfx::Image& window_icon = app_window->window_icon(); |
| 191 // Restore any existing window icon for showInShelf=true window | |
| 192 // and flag as set. | |
| 193 if (app_window->show_in_shelf() && !window_icon.IsEmpty()) { | |
| 194 owner()->SetLauncherItemImage(shelf_id, window_icon.AsImageSkia()); | |
| 195 controller->set_image_set_by_controller(true); | |
| 196 // Restore any existing app icon and flag as set. | |
|
stevenjb
2016/08/04 21:00:47
This is confusing here. I would put both comments
Andra Paraschiv
2016/08/08 13:34:12
Done.
| |
| 197 } else if (!app_icon.IsEmpty()) { | |
| 186 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia()); | 198 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia()); |
| 187 controller->set_image_set_by_controller(true); | 199 controller->set_image_set_by_controller(true); |
| 188 } | 200 } |
| 189 } else { | 201 } else { |
| 190 owner()->SetItemController(shelf_id, controller); | 202 owner()->SetItemController(shelf_id, controller); |
| 191 } | 203 } |
| 192 | 204 |
| 193 // We need to change the controller associated with app_shelf_id. | 205 // We need to change the controller associated with app_shelf_id. |
| 194 app_controller_map_[app_shelf_id] = controller; | 206 app_controller_map_[app_shelf_id] = controller; |
| 195 app_shelf_id_to_shelf_id_map_[app_shelf_id] = shelf_id; | 207 app_shelf_id_to_shelf_id_map_[app_shelf_id] = shelf_id; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 WindowToAppShelfIdMap::iterator window_iter = | 251 WindowToAppShelfIdMap::iterator window_iter = |
| 240 window_to_app_shelf_id_map_.find(window); | 252 window_to_app_shelf_id_map_.find(window); |
| 241 if (window_iter == window_to_app_shelf_id_map_.end()) | 253 if (window_iter == window_to_app_shelf_id_map_.end()) |
| 242 return nullptr; | 254 return nullptr; |
| 243 AppControllerMap::iterator app_controller_iter = | 255 AppControllerMap::iterator app_controller_iter = |
| 244 app_controller_map_.find(window_iter->second); | 256 app_controller_map_.find(window_iter->second); |
| 245 if (app_controller_iter == app_controller_map_.end()) | 257 if (app_controller_iter == app_controller_map_.end()) |
| 246 return nullptr; | 258 return nullptr; |
| 247 return app_controller_iter->second; | 259 return app_controller_iter->second; |
| 248 } | 260 } |
| OLD | NEW |