Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.cc

Issue 2341643002: Enhance chrome.app.window API for shelf integration with pinning support (cont.) (Closed)
Patch Set: Unit Test Fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 10 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
10 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 11 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
11 #include "extensions/grit/extensions_browser_resources.h" 12 #include "extensions/grit/extensions_browser_resources.h"
12 #include "mojo/common/common_type_converters.h" 13 #include "mojo/common/common_type_converters.h"
13 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
14 15
15 class ChromeShelfItemDelegate : public ash::mojom::ShelfItemDelegate { 16 class ChromeShelfItemDelegate : public ash::mojom::ShelfItemDelegate {
16 public: 17 public:
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 void ChromeLauncherControllerMus::OnUserProfileReadyToSwitch(Profile* profile) { 262 void ChromeLauncherControllerMus::OnUserProfileReadyToSwitch(Profile* profile) {
262 NOTIMPLEMENTED(); 263 NOTIMPLEMENTED();
263 } 264 }
264 265
265 ArcAppDeferredLauncherController* 266 ArcAppDeferredLauncherController*
266 ChromeLauncherControllerMus::GetArcDeferredLauncher() { 267 ChromeLauncherControllerMus::GetArcDeferredLauncher() {
267 NOTIMPLEMENTED(); 268 NOTIMPLEMENTED();
268 return nullptr; 269 return nullptr;
269 } 270 }
270 271
272 const std::string& ChromeLauncherControllerMus::GetLaunchIDForShelfID(
273 ash::ShelfID id) {
274 NOTIMPLEMENTED();
275 return base::EmptyString();
276 }
277
271 void ChromeLauncherControllerMus::OnAppImageUpdated( 278 void ChromeLauncherControllerMus::OnAppImageUpdated(
272 const std::string& app_id, 279 const std::string& app_id,
273 const gfx::ImageSkia& image) { 280 const gfx::ImageSkia& image) {
274 if (ConnectToShelfController()) 281 if (ConnectToShelfController())
275 shelf_controller()->SetItemImage(app_id, *image.bitmap()); 282 shelf_controller()->SetItemImage(app_id, *image.bitmap());
276 } 283 }
277 284
278 void ChromeLauncherControllerMus::PinAppsFromPrefs() { 285 void ChromeLauncherControllerMus::PinAppsFromPrefs() {
279 if (!ConnectToShelfController()) 286 if (!ConnectToShelfController())
280 return; 287 return;
281 288
282 std::vector<ash::launcher::AppLauncherId> pinned_apps = 289 std::vector<ash::launcher::AppLauncherId> pinned_apps =
283 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), 290 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(),
284 launcher_controller_helper()); 291 launcher_controller_helper());
285 292
286 for (const auto& app_launcher_id : pinned_apps) { 293 for (const auto& app_launcher_id : pinned_apps) {
287 const std::string app_launcher_id_str = app_launcher_id.ToString(); 294 const std::string app_id = app_launcher_id.app_id();
288 if (app_launcher_id_str == ash::launcher::kPinnedAppsPlaceholder) 295 if (app_launcher_id.ToString() == ash::launcher::kPinnedAppsPlaceholder)
289 continue; 296 continue;
290 297
291 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); 298 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New());
292 item->app_id = app_launcher_id_str; 299 item->app_id = app_id;
293 item->app_title = 300 item->app_title = mojo::String::From(
294 mojo::String::From(launcher_controller_helper()->GetAppTitle( 301 launcher_controller_helper()->GetAppTitle(profile(), app_id));
295 profile(), app_launcher_id_str));
296 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 302 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
297 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); 303 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON);
298 item->image = *image.ToSkBitmap(); 304 item->image = *image.ToSkBitmap();
299 std::unique_ptr<ChromeShelfItemDelegate> delegate( 305 std::unique_ptr<ChromeShelfItemDelegate> delegate(
300 new ChromeShelfItemDelegate(app_launcher_id_str, this)); 306 new ChromeShelfItemDelegate(app_id, this));
301 shelf_controller()->PinItem(std::move(item), 307 shelf_controller()->PinItem(std::move(item),
302 delegate->CreateInterfacePtrInfoAndBind( 308 delegate->CreateInterfacePtrInfoAndBind(
303 shelf_controller().associated_group())); 309 shelf_controller().associated_group()));
304 app_id_to_item_delegate_.insert( 310 app_id_to_item_delegate_.insert(
305 std::make_pair(app_launcher_id_str, std::move(delegate))); 311 std::make_pair(app_id, std::move(delegate)));
306 312
307 AppIconLoader* app_icon_loader = 313 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
308 GetAppIconLoaderForApp(app_launcher_id_str);
309 if (app_icon_loader) { 314 if (app_icon_loader) {
310 app_icon_loader->FetchImage(app_launcher_id_str); 315 app_icon_loader->FetchImage(app_id);
311 app_icon_loader->UpdateImage(app_launcher_id_str); 316 app_icon_loader->UpdateImage(app_id);
312 } 317 }
313 } 318 }
314 } 319 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698