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

Side by Side Diff: chrome/browser/ui/app_list/chrome_app_list_item.cc

Issue 2614803002: Prevent appearing INVALID position ordinal in sync. (Closed)
Patch Set: update_unit_tests Created 3 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/app_list/chrome_app_list_item.h" 5 #include "chrome/browser/ui/app_list/chrome_app_list_item.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/app_list/app_list_service.h" 8 #include "chrome/browser/ui/app_list/app_list_service.h"
9 #include "extensions/browser/app_sorting.h" 9 #include "extensions/browser/app_sorting.h"
10 #include "extensions/browser/extension_system.h" 10 #include "extensions/browser/extension_system.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // An existing synced position exists, use that. 55 // An existing synced position exists, use that.
56 set_position(sync_item->item_ordinal); 56 set_position(sync_item->item_ordinal);
57 // Only set the name from the sync item if it is empty. 57 // Only set the name from the sync item if it is empty.
58 if (name().empty()) 58 if (name().empty())
59 SetName(sync_item->item_name); 59 SetName(sync_item->item_name);
60 } 60 }
61 61
62 void ChromeAppListItem::SetDefaultPositionIfApplicable() { 62 void ChromeAppListItem::SetDefaultPositionIfApplicable() {
63 syncer::StringOrdinal page_ordinal; 63 syncer::StringOrdinal page_ordinal;
64 syncer::StringOrdinal launch_ordinal; 64 syncer::StringOrdinal launch_ordinal;
65 if (GetAppSorting()->GetDefaultOrdinals(id(), &page_ordinal, 65 extensions::AppSorting* app_sorting = GetAppSorting();
66 &launch_ordinal) && 66 if (!app_sorting->GetDefaultOrdinals(id(), &page_ordinal,
67 page_ordinal.IsValid() && launch_ordinal.IsValid()) { 67 &launch_ordinal) ||
68 set_position(syncer::StringOrdinal(page_ordinal.ToInternalValue() + 68 !page_ordinal.IsValid() || !launch_ordinal.IsValid()) {
69 launch_ordinal.ToInternalValue())); 69 app_sorting->EnsureValidOrdinals(id(), syncer::StringOrdinal());
70 page_ordinal = app_sorting->GetPageOrdinal(id());
71 launch_ordinal = app_sorting->GetAppLaunchOrdinal(id());
70 } 72 }
73 DCHECK(page_ordinal.IsValid());
74 DCHECK(launch_ordinal.IsValid());
75 set_position(syncer::StringOrdinal(page_ordinal.ToInternalValue() +
76 launch_ordinal.ToInternalValue()));
71 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698