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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc

Issue 2352353002: Add AppLauncherId wrapper for items shown in shelf (Closed)
Patch Set: Rebase Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
index 2fa220bf94e35a121b0e48cd4173e5165a96a90a..55b72a202fc0cc42a1a361392ad8d486971b0ef3 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
@@ -375,8 +375,10 @@ void ChromeLauncherControllerImpl::UnpinAndUpdatePrefs(ash::ShelfID id,
LauncherItemController* controller = GetLauncherItemController(id);
CHECK(controller);
- if (update_prefs)
- ash::launcher::RemovePinPosition(profile(), GetAppIDForShelfID(id));
+ if (update_prefs) {
+ ash::launcher::RemovePinPosition(
+ profile(), ash::launcher::AppLauncherId(GetAppIDForShelfID(id)));
+ }
if (controller->type() == LauncherItemController::TYPE_APP ||
controller->locked()) {
@@ -1157,7 +1159,7 @@ void ChromeLauncherControllerImpl::SyncPinPosition(ash::ShelfID shelf_id) {
DCHECK(!app_id.empty());
std::string app_id_before;
- std::vector<std::string> app_ids_after;
+ std::vector<ash::launcher::AppLauncherId> app_launcher_ids_after;
for (int i = index - 1; i > 0; --i) {
const ash::ShelfID shelf_id_before = model_->items()[i].id;
@@ -1173,12 +1175,14 @@ void ChromeLauncherControllerImpl::SyncPinPosition(ash::ShelfID shelf_id) {
if (IsPinned(shelf_id_after)) {
const std::string app_id_after = GetAppIDForShelfID(shelf_id_after);
DCHECK(!app_id_after.empty());
- app_ids_after.push_back(app_id_after);
+ app_launcher_ids_after.push_back(
+ ash::launcher::AppLauncherId(app_id_after));
}
}
- ash::launcher::SetPinPosition(profile(), app_id, app_id_before,
- app_ids_after);
+ ash::launcher::SetPinPosition(profile(), ash::launcher::AppLauncherId(app_id),
+ ash::launcher::AppLauncherId(app_id_before),
+ app_launcher_ids_after);
}
void ChromeLauncherControllerImpl::OnSyncModelUpdated() {
@@ -1201,7 +1205,7 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() {
// into the pref state. Therefore we tell |persistPinnedState| to ignore any
// invocations while we are running.
base::AutoReset<bool> auto_reset(&ignore_persist_pinned_state_change_, true);
- const std::vector<std::string> pinned_apps =
+ const std::vector<ash::launcher::AppLauncherId> pinned_apps =
ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(),
launcher_controller_helper());
@@ -1213,16 +1217,17 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() {
// Apply pins in two steps. At the first step, go through the list of apps to
// pin, move existing pin to current position specified by |index| or create
// the new pin at that position.
- for (const auto& pref_app_id : pinned_apps) {
+ for (const auto& pref_app_launcher_id : pinned_apps) {
// Filter out apps that may be mapped wrongly.
// TODO(khmel): b/31703859 is to refactore shelf mapping.
+ const std::string launcher_id = pref_app_launcher_id.ToString();
stevenjb 2016/10/13 17:59:15 nit: app_launcher_id_str
Andra Paraschiv 2016/10/14 12:09:17 Done.
const std::string shelf_app_id =
- ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(pref_app_id);
- if (shelf_app_id != pref_app_id)
+ ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(launcher_id);
+ if (shelf_app_id != launcher_id)
continue;
// Update apps icon if applicable.
- OnAppUpdated(profile(), pref_app_id);
+ OnAppUpdated(profile(), launcher_id);
// Find existing pin or app from the right of current |index|.
int app_index = index;
@@ -1231,7 +1236,7 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() {
const IDToItemControllerMap::iterator it =
id_to_item_controller_map_.find(item.id);
if (it != id_to_item_controller_map_.end() &&
- it->second->app_id() == pref_app_id) {
+ it->second->app_id() == launcher_id) {
break;
}
}
@@ -1248,8 +1253,8 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() {
DCHECK_EQ(model_->ItemIndexByID(item.id), index);
} else {
// This is fresh pin. Create new one.
- DCHECK_NE(pref_app_id, extension_misc::kChromeAppId);
- CreateAppShortcutLauncherItem(pref_app_id, index);
+ DCHECK_NE(launcher_id, extension_misc::kChromeAppId);
+ CreateAppShortcutLauncherItem(launcher_id, index);
}
++index;
}

Powered by Google App Engine
This is Rietveld 408576698