| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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<ash::launcher::AppLauncherId> pinned_apps = | 282 std::vector<ash::launcher::AppLauncherId> pinned_apps = |
| 283 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), | 283 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), |
| 284 launcher_controller_helper()); | 284 launcher_controller_helper()); |
| 285 | 285 |
| 286 for (const auto& app_launcher_id : pinned_apps) { | 286 for (const auto& app_launcher_id : pinned_apps) { |
| 287 const std::string app_launcher_id_str = app_launcher_id.ToString(); | 287 const std::string app_id = app_launcher_id.app_id(); |
| 288 if (app_launcher_id_str == ash::launcher::kPinnedAppsPlaceholder) | 288 if (app_launcher_id.ToString() == ash::launcher::kPinnedAppsPlaceholder) |
| 289 continue; | 289 continue; |
| 290 | 290 |
| 291 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); | 291 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); |
| 292 item->app_id = app_launcher_id_str; | 292 item->app_id = app_id; |
| 293 item->app_title = | 293 item->app_title = mojo::String::From( |
| 294 mojo::String::From(launcher_controller_helper()->GetAppTitle( | 294 launcher_controller_helper()->GetAppTitle(profile(), app_id)); |
| 295 profile(), app_launcher_id_str)); | |
| 296 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 295 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 297 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); | 296 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); |
| 298 item->image = *image.ToSkBitmap(); | 297 item->image = *image.ToSkBitmap(); |
| 299 std::unique_ptr<ChromeShelfItemDelegate> delegate( | 298 std::unique_ptr<ChromeShelfItemDelegate> delegate( |
| 300 new ChromeShelfItemDelegate(app_launcher_id_str, this)); | 299 new ChromeShelfItemDelegate(app_id, this)); |
| 301 shelf_controller()->PinItem(std::move(item), | 300 shelf_controller()->PinItem(std::move(item), |
| 302 delegate->CreateInterfacePtrInfoAndBind( | 301 delegate->CreateInterfacePtrInfoAndBind( |
| 303 shelf_controller().associated_group())); | 302 shelf_controller().associated_group())); |
| 304 app_id_to_item_delegate_.insert( | 303 app_id_to_item_delegate_.insert( |
| 305 std::make_pair(app_launcher_id_str, std::move(delegate))); | 304 std::make_pair(app_id, std::move(delegate))); |
| 306 | 305 |
| 307 AppIconLoader* app_icon_loader = | 306 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); |
| 308 GetAppIconLoaderForApp(app_launcher_id_str); | |
| 309 if (app_icon_loader) { | 307 if (app_icon_loader) { |
| 310 app_icon_loader->FetchImage(app_launcher_id_str); | 308 app_icon_loader->FetchImage(app_id); |
| 311 app_icon_loader->UpdateImage(app_launcher_id_str); | 309 app_icon_loader->UpdateImage(app_id); |
| 312 } | 310 } |
| 313 } | 311 } |
| 314 } | 312 } |
| OLD | NEW |