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/views/apps_grid_view.h" | 5 #include "ui/app_list/views/apps_grid_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1673 | 1673 |
1674 // Make change to data model. | 1674 // Make change to data model. |
1675 item_list_->RemoveObserver(this); | 1675 item_list_->RemoveObserver(this); |
1676 | 1676 |
1677 AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item(); | 1677 AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item(); |
1678 DCHECK(reparent_item->IsInFolder()); | 1678 DCHECK(reparent_item->IsInFolder()); |
1679 const std::string source_folder_id = reparent_item->folder_id(); | 1679 const std::string source_folder_id = reparent_item->folder_id(); |
1680 AppListFolderItem* source_folder = | 1680 AppListFolderItem* source_folder = |
1681 static_cast<AppListFolderItem*>(item_list_->FindItem(source_folder_id)); | 1681 static_cast<AppListFolderItem*>(item_list_->FindItem(source_folder_id)); |
1682 | 1682 |
1683 AppListItemView* target_view = | |
1684 static_cast<AppListItemView*>(GetViewAtSlotOnCurrentPage(target.slot)); | |
1685 if (!target_view) | |
1686 return; | |
tapted
2014/05/09 02:55:47
I think this will ~leak the observer removed up on
calamity
2014/05/09 03:13:02
Done.
| |
1687 | |
1683 // Remove the source folder view if there is only 1 item in it, since the | 1688 // Remove the source folder view if there is only 1 item in it, since the |
1684 // source folder will be deleted after its only child item merged into the | 1689 // source folder will be deleted after its only child item merged into the |
1685 // target item. | 1690 // target item. |
1686 if (source_folder->ChildItemCount() == 1u) | 1691 if (source_folder->ChildItemCount() == 1u) |
1687 DeleteItemViewAtIndex(view_model_.GetIndexOfView(activated_item_view())); | 1692 DeleteItemViewAtIndex(view_model_.GetIndexOfView(activated_item_view())); |
1688 | 1693 |
1689 AppListItemView* target_view = | |
1690 static_cast<AppListItemView*>(GetViewAtSlotOnCurrentPage(target.slot)); | |
1691 AppListItem* target_item = target_view->item(); | 1694 AppListItem* target_item = target_view->item(); |
1692 | 1695 |
1693 // Move item to the target folder. | 1696 // Move item to the target folder. |
1694 std::string target_id_after_merge = | 1697 std::string target_id_after_merge = |
1695 model_->MergeItems(target_item->id(), reparent_item->id()); | 1698 model_->MergeItems(target_item->id(), reparent_item->id()); |
1696 if (target_id_after_merge.empty()) { | 1699 if (target_id_after_merge.empty()) { |
1697 LOG(ERROR) << "Unable to reparent to item id: " << target_item->id(); | 1700 LOG(ERROR) << "Unable to reparent to item id: " << target_item->id(); |
1698 item_list_->AddObserver(this); | 1701 item_list_->AddObserver(this); |
1699 return; | 1702 return; |
1700 } | 1703 } |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2093 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 2096 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
2094 bool is_target_folder) { | 2097 bool is_target_folder) { |
2095 AppListItemView* target_view = | 2098 AppListItemView* target_view = |
2096 static_cast<AppListItemView*>( | 2099 static_cast<AppListItemView*>( |
2097 GetViewAtSlotOnCurrentPage(target_index.slot)); | 2100 GetViewAtSlotOnCurrentPage(target_index.slot)); |
2098 if (target_view) | 2101 if (target_view) |
2099 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 2102 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
2100 } | 2103 } |
2101 | 2104 |
2102 } // namespace app_list | 2105 } // namespace app_list |
OLD | NEW |