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 "ash/public/cpp/app_launch_id.h" |
7 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/browser/ui/ash/app_launcher_id.h" | |
11 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 11 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
12 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 12 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
13 #include "extensions/grit/extensions_browser_resources.h" | 13 #include "extensions/grit/extensions_browser_resources.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
16 | 16 |
17 ChromeLauncherControllerMus::ChromeLauncherControllerMus() { | 17 ChromeLauncherControllerMus::ChromeLauncherControllerMus() { |
18 AttachProfile(ProfileManager::GetActiveUserProfile()); | 18 AttachProfile(ProfileManager::GetActiveUserProfile()); |
19 } | 19 } |
20 | 20 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 if (ConnectToShelfController()) | 226 if (ConnectToShelfController()) |
227 shelf_controller()->SetItemImage(app_id, *image.bitmap()); | 227 shelf_controller()->SetItemImage(app_id, *image.bitmap()); |
228 } | 228 } |
229 | 229 |
230 void ChromeLauncherControllerMus::OnInit() {} | 230 void ChromeLauncherControllerMus::OnInit() {} |
231 | 231 |
232 void ChromeLauncherControllerMus::PinAppsFromPrefs() { | 232 void ChromeLauncherControllerMus::PinAppsFromPrefs() { |
233 if (!ConnectToShelfController()) | 233 if (!ConnectToShelfController()) |
234 return; | 234 return; |
235 | 235 |
236 std::vector<ash::AppLauncherId> pinned_apps = | 236 std::vector<ash::AppLaunchId> pinned_apps = |
237 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), | 237 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), |
238 launcher_controller_helper()); | 238 launcher_controller_helper()); |
239 | 239 |
240 for (const auto& app_launcher_id : pinned_apps) { | 240 for (const auto& app_launch_id : pinned_apps) { |
241 const std::string app_id = app_launcher_id.app_id(); | 241 const std::string app_id = app_launch_id.app_id(); |
242 if (app_launcher_id.app_id() == ash::launcher::kPinnedAppsPlaceholder) | 242 if (app_launch_id.app_id() == ash::launcher::kPinnedAppsPlaceholder) |
243 continue; | 243 continue; |
244 | 244 |
245 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); | 245 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); |
246 item->app_id = app_id; | 246 item->app_id = app_id; |
247 item->title = launcher_controller_helper()->GetAppTitle(profile(), app_id); | 247 item->title = launcher_controller_helper()->GetAppTitle(profile(), app_id); |
248 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 248 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
249 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); | 249 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); |
250 item->image = *image.ToSkBitmap(); | 250 item->image = *image.ToSkBitmap(); |
251 // TOOD(msw): Actually pin the item and install its delegate; this code is | 251 // TOOD(msw): Actually pin the item and install its delegate; this code is |
252 // unused at the moment. See http://crbug.com/647879 | 252 // unused at the moment. See http://crbug.com/647879 |
253 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); | 253 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); |
254 if (app_icon_loader) { | 254 if (app_icon_loader) { |
255 app_icon_loader->FetchImage(app_id); | 255 app_icon_loader->FetchImage(app_id); |
256 app_icon_loader->UpdateImage(app_id); | 256 app_icon_loader->UpdateImage(app_id); |
257 } | 257 } |
258 } | 258 } |
259 } | 259 } |
OLD | NEW |