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

Unified Diff: chrome/browser/ui/ash/chrome_launcher_prefs.cc

Issue 2378353002: [Merge-M54] Fix crash on item drag in shelf. (Closed)
Patch Set: Created 4 years, 3 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/chrome_launcher_prefs.cc
diff --git a/chrome/browser/ui/ash/chrome_launcher_prefs.cc b/chrome/browser/ui/ash/chrome_launcher_prefs.cc
index 5d804d908a9b28bf586e494e8cef548af9d6a95a..c600e1eb486f4518d20632f454704c597f6ead62 100644
--- a/chrome/browser/ui/ash/chrome_launcher_prefs.cc
+++ b/chrome/browser/ui/ash/chrome_launcher_prefs.cc
@@ -666,12 +666,10 @@ void RemovePinPosition(Profile* profile, const std::string& app_id) {
void SetPinPosition(Profile* profile,
const std::string& app_id,
const std::string& app_id_before,
- const std::string& app_id_after) {
+ const std::vector<std::string>& app_ids_after) {
DCHECK(profile);
DCHECK(!app_id.empty());
DCHECK_NE(app_id, app_id_before);
- DCHECK_NE(app_id, app_id_after);
- DCHECK(app_id_before.empty() || app_id_before != app_id_after);
app_list::AppListSyncableService* app_service =
app_list::AppListSyncableServiceFactory::GetForProfile(profile);
@@ -682,9 +680,21 @@ void SetPinPosition(Profile* profile,
syncer::StringOrdinal position_before =
app_id_before.empty() ? syncer::StringOrdinal()
: app_service->GetPinPosition(app_id_before);
- syncer::StringOrdinal position_after =
- app_id_after.empty() ? syncer::StringOrdinal()
- : app_service->GetPinPosition(app_id_after);
+ syncer::StringOrdinal position_after;
+ for (const auto& app_id_after : app_ids_after) {
+ DCHECK_NE(app_id_after, app_id);
+ DCHECK_NE(app_id_after, app_id_before);
+ syncer::StringOrdinal position = app_service->GetPinPosition(app_id_after);
+ DCHECK(position.IsValid());
+ if (!position.IsValid()) {
+ LOG(ERROR) << "Sync pin position was not found for " << app_id_after;
+ continue;
+ }
+ if (!position_before.IsValid() || !position.Equals(position_before)) {
+ position_after = position;
+ break;
+ }
+ }
syncer::StringOrdinal pin_position;
if (position_before.IsValid() && position_after.IsValid())
« no previous file with comments | « chrome/browser/ui/ash/chrome_launcher_prefs.h ('k') | chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698