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

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

Issue 2684853002: Discard pinning an app with non-empty launcher id. (Closed)
Patch Set: Created 3 years, 10 months 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
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 "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"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (ConnectToShelfController()) 266 if (ConnectToShelfController())
267 shelf_controller()->SetItemImage(app_id, *image.bitmap()); 267 shelf_controller()->SetItemImage(app_id, *image.bitmap());
268 } 268 }
269 269
270 void ChromeLauncherControllerMus::OnInit() {} 270 void ChromeLauncherControllerMus::OnInit() {}
271 271
272 void ChromeLauncherControllerMus::PinAppsFromPrefs() { 272 void ChromeLauncherControllerMus::PinAppsFromPrefs() {
273 if (!ConnectToShelfController()) 273 if (!ConnectToShelfController())
274 return; 274 return;
275 275
276 std::vector<ash::launcher::AppLauncherId> pinned_apps = 276 std::vector<std::string> pinned_apps = ash::launcher::GetPinnedAppsFromPrefs(
277 ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), 277 profile()->GetPrefs(), launcher_controller_helper());
278 launcher_controller_helper());
279 278
280 for (const auto& app_launcher_id : pinned_apps) { 279 for (const auto& app_id : pinned_apps) {
281 const std::string app_id = app_launcher_id.app_id(); 280 if (app_id == ash::launcher::kPinnedAppsPlaceholder)
282 if (app_launcher_id.ToString() == ash::launcher::kPinnedAppsPlaceholder)
283 continue; 281 continue;
284 282
285 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); 283 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New());
286 item->app_id = app_id; 284 item->app_id = app_id;
287 item->app_title = base::UTF16ToUTF8( 285 item->app_title = base::UTF16ToUTF8(
288 launcher_controller_helper()->GetAppTitle(profile(), app_id)); 286 launcher_controller_helper()->GetAppTitle(profile(), app_id));
289 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 287 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
290 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); 288 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON);
291 item->image = *image.ToSkBitmap(); 289 item->image = *image.ToSkBitmap();
292 std::unique_ptr<ChromeShelfItemDelegate> delegate( 290 std::unique_ptr<ChromeShelfItemDelegate> delegate(
293 new ChromeShelfItemDelegate(app_id, this)); 291 new ChromeShelfItemDelegate(app_id, this));
294 shelf_controller()->PinItem(std::move(item), 292 shelf_controller()->PinItem(std::move(item),
295 delegate->CreateInterfacePtrInfoAndBind( 293 delegate->CreateInterfacePtrInfoAndBind(
296 shelf_controller().associated_group())); 294 shelf_controller().associated_group()));
297 app_id_to_item_delegate_.insert( 295 app_id_to_item_delegate_.insert(
298 std::make_pair(app_id, std::move(delegate))); 296 std::make_pair(app_id, std::move(delegate)));
299 297
300 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 298 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
301 if (app_icon_loader) { 299 if (app_icon_loader) {
302 app_icon_loader->FetchImage(app_id); 300 app_icon_loader->FetchImage(app_id);
303 app_icon_loader->UpdateImage(app_id); 301 app_icon_loader->UpdateImage(app_id);
304 } 302 }
305 } 303 }
306 } 304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698