Commit 2edc0017 authored by stevenjb@chromium.org's avatar stevenjb@chromium.org

Place OEM folder for new users after Web Store

It turns out that on some OEM devices the Files app is placed near the
end, so placing the OEM folder before the last non-removable app does
not have the desired result.

Instead, we place it after the WebStore, and assume that a pre-installed
app (e.g. Search) exists so that the app location is stable.

This was tested succesfully on an official build on one of the failing
devices. (I also confirmed that all of the existing defailt_app_order
files have the WebStore followed by Search early in the list).

BUG=chrome-os-partner:29764

Review URL: https://codereview.chromium.org/396843003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283722 0039d316-1c4b-4281-b951-d872f2087c98
parent bc141e92
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment