| 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/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 10 #include "ash/common/wm_window_property.h" | 10 #include "ash/common/wm_window_property.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()) |
| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 controller->AddAppWindow(app_window); | 178 controller->AddAppWindow(app_window); |
| 173 // If there is already a shelf id mapped to this app_shelf_id (e.g. pinned), | 179 // If there is already a shelf id mapped to this app_shelf_id (e.g. pinned), |
| 174 // use that shelf item. | 180 // use that shelf item. |
| 175 shelf_id = | 181 shelf_id = |
| 176 ash::WmShell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( | 182 ash::WmShell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( |
| 177 app_id, launch_id); | 183 app_id, launch_id); |
| 178 | 184 |
| 179 if (shelf_id == 0) { | 185 if (shelf_id == 0) { |
| 180 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status); | 186 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status); |
| 181 // Restore any existing app icon and flag as set. | 187 // Restore any existing app icon and flag as set. |
| 182 const gfx::Image& app_icon = app_window->app_icon(); | 188 if (app_window->HasCustomIcon() && !app_window->app_icon().IsEmpty()) { |
| 183 if (!app_icon.IsEmpty()) { | 189 owner()->SetLauncherItemImage(shelf_id, |
| 184 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia()); | 190 app_window->app_icon().AsImageSkia()); |
| 185 controller->set_image_set_by_controller(true); | 191 controller->set_image_set_by_controller(true); |
| 186 } | 192 } |
| 187 } else { | 193 } else { |
| 188 owner()->SetItemController(shelf_id, controller); | 194 owner()->SetItemController(shelf_id, controller); |
| 189 } | 195 } |
| 190 | 196 |
| 191 // We need to change the controller associated with app_shelf_id. | 197 // We need to change the controller associated with app_shelf_id. |
| 192 app_controller_map_[app_shelf_id] = controller; | 198 app_controller_map_[app_shelf_id] = controller; |
| 193 } | 199 } |
| 194 owner()->SetItemStatus(shelf_id, status); | 200 owner()->SetItemStatus(shelf_id, status); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 WindowToAppShelfIdMap::iterator window_iter = | 240 WindowToAppShelfIdMap::iterator window_iter = |
| 235 window_to_app_shelf_id_map_.find(window); | 241 window_to_app_shelf_id_map_.find(window); |
| 236 if (window_iter == window_to_app_shelf_id_map_.end()) | 242 if (window_iter == window_to_app_shelf_id_map_.end()) |
| 237 return nullptr; | 243 return nullptr; |
| 238 AppControllerMap::iterator app_controller_iter = | 244 AppControllerMap::iterator app_controller_iter = |
| 239 app_controller_map_.find(window_iter->second); | 245 app_controller_map_.find(window_iter->second); |
| 240 if (app_controller_iter == app_controller_map_.end()) | 246 if (app_controller_iter == app_controller_map_.end()) |
| 241 return nullptr; | 247 return nullptr; |
| 242 return app_controller_iter->second; | 248 return app_controller_iter->second; |
| 243 } | 249 } |
| OLD | NEW |