| 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 // crbug.com/368111: Upon uninstall of 2nd-to-last folder item, reparent last |
| 291 // item to top; this will remove the folder. |
| 292 AppListFolderItem* folder = FindFolderItem(folder_id); |
| 293 if (folder && folder->ChildItemCount() == 1u) { |
| 294 AppListItem* last_item = folder->item_list()->item_at(0); |
| 295 MoveItemToFolderAt(last_item, "", folder->position()); |
| 296 } |
| 297 } |
| 298 |
| 283 void AppListModel::NotifyExtensionPreferenceChanged() { | 299 void AppListModel::NotifyExtensionPreferenceChanged() { |
| 284 for (size_t i = 0; i < top_level_item_list_->item_count(); ++i) | 300 for (size_t i = 0; i < top_level_item_list_->item_count(); ++i) |
| 285 top_level_item_list_->item_at(i)->OnExtensionPreferenceChanged(); | 301 top_level_item_list_->item_at(i)->OnExtensionPreferenceChanged(); |
| 286 } | 302 } |
| 287 | 303 |
| 288 void AppListModel::SetFoldersEnabled(bool folders_enabled) { | 304 void AppListModel::SetFoldersEnabled(bool folders_enabled) { |
| 289 folders_enabled_ = folders_enabled; | 305 folders_enabled_ = folders_enabled; |
| 290 if (folders_enabled) | 306 if (folders_enabled) |
| 291 return; | 307 return; |
| 292 // Remove child items from folders. | 308 // 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()); | 451 scoped_ptr<AppListItem> result = folder->item_list()->RemoveItem(item->id()); |
| 436 result->set_folder_id(""); | 452 result->set_folder_id(""); |
| 437 if (folder->item_list()->item_count() == 0) { | 453 if (folder->item_list()->item_count() == 0) { |
| 438 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); | 454 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); |
| 439 DeleteItem(folder_id); | 455 DeleteItem(folder_id); |
| 440 } | 456 } |
| 441 return result.Pass(); | 457 return result.Pass(); |
| 442 } | 458 } |
| 443 | 459 |
| 444 } // namespace app_list | 460 } // namespace app_list |
| OLD | NEW |