Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_model.h" | 5 #include "ui/app_list/app_list_model.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ui/app_list/app_list_folder_item.h" | 9 #include "ui/app_list/app_list_folder_item.h" |
| 10 #include "ui/app_list/app_list_item.h" | 10 #include "ui/app_list/app_list_item.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 DCHECK(folder) << "Folder not found for item: " << item->ToDebugString(); | 273 DCHECK(folder) << "Folder not found for item: " << item->ToDebugString(); |
| 274 scoped_ptr<AppListItem> child_item = RemoveItemFromFolder(folder, item); | 274 scoped_ptr<AppListItem> child_item = RemoveItemFromFolder(folder, item); |
| 275 DCHECK_EQ(item, child_item.get()); | 275 DCHECK_EQ(item, child_item.get()); |
| 276 FOR_EACH_OBSERVER(AppListModelObserver, | 276 FOR_EACH_OBSERVER(AppListModelObserver, |
| 277 observers_, | 277 observers_, |
| 278 OnAppListItemWillBeDeleted(item)); | 278 OnAppListItemWillBeDeleted(item)); |
| 279 child_item.reset(); // Deletes item. | 279 child_item.reset(); // Deletes item. |
| 280 FOR_EACH_OBSERVER(AppListModelObserver, observers_, OnAppListItemDeleted()); | 280 FOR_EACH_OBSERVER(AppListModelObserver, observers_, OnAppListItemDeleted()); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void AppListModel::DeleteUninstalledItem(const std::string& id) { | |
| 284 AppListItem* item = FindItem(id); | |
| 285 if (!item) | |
| 286 return; | |
| 287 const std::string folder_id = item->folder_id(); | |
| 288 DeleteItem(id); | |
| 289 | |
| 290 // Issue 368111: Upon uninstall of 2nd-to-last folder item, reparent last item | |
|
stevenjb
2015/03/30 17:23:59
nit: crbug.com/368111:
Greg Levin
2015/03/30 23:08:52
Done.
| |
| 291 // to top and remove folder. | |
| 292 AppListFolderItem* folder = FindFolderItem(folder_id); | |
| 293 if (folder && folder->ChildItemCount() == 1u) { | |
| 294 FOR_EACH_OBSERVER(AppListModelObserver, observers_, | |
| 295 OnSingleItemFolderWillBeDeleted(folder_id)); | |
|
stevenjb
2015/03/30 17:23:59
In DeleteItem() we call OnAppListItemWillBeDeleted
Greg Levin
2015/03/30 23:08:52
Done. Thanks for pointing this out. It turns out
| |
| 296 | |
| 297 // Move last item in model, folder and views will update themselves. | |
| 298 AppListItem* last_item = folder->item_list()->item_at(0); | |
| 299 MoveItemToFolderAt(last_item, "", folder->position()); | |
| 300 } | |
| 301 } | |
| 302 | |
| 283 void AppListModel::NotifyExtensionPreferenceChanged() { | 303 void AppListModel::NotifyExtensionPreferenceChanged() { |
| 284 for (size_t i = 0; i < top_level_item_list_->item_count(); ++i) | 304 for (size_t i = 0; i < top_level_item_list_->item_count(); ++i) |
| 285 top_level_item_list_->item_at(i)->OnExtensionPreferenceChanged(); | 305 top_level_item_list_->item_at(i)->OnExtensionPreferenceChanged(); |
| 286 } | 306 } |
| 287 | 307 |
| 288 void AppListModel::SetFoldersEnabled(bool folders_enabled) { | 308 void AppListModel::SetFoldersEnabled(bool folders_enabled) { |
| 289 folders_enabled_ = folders_enabled; | 309 folders_enabled_ = folders_enabled; |
| 290 if (folders_enabled) | 310 if (folders_enabled) |
| 291 return; | 311 return; |
| 292 // Remove child items from folders. | 312 // Remove child items from folders. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 scoped_ptr<AppListItem> result = folder->item_list()->RemoveItem(item->id()); | 455 scoped_ptr<AppListItem> result = folder->item_list()->RemoveItem(item->id()); |
| 436 result->set_folder_id(""); | 456 result->set_folder_id(""); |
| 437 if (folder->item_list()->item_count() == 0) { | 457 if (folder->item_list()->item_count() == 0) { |
| 438 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); | 458 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); |
| 439 DeleteItem(folder_id); | 459 DeleteItem(folder_id); |
| 440 } | 460 } |
| 441 return result.Pass(); | 461 return result.Pass(); |
| 442 } | 462 } |
| 443 | 463 |
| 444 } // namespace app_list | 464 } // namespace app_list |
| OLD | NEW |