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

Unified Diff: chrome/browser/ui/app_list/app_list_syncable_service.cc

Issue 396843003: Place OEM folder for new users after Web Store (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/app_list_syncable_service.cc
diff --git a/chrome/browser/ui/app_list/app_list_syncable_service.cc b/chrome/browser/ui/app_list/app_list_syncable_service.cc
index c19585fdccb512e3cb80139c793f7c29fee9d0a2..2f0cddaef010e47808f3f79a8c9ae91ce68a3d63 100644
--- a/chrome/browser/ui/app_list/app_list_syncable_service.cc
+++ b/chrome/browser/ui/app_list/app_list_syncable_service.cc
@@ -875,30 +875,30 @@ syncer::StringOrdinal AppListSyncableService::GetOemFolderPos() {
return last.CreateAfter();
}
- // Place the OEM folder just before the last unremovable default item.
- // Since positions are relative, anywhere else is unstable. TODO(stevenjb):
- // consider explicitly setting the OEM folder location along with the name in
- // ServicesCustomizationDocument::SetOemFolderName().
+ // Place the OEM folder just after the web store, which should always be
+ // followed by a pre-installed app (e.g. Search), so the poosition should be
+ // stable. TODO(stevenjb): consider explicitly setting the OEM folder location
+ // along with the name in ServicesCustomizationDocument::SetOemFolderName().
AppListItemList* item_list = model_->top_level_item_list();
+ if (item_list->item_count() == 0)
+ return syncer::StringOrdinal();
+
size_t oem_index = 0;
- for (int i = static_cast<int>(item_list->item_count()) - 1; i >= 0; --i) {
- AppListItem* cur_item = item_list->item_at(i);
- const std::string& id = cur_item->id();
- if (IsUnRemovableDefaultApp(id)) {
- oem_index = i;
+ for (; oem_index < item_list->item_count() - 1; ++oem_index) {
+ AppListItem* cur_item = item_list->item_at(oem_index);
+ if (cur_item->id() == extension_misc::kWebStoreAppId)
break;
- }
}
syncer::StringOrdinal oem_ordinal;
- AppListItem* next = item_list->item_at(oem_index);
- if (oem_index > 0) {
- AppListItem* prev = item_list->item_at(oem_index - 1);
+ AppListItem* prev = item_list->item_at(oem_index);
+ if (oem_index + 1 < item_list->item_count()) {
+ AppListItem* next = item_list->item_at(oem_index + 1);
oem_ordinal = prev->position().CreateBetween(next->position());
} else {
- oem_ordinal = next->position().CreateBefore();
+ oem_ordinal = prev->position().CreateAfter();
}
- DVLOG(1) << "Placing OEM Folder at: " << oem_index
- << " position: " << oem_ordinal.ToDebugString();
+ VLOG(1) << "Placing OEM Folder at: " << oem_index
+ << " position: " << oem_ordinal.ToDebugString();
return oem_ordinal;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698