Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: ui/app_list/app_list_model.cc

Issue 1003393002: After uninstall, remove last item in Launcher folder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another round of revisions Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/app_list/app_list_model.h ('k') | ui/app_list/app_list_model_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/app_list/app_list_model.h ('k') | ui/app_list/app_list_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698