Commit fd8b77bc authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Fixed missing calls to set the button pressed callback.

Bug: 772945
Change-Id: Idb01c79d10872f91aa83c915e16034e727d70d30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2466387
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Auto-Submit: Allen Bauer <kylixrd@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816255}
parent 5e59294f
...@@ -306,11 +306,6 @@ class AppListItemView::IconImageView : public views::ImageView { ...@@ -306,11 +306,6 @@ class AppListItemView::IconImageView : public views::ImageView {
// static // static
const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView"; const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView";
AppListItemView::AppListItemView(AppsGridView* apps_grid_view,
AppListItem* item,
AppListViewDelegate* delegate)
: AppListItemView(apps_grid_view, item, delegate, item->IsInFolder()) {}
AppListItemView::AppListItemView(AppsGridView* apps_grid_view, AppListItemView::AppListItemView(AppsGridView* apps_grid_view,
AppListItem* item, AppListItem* item,
AppListViewDelegate* delegate, AppListViewDelegate* delegate,
......
...@@ -45,9 +45,6 @@ class APP_LIST_EXPORT AppListItemView : public views::Button, ...@@ -45,9 +45,6 @@ class APP_LIST_EXPORT AppListItemView : public views::Button,
// Internal class name. // Internal class name.
static const char kViewClassName[]; static const char kViewClassName[];
AppListItemView(AppsGridView* apps_grid_view,
AppListItem* item,
AppListViewDelegate* delegate);
AppListItemView(AppsGridView* apps_grid_view, AppListItemView(AppsGridView* apps_grid_view,
AppListItem* item, AppListItem* item,
AppListViewDelegate* delegate, AppListViewDelegate* delegate,
......
...@@ -943,10 +943,7 @@ void AppsGridView::InitiateDragFromReparentItemInRootLevelGridView( ...@@ -943,10 +943,7 @@ void AppsGridView::InitiateDragFromReparentItemInRootLevelGridView(
// Create a new AppListItemView to duplicate the original_drag_view in the // Create a new AppListItemView to duplicate the original_drag_view in the
// folder's grid view. // folder's grid view.
auto view = std::make_unique<AppListItemView>( auto view = CreateViewForItem(original_drag_view->item());
this, original_drag_view->item(),
contents_view_->GetAppListMainView()->view_delegate(),
false /* is_in_folder */);
items_need_layer_for_drag_ = true; items_need_layer_for_drag_ = true;
auto* view_ptr = items_container_->AddChildView(std::move(view)); auto* view_ptr = items_container_->AddChildView(std::move(view));
for (const auto& entry : view_model_.entries()) for (const auto& entry : view_model_.entries())
...@@ -1388,20 +1385,27 @@ void AppsGridView::UpdatePulsingBlockViews() { ...@@ -1388,20 +1385,27 @@ void AppsGridView::UpdatePulsingBlockViews() {
} }
} }
std::unique_ptr<AppListItemView> AppsGridView::CreateViewForItemAtIndex( std::unique_ptr<AppListItemView> AppsGridView::CreateViewForItem(
size_t index) { AppListItem* item,
// The |drag_view_| might be pending for deletion, therefore |view_model_| bool is_in_folder) {
// may have one more item than |item_list_|.
DCHECK_LE(index, item_list_->item_count());
std::unique_ptr<AppListItemView> view = std::make_unique<AppListItemView>( std::unique_ptr<AppListItemView> view = std::make_unique<AppListItemView>(
this, item_list_->item_at(index), this, item, contents_view_->GetAppListMainView()->view_delegate(),
contents_view_->GetAppListMainView()->view_delegate()); is_in_folder);
view->set_callback(base::BindRepeating( view->set_callback(base::BindRepeating(
&AppsGridView::OnAppListItemViewPressed, base::Unretained(this), &AppsGridView::OnAppListItemViewPressed, base::Unretained(this),
base::Unretained(view.get()))); base::Unretained(view.get())));
return view; return view;
} }
std::unique_ptr<AppListItemView> AppsGridView::CreateViewForItemAtIndex(
size_t index) {
// The |drag_view_| might be pending for deletion, therefore |view_model_|
// may have one more item than |item_list_|.
DCHECK_LE(index, item_list_->item_count());
auto* item = item_list_->item_at(index);
return CreateViewForItem(item, item->IsInFolder());
}
bool AppsGridView::HandleScroll(const gfx::Vector2d& offset, bool AppsGridView::HandleScroll(const gfx::Vector2d& offset,
ui::EventType type) { ui::EventType type) {
// If |pagination_model_| is empty, don't handle scroll events. // If |pagination_model_| is empty, don't handle scroll events.
...@@ -2208,15 +2212,10 @@ void AppsGridView::HandleKeyboardReparent(AppListItemView* reparented_view, ...@@ -2208,15 +2212,10 @@ void AppsGridView::HandleKeyboardReparent(AppListItemView* reparented_view,
DCHECK(!folder_delegate_); DCHECK(!folder_delegate_);
DCHECK(activated_folder_item_view_); DCHECK(activated_folder_item_view_);
auto reparented_view_in_root_grid = std::make_unique<AppListItemView>( auto* reparented_view_in_root_grid = items_container_->AddChildView(
this, reparented_view->item(), CreateViewForItem(reparented_view->item()));
contents_view_->GetAppListMainView()->view_delegate(), view_model_.Add(reparented_view_in_root_grid, view_model_.view_size());
false /* is_in_folder */); view_structure_.Add(reparented_view_in_root_grid, GetLastTargetIndex());
auto* reparented_view_in_root_grid_ptr =
items_container_->AddChildView(std::move(reparented_view_in_root_grid));
view_model_.Add(reparented_view_in_root_grid_ptr, view_model_.view_size());
view_structure_.Add(reparented_view_in_root_grid_ptr, GetLastTargetIndex());
// Set |activated_folder_item_view_| selected so |target_index| will be // Set |activated_folder_item_view_| selected so |target_index| will be
// computed relative to the open folder. // computed relative to the open folder.
...@@ -2224,7 +2223,7 @@ void AppsGridView::HandleKeyboardReparent(AppListItemView* reparented_view, ...@@ -2224,7 +2223,7 @@ void AppsGridView::HandleKeyboardReparent(AppListItemView* reparented_view,
const GridIndex target_index = const GridIndex target_index =
GetTargetGridIndexForKeyboardReparent(key_code); GetTargetGridIndexForKeyboardReparent(key_code);
AnnounceReorder(target_index); AnnounceReorder(target_index);
ReparentItemForReorder(reparented_view_in_root_grid_ptr, target_index); ReparentItemForReorder(reparented_view_in_root_grid, target_index);
GetViewAtIndex(target_index)->RequestFocus(); GetViewAtIndex(target_index)->RequestFocus();
Layout(); Layout();
......
...@@ -47,6 +47,7 @@ class AppsGridViewTestApi; ...@@ -47,6 +47,7 @@ class AppsGridViewTestApi;
class ApplicationDragAndDropHost; class ApplicationDragAndDropHost;
class AppListConfig; class AppListConfig;
class AppListItem;
class AppListItemView; class AppListItemView;
class AppsGridViewFolderDelegate; class AppsGridViewFolderDelegate;
class ContentsView; class ContentsView;
...@@ -379,6 +380,9 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -379,6 +380,9 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// number of apps. // number of apps.
void UpdatePulsingBlockViews(); void UpdatePulsingBlockViews();
std::unique_ptr<AppListItemView> CreateViewForItem(AppListItem* item,
bool is_in_folder = false);
std::unique_ptr<AppListItemView> CreateViewForItemAtIndex(size_t index); std::unique_ptr<AppListItemView> CreateViewForItemAtIndex(size_t index);
// Returns true if the event was handled by the pagination controller. // Returns true if the event was handled by the pagination controller.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment