| 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/public/cpp/shelf_types.h" | 7 #include "ash/public/cpp/shelf_types.h" |
| 8 #include "ash/public/cpp/window_properties.h" | 8 #include "ash/public/cpp/window_properties.h" |
| 9 #include "ash/shelf/shelf_model.h" | 9 #include "ash/shelf/shelf_model.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 app_controller_iter->second; | 146 app_controller_iter->second; |
| 147 DCHECK_EQ(controller->app_id(), shelf_id.app_id); | 147 DCHECK_EQ(controller->app_id(), shelf_id.app_id); |
| 148 controller->AddAppWindow(app_window); | 148 controller->AddAppWindow(app_window); |
| 149 } else { | 149 } else { |
| 150 std::unique_ptr<ExtensionAppWindowLauncherItemController> controller = | 150 std::unique_ptr<ExtensionAppWindowLauncherItemController> controller = |
| 151 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id); | 151 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id); |
| 152 app_controller_map_[shelf_id] = controller.get(); | 152 app_controller_map_[shelf_id] = controller.get(); |
| 153 controller->AddAppWindow(app_window); | 153 controller->AddAppWindow(app_window); |
| 154 | 154 |
| 155 // Check for any existing pinned shelf item with a matching |shelf_id|. | 155 // Check for any existing pinned shelf item with a matching |shelf_id|. |
| 156 const int item_index = owner()->shelf_model()->ItemIndexByID(shelf_id); | 156 if (owner()->GetItem(shelf_id) == nullptr) { |
| 157 if (item_index < 0) { | |
| 158 owner()->CreateAppLauncherItem(std::move(controller), status); | 157 owner()->CreateAppLauncherItem(std::move(controller), status); |
| 159 // Restore any existing app icon and flag as set. | 158 // Restore any existing app icon and flag as set. |
| 160 if (app_window->HasCustomIcon() && !app_window->app_icon().IsEmpty()) { | 159 if (app_window->HasCustomIcon() && !app_window->app_icon().IsEmpty()) { |
| 161 owner()->SetLauncherItemImage(shelf_id, | 160 owner()->SetLauncherItemImage(shelf_id, |
| 162 app_window->app_icon().AsImageSkia()); | 161 app_window->app_icon().AsImageSkia()); |
| 163 app_controller_map_[shelf_id]->set_image_set_by_controller(true); | 162 app_controller_map_[shelf_id]->set_image_set_by_controller(true); |
| 164 } | 163 } |
| 165 } else { | 164 } else { |
| 166 owner()->shelf_model()->SetShelfItemDelegate(shelf_id, | 165 owner()->shelf_model()->SetShelfItemDelegate(shelf_id, |
| 167 std::move(controller)); | 166 std::move(controller)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 ExtensionAppWindowLauncherController::ControllerForWindow( | 203 ExtensionAppWindowLauncherController::ControllerForWindow( |
| 205 aura::Window* window) { | 204 aura::Window* window) { |
| 206 const auto window_iter = window_to_shelf_id_map_.find(window); | 205 const auto window_iter = window_to_shelf_id_map_.find(window); |
| 207 if (window_iter == window_to_shelf_id_map_.end()) | 206 if (window_iter == window_to_shelf_id_map_.end()) |
| 208 return nullptr; | 207 return nullptr; |
| 209 const auto controller_iter = app_controller_map_.find(window_iter->second); | 208 const auto controller_iter = app_controller_map_.find(window_iter->second); |
| 210 if (controller_iter == app_controller_map_.end()) | 209 if (controller_iter == app_controller_map_.end()) |
| 211 return nullptr; | 210 return nullptr; |
| 212 return controller_iter->second; | 211 return controller_iter->second; |
| 213 } | 212 } |
| OLD | NEW |