| 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 "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/browser/ui/ash/app_launcher_id.h" |
| 11 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 12 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 12 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 13 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
| 13 #include "extensions/grit/extensions_browser_resources.h" | 14 #include "extensions/grit/extensions_browser_resources.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/events/event_constants.h" | 16 #include "ui/events/event_constants.h" |
| 16 | 17 |
| 17 class ChromeShelfItemDelegate : public ash::mojom::ShelfItemDelegate { | 18 class ChromeShelfItemDelegate : public ash::mojom::ShelfItemDelegate { |
| 18 public: | 19 public: |
| 19 explicit ChromeShelfItemDelegate(const std::string& app_id, | 20 explicit ChromeShelfItemDelegate(const std::string& app_id, |
| 20 ChromeLauncherController* controller) | 21 ChromeLauncherController* controller) |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 void ChromeLauncherControllerMus::PinAppsFromPrefs() { | 275 void ChromeLauncherControllerMus::PinAppsFromPrefs() { |
| 275 if (!ConnectToShelfController()) | 276 if (!ConnectToShelfController()) |
| 276 return; | 277 return; |
| 277 | 278 |
| 278 std::vector<ash::launcher::AppLauncherId> pinned_apps = | 279 std::vector<ash::launcher::AppLauncherId> pinned_apps = |
| 279 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), | 280 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), |
| 280 launcher_controller_helper()); | 281 launcher_controller_helper()); |
| 281 | 282 |
| 282 for (const auto& app_launcher_id : pinned_apps) { | 283 for (const auto& app_launcher_id : pinned_apps) { |
| 283 const std::string app_id = app_launcher_id.app_id(); | 284 const std::string app_id = app_launcher_id.app_id(); |
| 284 if (app_launcher_id.ToString() == ash::launcher::kPinnedAppsPlaceholder) | 285 if (app_launcher_id.app_id() == ash::launcher::kPinnedAppsPlaceholder) |
| 285 continue; | 286 continue; |
| 286 | 287 |
| 287 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); | 288 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); |
| 288 item->app_id = app_id; | 289 item->app_id = app_id; |
| 289 item->app_title = base::UTF16ToUTF8( | 290 item->app_title = base::UTF16ToUTF8( |
| 290 launcher_controller_helper()->GetAppTitle(profile(), app_id)); | 291 launcher_controller_helper()->GetAppTitle(profile(), app_id)); |
| 291 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 292 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 292 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); | 293 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); |
| 293 item->image = *image.ToSkBitmap(); | 294 item->image = *image.ToSkBitmap(); |
| 294 std::unique_ptr<ChromeShelfItemDelegate> delegate( | 295 std::unique_ptr<ChromeShelfItemDelegate> delegate( |
| 295 new ChromeShelfItemDelegate(app_id, this)); | 296 new ChromeShelfItemDelegate(app_id, this)); |
| 296 shelf_controller()->PinItem(std::move(item), | 297 shelf_controller()->PinItem(std::move(item), |
| 297 delegate->CreateInterfacePtrInfoAndBind( | 298 delegate->CreateInterfacePtrInfoAndBind( |
| 298 shelf_controller().associated_group())); | 299 shelf_controller().associated_group())); |
| 299 app_id_to_item_delegate_.insert( | 300 app_id_to_item_delegate_.insert( |
| 300 std::make_pair(app_id, std::move(delegate))); | 301 std::make_pair(app_id, std::move(delegate))); |
| 301 | 302 |
| 302 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); | 303 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); |
| 303 if (app_icon_loader) { | 304 if (app_icon_loader) { |
| 304 app_icon_loader->FetchImage(app_id); | 305 app_icon_loader->FetchImage(app_id); |
| 305 app_icon_loader->UpdateImage(app_id); | 306 app_icon_loader->UpdateImage(app_id); |
| 306 } | 307 } |
| 307 } | 308 } |
| 308 } | 309 } |
| OLD | NEW |