search_box_(new SearchBoxModel),
results_(new SearchResults),
status_(STATUS_NORMAL),
+ state_(INVALID_STATE),
folders_enabled_(false) {
top_level_item_list_->AddObserver(this);
}
OnAppListModelStatusChanged());
}
+void AppListModel::SetState(State state) {
+ if (state_ == state)
+ return;
+
+ State old_state = state_;
+
+ state_ = state;
+
+ FOR_EACH_OBSERVER(AppListModelObserver,
+ observers_,
+ OnAppListModelStateChanged(old_state, state_));
+}
+
AppListItem* AppListModel::FindItem(const std::string& id) {
AppListItem* item = top_level_item_list_->FindItem(id);
if (item)
return "";
}
DVLOG(2) << "MergeItems: " << source_item_id << " -> " << target_item_id;
+
+ if (target_item_id == source_item_id) {
+ LOG(WARNING) << "MergeItems tried to drop item onto itself ("
+ << source_item_id << " -> " << target_item_id << ").";
+ return "";
+ }
+
// Find the target item.
- AppListItem* target_item = FindItem(target_item_id);
+ AppListItem* target_item = top_level_item_list_->FindItem(target_item_id);
if (!target_item) {
LOG(ERROR) << "MergeItems: Target no longer exists.";
return "";
}
- CHECK(target_item->folder_id().empty());
AppListItem* source_item = FindItem(source_item_id);
if (!source_item) {
// location, they will become owned by the new folder.
scoped_ptr<AppListItem> source_item_ptr = RemoveItem(source_item);
CHECK(source_item_ptr);
+ // Note: This would fail if |target_item_id == source_item_id|, except we
+ // checked that they are distinct at the top of this method.
scoped_ptr<AppListItem> target_item_ptr =
top_level_item_list_->RemoveItem(target_item_id);
CHECK(target_item_ptr);
new AppListFolderItem(folder_id, AppListFolderItem::FOLDER_TYPE_NORMAL));
new_folder->set_position(
top_level_item_list_->CreatePositionBefore(syncer::StringOrdinal()));
- AppListItem* new_folder_item =
- AddItemToItemListAndNotify(new_folder.PassAs<AppListItem>());
+ AppListItem* new_folder_item = AddItemToItemListAndNotify(new_folder.Pass());
return static_cast<AppListFolderItem*>(new_folder_item);
}