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

Unified Diff: ui/app_list/views/app_list_main_view.cc

Issue 302803002: Refactor app list so AppsGridView owns the PaginationModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error (conflict). 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/app_list_main_view.h ('k') | ui/app_list/views/app_list_main_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/app_list_main_view.cc
diff --git a/ui/app_list/views/app_list_main_view.cc b/ui/app_list/views/app_list_main_view.cc
index 20db203df05ade2f6f685f0772f1edd93cd49a88..ba4f8d22930247fadb8bdbf8e75d80f987676bf2 100644
--- a/ui/app_list/views/app_list_main_view.cc
+++ b/ui/app_list/views/app_list_main_view.cc
@@ -84,10 +84,9 @@ class AppListMainView::IconLoader : public AppListItemObserver {
// AppListMainView:
AppListMainView::AppListMainView(AppListViewDelegate* delegate,
- PaginationModel* pagination_model,
+ int initial_apps_page,
gfx::NativeView parent)
: delegate_(delegate),
- pagination_model_(pagination_model),
model_(delegate->GetModel()),
search_box_view_(NULL),
contents_view_(NULL),
@@ -103,13 +102,17 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate,
if (app_list::switches::IsExperimentalAppListEnabled())
AddChildView(new ContentsSwitcherView(contents_view_));
+ // Switch the apps grid view to the specified page.
+ app_list::PaginationModel* pagination_model = GetAppsPaginationModel();
+ if (pagination_model->is_valid_page(initial_apps_page))
+ pagination_model->SelectPage(initial_apps_page, false);
+
// Starts icon loading early.
PreloadIcons(parent);
}
void AppListMainView::AddContentsView() {
- contents_view_ = new ContentsView(
- this, pagination_model_, model_, delegate_);
+ contents_view_ = new ContentsView(this, model_, delegate_);
AddChildViewAt(contents_view_, kContentsViewIndex);
search_box_view_->set_contents_view(contents_view_);
@@ -163,7 +166,6 @@ void AppListMainView::ModelChanged() {
search_box_view_->ModelChanged();
delete contents_view_;
contents_view_ = NULL;
- pagination_model_->SelectPage(0, false /* animate */);
AddContentsView();
Layout();
}
@@ -188,14 +190,21 @@ bool AppListMainView::ShouldCenterWindow() const {
return delegate_->ShouldCenterWindow();
}
+PaginationModel* AppListMainView::GetAppsPaginationModel() {
+ return contents_view_->apps_container_view()
+ ->apps_grid_view()
+ ->pagination_model();
+}
+
void AppListMainView::PreloadIcons(gfx::NativeView parent) {
float scale_factor = 1.0f;
if (parent)
scale_factor = ui::GetScaleFactorForNativeView(parent);
- // |pagination_model| could have -1 as the initial selected page and
+ // The PaginationModel could have -1 as the initial selected page and
// assumes first page (i.e. index 0) will be used in this case.
- const int selected_page = std::max(0, pagination_model_->selected_page());
+ const int selected_page =
+ std::max(0, GetAppsPaginationModel()->selected_page());
const AppsGridView* const apps_grid_view =
contents_view_->apps_container_view()->apps_grid_view();
« no previous file with comments | « ui/app_list/views/app_list_main_view.h ('k') | ui/app_list/views/app_list_main_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698