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

Side by Side Diff: chrome/browser/ui/ash/launcher/extension_app_window_launcher_controller.cc

Issue 2791803002: mash: Move LauncherItemController to ash, rename ShelfItemDelegate. (Closed)
Patch Set: Sync and rebase. Created 3 years, 8 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 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 ash::ShelfID shelf_id = 0; 159 ash::ShelfID shelf_id = 0;
160 160
161 if (app_controller_iter != app_controller_map_.end()) { 161 if (app_controller_iter != app_controller_map_.end()) {
162 ExtensionAppWindowLauncherItemController* controller = 162 ExtensionAppWindowLauncherItemController* controller =
163 app_controller_iter->second; 163 app_controller_iter->second;
164 DCHECK(controller->app_id() == app_id); 164 DCHECK(controller->app_id() == app_id);
165 shelf_id = controller->shelf_id(); 165 shelf_id = controller->shelf_id();
166 controller->AddAppWindow(app_window); 166 controller->AddAppWindow(app_window);
167 } else { 167 } else {
168 std::string launch_id = GetLaunchId(app_window); 168 std::string launch_id = GetLaunchId(app_window);
169 ExtensionAppWindowLauncherItemController* controller = 169 std::unique_ptr<ExtensionAppWindowLauncherItemController> controller =
170 new ExtensionAppWindowLauncherItemController( 170 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
171 ash::AppLaunchId(app_id, launch_id), owner()); 171 ash::AppLaunchId(app_id, launch_id));
172 ExtensionAppWindowLauncherItemController* item_controller =
173 controller.get();
174
172 controller->AddAppWindow(app_window); 175 controller->AddAppWindow(app_window);
173 // If there is already a shelf id mapped to this AppLaunchId (e.g. pinned), 176 // If there is already a shelf id mapped to this AppLaunchId (e.g. pinned),
174 // use that shelf item. 177 // use that shelf item.
175 shelf_id = 178 shelf_id =
176 ash::Shell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( 179 ash::Shell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID(
177 app_id, launch_id); 180 app_id, launch_id);
178 181
179 if (shelf_id == 0) { 182 if (shelf_id == 0) {
180 shelf_id = owner()->CreateAppLauncherItem(controller, status); 183 shelf_id = owner()->CreateAppLauncherItem(std::move(controller), status);
181 // Restore any existing app icon and flag as set. 184 // Restore any existing app icon and flag as set.
182 const gfx::Image& app_icon = app_window->app_icon(); 185 const gfx::Image& app_icon = app_window->app_icon();
183 if (!app_icon.IsEmpty()) { 186 if (!app_icon.IsEmpty()) {
184 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia()); 187 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia());
185 controller->set_image_set_by_controller(true); 188 item_controller->set_image_set_by_controller(true);
186 } 189 }
187 } else { 190 } else {
188 owner()->SetItemController(shelf_id, controller); 191 owner()->SetShelfItemDelegate(shelf_id, std::move(controller));
189 } 192 }
190 193
191 // We need to change the controller associated with app_shelf_id. 194 // We need to change the controller associated with app_shelf_id.
192 app_controller_map_[app_shelf_id] = controller; 195 app_controller_map_[app_shelf_id] = item_controller;
193 } 196 }
194 owner()->SetItemStatus(shelf_id, status); 197 owner()->SetItemStatus(shelf_id, status);
195 ash::WmWindow::Get(window)->aura_window()->SetProperty(ash::kShelfIDKey, 198 ash::WmWindow::Get(window)->aura_window()->SetProperty(ash::kShelfIDKey,
196 shelf_id); 199 shelf_id);
197 } 200 }
198 201
199 void ExtensionAppWindowLauncherController::UnregisterApp(aura::Window* window) { 202 void ExtensionAppWindowLauncherController::UnregisterApp(aura::Window* window) {
200 WindowToAppShelfIdMap::iterator window_iter = 203 WindowToAppShelfIdMap::iterator window_iter =
201 window_to_app_shelf_id_map_.find(window); 204 window_to_app_shelf_id_map_.find(window);
202 DCHECK(window_iter != window_to_app_shelf_id_map_.end()); 205 DCHECK(window_iter != window_to_app_shelf_id_map_.end());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 WindowToAppShelfIdMap::iterator window_iter = 237 WindowToAppShelfIdMap::iterator window_iter =
235 window_to_app_shelf_id_map_.find(window); 238 window_to_app_shelf_id_map_.find(window);
236 if (window_iter == window_to_app_shelf_id_map_.end()) 239 if (window_iter == window_to_app_shelf_id_map_.end())
237 return nullptr; 240 return nullptr;
238 AppControllerMap::iterator app_controller_iter = 241 AppControllerMap::iterator app_controller_iter =
239 app_controller_map_.find(window_iter->second); 242 app_controller_map_.find(window_iter->second);
240 if (app_controller_iter == app_controller_map_.end()) 243 if (app_controller_iter == app_controller_map_.end())
241 return nullptr; 244 return nullptr;
242 return app_controller_iter->second; 245 return app_controller_iter->second;
243 } 246 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698