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 c1a03b6d6860343dffd8de27b81f935cd33d711a..e2f972fe694d15cdca79bc05627a3f56f26283b3 100644 |
--- a/chrome/browser/ui/app_list/app_list_syncable_service.cc |
+++ b/chrome/browser/ui/app_list/app_list_syncable_service.cc |
@@ -305,7 +305,7 @@ void AppListSyncableService::AddItem(scoped_ptr<AppListItem> app_item) { |
std::string folder_id; |
if (app_list::switches::IsFolderUIEnabled()) { |
if (AppIsOem(app_item->id())) { |
- folder_id = FindOrCreateOemFolder(app_item->id()); |
+ folder_id = FindOrCreateOemFolder(); |
VLOG_IF(2, !folder_id.empty()) |
<< this << ": AddItem to OEM folder: " << sync_item->ToString(); |
} else { |
@@ -476,19 +476,13 @@ void AppListSyncableService::ResolveFolderPositions() { |
UpdateAppItemFromSyncItem(sync_item, app_item); |
} |
- // Create the OEM folder if necessary. |
- if (oem_folder_item_ids_.empty()) |
- return; |
- std::string oem_folder_id = FindOrCreateOemFolder(""); |
- DCHECK(!oem_folder_id.empty()); |
- for (std::vector<std::string>::iterator iter = oem_folder_item_ids_.begin(); |
- iter != oem_folder_item_ids_.end(); ++iter) { |
- AppListItem* app_item = model_->FindItem(*iter); |
- if (!app_item) |
- continue; |
- VLOG(2) << this << ": MoveItem to OEM folder: " |
- << app_item->ToDebugString(); |
- model_->MoveItemToFolder(app_item, oem_folder_id); |
+ // Move the OEM folder if one exists and we have not synced its position. |
+ AppListFolderItem* oem_folder = model_->FindFolderItem(kOemFolderId); |
+ if (oem_folder && !FindSyncItem(kOemFolderId)) { |
+ model_->SetItemPosition(oem_folder, GetOemFolderPos()); |
+ DVLOG(1) << "Creating new OEM folder sync item: " |
+ << oem_folder->position().ToDebugString(); |
+ CreateSyncItemFromAppItem(oem_folder); |
} |
} |
@@ -829,18 +823,9 @@ void AppListSyncableService::DeleteSyncItemSpecifics( |
model_->DeleteItem(item_id); |
} |
-std::string AppListSyncableService::FindOrCreateOemFolder( |
- const std::string& item_id) { |
+std::string AppListSyncableService::FindOrCreateOemFolder() { |
AppListFolderItem* oem_folder = model_->FindFolderItem(kOemFolderId); |
if (!oem_folder) { |
- if (!SyncStarted()) { |
- // We need sync to have started to know where to place the OEM folder. |
- // If sync is not started, add |item_id| (which should never be empty |
- // when called before sync is started) to oem_folder_item_ids_. |
- DCHECK(!item_id.empty()); |
- oem_folder_item_ids_.push_back(item_id); |
- return ""; |
- } |
scoped_ptr<AppListFolderItem> new_folder(new AppListFolderItem( |
kOemFolderId, AppListFolderItem::FOLDER_TYPE_OEM)); |
oem_folder = static_cast<AppListFolderItem*>( |
@@ -852,9 +837,8 @@ std::string AppListSyncableService::FindOrCreateOemFolder( |
model_->SetItemPosition(oem_folder, oem_sync_item->item_ordinal); |
} else { |
model_->SetItemPosition(oem_folder, GetOemFolderPos()); |
- DVLOG(1) << "Creating new OEM folder sync item: " |
- << oem_folder->position().ToDebugString(); |
- CreateSyncItemFromAppItem(oem_folder); |
+ // Do not create a sync item for the OEM folder here, do it in |
+ // ResolveFolderPositions() when the item position is finalized. |
} |
} |
model_->SetItemName(oem_folder, oem_folder_name_); |