OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/app_list/app_list_item_list.h" | 5 #include "ui/app_list/app_list_item_list.h" |
6 | 6 |
7 #include "ui/app_list/app_list_item.h" | 7 #include "ui/app_list/app_list_item.h" |
8 | 8 |
9 namespace app_list { | 9 namespace app_list { |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 observers_, | 159 observers_, |
160 OnListItemAdded(index, item)); | 160 OnListItemAdded(index, item)); |
161 return item; | 161 return item; |
162 } | 162 } |
163 | 163 |
164 void AppListItemList::DeleteItem(const std::string& id) { | 164 void AppListItemList::DeleteItem(const std::string& id) { |
165 scoped_ptr<AppListItem> item = RemoveItem(id); | 165 scoped_ptr<AppListItem> item = RemoveItem(id); |
166 // |item| will be deleted on destruction. | 166 // |item| will be deleted on destruction. |
167 } | 167 } |
168 | 168 |
169 scoped_ptr<AppListItem> AppListItemList::RemoveItem( | 169 scoped_ptr<AppListItem> AppListItemList::RemoveItem(const std::string& id) { |
170 const std::string& id) { | |
171 size_t index; | 170 size_t index; |
172 if (FindItemIndex(id, &index)) | 171 if (!FindItemIndex(id, &index)) |
173 return RemoveItemAt(index); | 172 LOG(FATAL) << "RemoveItem: Not found: " << id; |
174 | 173 return RemoveItemAt(index); |
175 return scoped_ptr<AppListItem>(); | |
176 } | 174 } |
177 | 175 |
178 scoped_ptr<AppListItem> AppListItemList::RemoveItemAt(size_t index) { | 176 scoped_ptr<AppListItem> AppListItemList::RemoveItemAt(size_t index) { |
179 DCHECK_LT(index, item_count()); | 177 CHECK_LT(index, item_count()); |
180 AppListItem* item = app_list_items_[index]; | 178 AppListItem* item = app_list_items_[index]; |
181 app_list_items_.weak_erase(app_list_items_.begin() + index); | 179 app_list_items_.weak_erase(app_list_items_.begin() + index); |
182 FOR_EACH_OBSERVER(AppListItemListObserver, | 180 FOR_EACH_OBSERVER(AppListItemListObserver, |
183 observers_, | 181 observers_, |
184 OnListItemRemoved(index, item)); | 182 OnListItemRemoved(index, item)); |
185 return make_scoped_ptr<AppListItem>(item); | 183 return make_scoped_ptr<AppListItem>(item); |
186 } | 184 } |
187 | 185 |
188 void AppListItemList::DeleteItemAt(size_t index) { | 186 void AppListItemList::DeleteItemAt(size_t index) { |
189 scoped_ptr<AppListItem> item = RemoveItemAt(index); | 187 scoped_ptr<AppListItem> item = RemoveItemAt(index); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 else | 236 else |
239 cur->set_position(prev->position().CreateAfter()); | 237 cur->set_position(prev->position().CreateAfter()); |
240 prev = cur; | 238 prev = cur; |
241 } | 239 } |
242 FOR_EACH_OBSERVER(AppListItemListObserver, | 240 FOR_EACH_OBSERVER(AppListItemListObserver, |
243 observers_, | 241 observers_, |
244 OnListItemMoved(index, index, app_list_items_[index])); | 242 OnListItemMoved(index, index, app_list_items_[index])); |
245 } | 243 } |
246 | 244 |
247 } // namespace app_list | 245 } // namespace app_list |
OLD | NEW |