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

Side by Side Diff: ui/app_list/views/apps_grid_view.cc

Issue 271753007: Fix crash in ReparentItemToAnotherFolder() on Windows app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 6 years, 7 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 | « no previous file | no next file » | 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/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 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 1664
1665 item_list_->AddObserver(this); 1665 item_list_->AddObserver(this);
1666 model_->AddObserver(this); 1666 model_->AddObserver(this);
1667 UpdatePaging(); 1667 UpdatePaging();
1668 } 1668 }
1669 1669
1670 void AppsGridView::ReparentItemToAnotherFolder(views::View* item_view, 1670 void AppsGridView::ReparentItemToAnotherFolder(views::View* item_view,
1671 const Index& target) { 1671 const Index& target) {
1672 DCHECK(IsDraggingForReparentInRootLevelGridView()); 1672 DCHECK(IsDraggingForReparentInRootLevelGridView());
1673 1673
1674 AppListItemView* target_view =
1675 static_cast<AppListItemView*>(GetViewAtSlotOnCurrentPage(target.slot));
1676 if (!target_view)
1677 return;
1678
1674 // Make change to data model. 1679 // Make change to data model.
1675 item_list_->RemoveObserver(this); 1680 item_list_->RemoveObserver(this);
1676 1681
1677 AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item(); 1682 AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item();
1678 DCHECK(reparent_item->IsInFolder()); 1683 DCHECK(reparent_item->IsInFolder());
1679 const std::string source_folder_id = reparent_item->folder_id(); 1684 const std::string source_folder_id = reparent_item->folder_id();
1680 AppListFolderItem* source_folder = 1685 AppListFolderItem* source_folder =
1681 static_cast<AppListFolderItem*>(item_list_->FindItem(source_folder_id)); 1686 static_cast<AppListFolderItem*>(item_list_->FindItem(source_folder_id));
1682 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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698