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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 if (!folders_enabled()) { | 332 if (!folders_enabled()) { |
333 LOG(ERROR) << "Attempt to create folder item when disabled: " << folder_id; | 333 LOG(ERROR) << "Attempt to create folder item when disabled: " << folder_id; |
334 return NULL; | 334 return NULL; |
335 } | 335 } |
336 | 336 |
337 DVLOG(2) << "Creating new folder: " << folder_id; | 337 DVLOG(2) << "Creating new folder: " << folder_id; |
338 scoped_ptr<AppListFolderItem> new_folder( | 338 scoped_ptr<AppListFolderItem> new_folder( |
339 new AppListFolderItem(folder_id, AppListFolderItem::FOLDER_TYPE_NORMAL)); | 339 new AppListFolderItem(folder_id, AppListFolderItem::FOLDER_TYPE_NORMAL)); |
340 new_folder->set_position( | 340 new_folder->set_position( |
341 top_level_item_list_->CreatePositionBefore(syncer::StringOrdinal())); | 341 top_level_item_list_->CreatePositionBefore(syncer::StringOrdinal())); |
342 AppListItem* new_folder_item = | 342 AppListItem* new_folder_item = AddItemToItemListAndNotify(new_folder.Pass()); |
343 AddItemToItemListAndNotify(new_folder.PassAs<AppListItem>()); | |
344 return static_cast<AppListFolderItem*>(new_folder_item); | 343 return static_cast<AppListFolderItem*>(new_folder_item); |
345 } | 344 } |
346 | 345 |
347 AppListItem* AppListModel::AddItemToItemListAndNotify( | 346 AppListItem* AppListModel::AddItemToItemListAndNotify( |
348 scoped_ptr<AppListItem> item_ptr) { | 347 scoped_ptr<AppListItem> item_ptr) { |
349 DCHECK(!item_ptr->IsInFolder()); | 348 DCHECK(!item_ptr->IsInFolder()); |
350 AppListItem* item = top_level_item_list_->AddItem(item_ptr.Pass()); | 349 AppListItem* item = top_level_item_list_->AddItem(item_ptr.Pass()); |
351 FOR_EACH_OBSERVER(AppListModelObserver, | 350 FOR_EACH_OBSERVER(AppListModelObserver, |
352 observers_, | 351 observers_, |
353 OnAppListItemAdded(item)); | 352 OnAppListItemAdded(item)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 scoped_ptr<AppListItem> result = folder->item_list()->RemoveItem(item->id()); | 391 scoped_ptr<AppListItem> result = folder->item_list()->RemoveItem(item->id()); |
393 result->set_folder_id(""); | 392 result->set_folder_id(""); |
394 if (folder->item_list()->item_count() == 0) { | 393 if (folder->item_list()->item_count() == 0) { |
395 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); | 394 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); |
396 DeleteItem(folder_id); | 395 DeleteItem(folder_id); |
397 } | 396 } |
398 return result.Pass(); | 397 return result.Pass(); |
399 } | 398 } |
400 | 399 |
401 } // namespace app_list | 400 } // namespace app_list |
OLD | NEW |