| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 void ChromeLauncherControllerMus::PinAppsFromPrefs() { | 273 void ChromeLauncherControllerMus::PinAppsFromPrefs() { |
| 273 if (!ConnectToShelfController()) | 274 if (!ConnectToShelfController()) |
| 274 return; | 275 return; |
| 275 | 276 |
| 276 std::vector<ash::launcher::AppLauncherId> pinned_apps = | 277 std::vector<ash::launcher::AppLauncherId> pinned_apps = |
| 277 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), | 278 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), |
| 278 launcher_controller_helper()); | 279 launcher_controller_helper()); |
| 279 | 280 |
| 280 for (const auto& app_launcher_id : pinned_apps) { | 281 for (const auto& app_launcher_id : pinned_apps) { |
| 281 const std::string app_id = app_launcher_id.app_id(); | 282 const std::string app_id = app_launcher_id.app_id(); |
| 282 if (app_launcher_id.ToString() == ash::launcher::kPinnedAppsPlaceholder) | 283 if (app_launcher_id.app_id() == ash::launcher::kPinnedAppsPlaceholder) |
| 283 continue; | 284 continue; |
| 284 | 285 |
| 285 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); | 286 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); |
| 286 item->app_id = app_id; | 287 item->app_id = app_id; |
| 287 item->app_title = base::UTF16ToUTF8( | 288 item->app_title = base::UTF16ToUTF8( |
| 288 launcher_controller_helper()->GetAppTitle(profile(), app_id)); | 289 launcher_controller_helper()->GetAppTitle(profile(), app_id)); |
| 289 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 290 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 290 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); | 291 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); |
| 291 item->image = *image.ToSkBitmap(); | 292 item->image = *image.ToSkBitmap(); |
| 292 std::unique_ptr<ChromeShelfItemDelegate> delegate( | 293 std::unique_ptr<ChromeShelfItemDelegate> delegate( |
| 293 new ChromeShelfItemDelegate(app_id, this)); | 294 new ChromeShelfItemDelegate(app_id, this)); |
| 294 shelf_controller()->PinItem(std::move(item), | 295 shelf_controller()->PinItem(std::move(item), |
| 295 delegate->CreateInterfacePtrInfoAndBind( | 296 delegate->CreateInterfacePtrInfoAndBind( |
| 296 shelf_controller().associated_group())); | 297 shelf_controller().associated_group())); |
| 297 app_id_to_item_delegate_.insert( | 298 app_id_to_item_delegate_.insert( |
| 298 std::make_pair(app_id, std::move(delegate))); | 299 std::make_pair(app_id, std::move(delegate))); |
| 299 | 300 |
| 300 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); | 301 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); |
| 301 if (app_icon_loader) { | 302 if (app_icon_loader) { |
| 302 app_icon_loader->FetchImage(app_id); | 303 app_icon_loader->FetchImage(app_id); |
| 303 app_icon_loader->UpdateImage(app_id); | 304 app_icon_loader->UpdateImage(app_id); |
| 304 } | 305 } |
| 305 } | 306 } |
| 306 } | 307 } |
| OLD | NEW |