Commit 3d05e15b authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Reland "Update and clarify view ownership for app-list views."

This is a reland of fe842ad4

Original change's description:
> Update and clarify view ownership for app-list views.
> 
> Bug: 648382
> Change-Id: I0d000accee686dd67b2db1e14cea20ff893835c5
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001399
> Commit-Queue: Allen Bauer <kylixrd@chromium.org>
> Reviewed-by: Alex Newcomer <newcomer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#732019}

Bug: 648382
Change-Id: I07aa57e7b497367fd5699bf997dc76c6f36f355c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2012835Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734244}
parent e1040299
...@@ -49,8 +49,6 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate, ...@@ -49,8 +49,6 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate,
: delegate_(delegate), : delegate_(delegate),
model_(delegate->GetModel()), model_(delegate->GetModel()),
search_model_(delegate->GetSearchModel()), search_model_(delegate->GetSearchModel()),
search_box_view_(nullptr),
contents_view_(nullptr),
app_list_view_(app_list_view) { app_list_view_(app_list_view) {
// We need a layer to apply transform to in small display so that the apps // We need a layer to apply transform to in small display so that the apps
// grid fits in the display. // grid fits in the display.
...@@ -77,11 +75,11 @@ void AppListMainView::Init(int initial_apps_page, ...@@ -77,11 +75,11 @@ void AppListMainView::Init(int initial_apps_page,
void AppListMainView::AddContentsViews() { void AppListMainView::AddContentsViews() {
DCHECK(search_box_view_); DCHECK(search_box_view_);
contents_view_ = new ContentsView(app_list_view_); auto contents_view = std::make_unique<ContentsView>(app_list_view_);
contents_view_->Init(model_); contents_view->Init(model_);
contents_view_->SetPaintToLayer(ui::LAYER_NOT_DRAWN); contents_view->SetPaintToLayer(ui::LAYER_NOT_DRAWN);
contents_view_->layer()->SetMasksToBounds(true); contents_view->layer()->SetMasksToBounds(true);
AddChildView(contents_view_); contents_view_ = AddChildView(std::move(contents_view));
search_box_view_->set_contents_view(contents_view_); search_box_view_->set_contents_view(contents_view_);
} }
......
...@@ -99,10 +99,10 @@ class APP_LIST_EXPORT AppListMainView ...@@ -99,10 +99,10 @@ class APP_LIST_EXPORT AppListMainView
SearchModel* search_model_; // Unowned; ownership is handled by |delegate_|. SearchModel* search_model_; // Unowned; ownership is handled by |delegate_|.
// Created by AppListView. Owned by views hierarchy. // Created by AppListView. Owned by views hierarchy.
SearchBoxView* search_box_view_; SearchBoxView* search_box_view_ = nullptr;
ContentsView* contents_view_; // Owned by views hierarchy. ContentsView* contents_view_ = nullptr; // Owned by views hierarchy.
AppListView* const app_list_view_; // Owned by views hierarchy. AppListView* const app_list_view_; // Owned by views hierarchy.
DISALLOW_COPY_AND_ASSIGN(AppListMainView); DISALLOW_COPY_AND_ASSIGN(AppListMainView);
}; };
......
...@@ -618,20 +618,24 @@ void AppListView::InitContents(bool is_tablet_mode) { ...@@ -618,20 +618,24 @@ void AppListView::InitContents(bool is_tablet_mode) {
DCHECK(!search_box_view_); DCHECK(!search_box_view_);
DCHECK(!announcement_view_); DCHECK(!announcement_view_);
auto app_list_background_shield =
std::make_unique<AppListBackgroundShieldView>(delegate_->GetShelfSize() /
2);
app_list_background_shield->UpdateBackground(/*use_blur*/ !is_tablet_mode &&
is_background_blur_enabled_);
app_list_background_shield_ = app_list_background_shield_ =
new AppListBackgroundShieldView(delegate_->GetShelfSize() / 2); AddChildView(std::move(app_list_background_shield));
app_list_background_shield_->UpdateBackground(/*use_blur*/ !is_tablet_mode &&
is_background_blur_enabled_);
AddChildView(app_list_background_shield_);
app_list_main_view_ = new AppListMainView(delegate_, this); auto app_list_main_view = std::make_unique<AppListMainView>(delegate_, this);
search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_, this); search_box_view_ =
new SearchBoxView(app_list_main_view.get(), delegate_, this);
search_box_view_->Init(is_tablet_mode); search_box_view_->Init(is_tablet_mode);
app_list_main_view_->Init(0, search_box_view_); // Assign |app_list_main_view_| here since it is accessed during Init().
AddChildView(app_list_main_view_); app_list_main_view_ = app_list_main_view.get();
announcement_view_ = new views::View(); app_list_main_view->Init(0, search_box_view_);
AddChildView(announcement_view_); AddChildView(std::move(app_list_main_view));
announcement_view_ = AddChildView(std::make_unique<views::View>());
} }
void AppListView::InitWidget(gfx::NativeView parent) { void AppListView::InitWidget(gfx::NativeView parent) {
......
...@@ -62,25 +62,26 @@ AppsContainerView::AppsContainerView(ContentsView* contents_view, ...@@ -62,25 +62,26 @@ AppsContainerView::AppsContainerView(ContentsView* contents_view,
: contents_view_(contents_view) { : contents_view_(contents_view) {
SetPaintToLayer(ui::LAYER_NOT_DRAWN); SetPaintToLayer(ui::LAYER_NOT_DRAWN);
suggestion_chip_container_view_ = suggestion_chip_container_view_ = AddChildView(
new SuggestionChipContainerView(contents_view); std::make_unique<SuggestionChipContainerView>(contents_view));
AddChildView(suggestion_chip_container_view_);
apps_grid_view_ = new AppsGridView(contents_view_, nullptr); apps_grid_view_ =
AddChildView(apps_grid_view_); AddChildView(std::make_unique<AppsGridView>(contents_view_, nullptr));
// Page switcher should be initialized after AppsGridView. // Page switcher should be initialized after AppsGridView.
page_switcher_ = auto page_switcher = std::make_unique<PageSwitcher>(
new PageSwitcher(apps_grid_view_->pagination_model(), true /* vertical */, apps_grid_view_->pagination_model(), true /* vertical */,
contents_view_->app_list_view()->is_tablet_mode()); contents_view_->app_list_view()->is_tablet_mode());
AddChildView(page_switcher_); page_switcher_ = AddChildView(std::move(page_switcher));
app_list_folder_view_ = new AppListFolderView(this, model, contents_view_); auto app_list_folder_view =
std::make_unique<AppListFolderView>(this, model, contents_view_);
// The folder view is initially hidden. // The folder view is initially hidden.
app_list_folder_view_->SetVisible(false); app_list_folder_view->SetVisible(false);
folder_background_view_ = new FolderBackgroundView(app_list_folder_view_); auto folder_background_view =
AddChildView(folder_background_view_); std::make_unique<FolderBackgroundView>(app_list_folder_view.get());
AddChildView(app_list_folder_view_); folder_background_view_ = AddChildView(std::move(folder_background_view));
app_list_folder_view_ = AddChildView(std::move(app_list_folder_view));
apps_grid_view_->SetModel(model); apps_grid_view_->SetModel(model);
apps_grid_view_->SetItemList(model->top_level_item_list()); apps_grid_view_->SetItemList(model->top_level_item_list());
......
This diff is collapsed.
...@@ -347,7 +347,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -347,7 +347,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// number of apps. // number of apps.
void UpdatePulsingBlockViews(); void UpdatePulsingBlockViews();
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.
bool HandleScroll(const gfx::Vector2d& offset, ui::EventType type); bool HandleScroll(const gfx::Vector2d& offset, ui::EventType type);
......
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