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/chrome_launcher_controller_mus.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 9 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
10 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 10 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 const std::string& app_id, | 272 const std::string& app_id, |
273 const gfx::ImageSkia& image) { | 273 const gfx::ImageSkia& image) { |
274 if (ConnectToShelfController()) | 274 if (ConnectToShelfController()) |
275 shelf_controller()->SetItemImage(app_id, *image.bitmap()); | 275 shelf_controller()->SetItemImage(app_id, *image.bitmap()); |
276 } | 276 } |
277 | 277 |
278 void ChromeLauncherControllerMus::PinAppsFromPrefs() { | 278 void ChromeLauncherControllerMus::PinAppsFromPrefs() { |
279 if (!ConnectToShelfController()) | 279 if (!ConnectToShelfController()) |
280 return; | 280 return; |
281 | 281 |
282 std::vector<std::string> pinned_apps = ash::launcher::GetPinnedAppsFromPrefs( | 282 std::vector<ash::launcher::AppLauncherId> pinned_apps = |
283 profile()->GetPrefs(), launcher_controller_helper()); | 283 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), |
| 284 launcher_controller_helper()); |
284 | 285 |
285 for (const auto& app : pinned_apps) { | 286 for (const auto& app_launcher_id : pinned_apps) { |
286 if (app == ash::launcher::kPinnedAppsPlaceholder) | 287 const std::string app_launcher_id_str = app_launcher_id.ToString(); |
| 288 if (app_launcher_id_str == ash::launcher::kPinnedAppsPlaceholder) |
287 continue; | 289 continue; |
288 | 290 |
289 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); | 291 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); |
290 item->app_id = app; | 292 item->app_id = app_launcher_id_str; |
291 item->app_title = mojo::String::From( | 293 item->app_title = |
292 launcher_controller_helper()->GetAppTitle(profile(), app)); | 294 mojo::String::From(launcher_controller_helper()->GetAppTitle( |
| 295 profile(), app_launcher_id_str)); |
293 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 296 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
294 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); | 297 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); |
295 item->image = *image.ToSkBitmap(); | 298 item->image = *image.ToSkBitmap(); |
296 std::unique_ptr<ChromeShelfItemDelegate> delegate( | 299 std::unique_ptr<ChromeShelfItemDelegate> delegate( |
297 new ChromeShelfItemDelegate(app, this)); | 300 new ChromeShelfItemDelegate(app_launcher_id_str, this)); |
298 shelf_controller()->PinItem(std::move(item), | 301 shelf_controller()->PinItem(std::move(item), |
299 delegate->CreateInterfacePtrInfoAndBind( | 302 delegate->CreateInterfacePtrInfoAndBind( |
300 shelf_controller().associated_group())); | 303 shelf_controller().associated_group())); |
301 app_id_to_item_delegate_.insert(std::make_pair(app, std::move(delegate))); | 304 app_id_to_item_delegate_.insert( |
| 305 std::make_pair(app_launcher_id_str, std::move(delegate))); |
302 | 306 |
303 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app); | 307 AppIconLoader* app_icon_loader = |
| 308 GetAppIconLoaderForApp(app_launcher_id_str); |
304 if (app_icon_loader) { | 309 if (app_icon_loader) { |
305 app_icon_loader->FetchImage(app); | 310 app_icon_loader->FetchImage(app_launcher_id_str); |
306 app_icon_loader->UpdateImage(app); | 311 app_icon_loader->UpdateImage(app_launcher_id_str); |
307 } | 312 } |
308 } | 313 } |
309 } | 314 } |
OLD | NEW |