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

Unified Diff: ash/wm/app_list_controller.cc

Issue 302803002: Refactor app list so AppsGridView owns the PaginationModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests and bugs. 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
Index: ash/wm/app_list_controller.cc
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index 6acf1aef33e2e868892ad2757babfeb9d190a142..6d00993648428c5c3c8873916c27280817d429a0 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -16,7 +16,11 @@
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_switches.h"
#include "ui/app_list/pagination_model.h"
+#include "ui/app_list/views/app_list_main_view.h"
#include "ui/app_list/views/app_list_view.h"
+#include "ui/app_list/views/apps_container_view.h"
+#include "ui/app_list/views/apps_grid_view.h"
+#include "ui/app_list/views/contents_view.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
@@ -153,23 +157,28 @@ int GetMinimumBoundsHeightForAppList(const app_list::AppListView* app_list) {
// AppListController, public:
AppListController::AppListController()
- : pagination_model_(new app_list::PaginationModel),
- is_visible_(false),
+ : is_visible_(false),
is_centered_(false),
view_(NULL),
+ pagination_model_(NULL),
+ current_app_page_(-1),
should_snap_back_(false) {
Shell::GetInstance()->AddShellObserver(this);
- pagination_model_->AddObserver(this);
}
AppListController::~AppListController() {
// Ensures app list view goes before the controller since pagination model
// lives in the controller and app list view would access it on destruction.
- if (view_ && view_->GetWidget())
- view_->GetWidget()->CloseNow();
+ if (view_) {
+ DCHECK(pagination_model_);
+ pagination_model_->RemoveObserver(this);
+ if (view_->GetWidget())
+ view_->GetWidget()->CloseNow();
+ } else {
+ DCHECK(!pagination_model_);
+ }
Shell::GetInstance()->RemoveShellObserver(this);
- pagination_model_->RemoveObserver(this);
}
void AppListController::SetVisible(bool visible, aura::Window* window) {
@@ -208,7 +217,6 @@ void AppListController::SetVisible(bool visible, aura::Window* window) {
// init at (0, 0) and then reset its anchor point.
view->InitAsBubbleAtFixedLocation(
container,
- pagination_model_.get(),
gfx::Point(),
views::BubbleBorder::FLOAT,
true /* border_accepts_events */);
@@ -225,7 +233,6 @@ void AppListController::SetVisible(bool visible, aura::Window* window) {
applist_button_bounds);
view->InitAsBubbleAttachedToAnchor(
container,
- pagination_model_.get(),
Shelf::ForWindow(container)->GetAppListButtonView(),
GetAnchorPositionOffsetToShelf(applist_button_bounds,
Shelf::ForWindow(container)->GetAppListButtonView()->
@@ -263,6 +270,7 @@ void AppListController::SetDragAndDropHostOfCurrentAppList(
void AppListController::SetView(app_list::AppListView* view) {
DCHECK(view_ == NULL);
+ DCHECK(pagination_model_ == NULL);
DCHECK(is_visible_);
view_ = view;
@@ -277,6 +285,15 @@ void AppListController::SetView(app_list::AppListView* view) {
widget->GetNativeView()->GetRootWindow()->AddObserver(this);
aura::client::GetFocusClient(widget->GetNativeView())->AddObserver(this);
+ pagination_model_ = view_->app_list_main_view()
tapted 2014/06/02 04:02:21 I think this justifies a GetPaginationModel() acce
Matt Giuca 2014/06/02 07:11:23 Done & Done.
+ ->contents_view()
+ ->apps_container_view()
+ ->apps_grid_view()
+ ->GetPaginationModel();
+ pagination_model_->AddObserver(this);
+ if (pagination_model_->is_valid_page(current_app_page_))
+ pagination_model_->SelectPage(current_app_page_, false);
+
view_->ShowWhenReady();
}
@@ -295,6 +312,11 @@ void AppListController::ResetView() {
Shelf::ForWindow(widget->GetNativeWindow())->RemoveIconObserver(this);
widget->GetNativeView()->GetRootWindow()->RemoveObserver(this);
aura::client::GetFocusClient(widget->GetNativeView())->RemoveObserver(this);
+
+ DCHECK(pagination_model_);
+ pagination_model_->RemoveObserver(this);
+ pagination_model_ = NULL;
+
view_ = NULL;
}
@@ -449,6 +471,7 @@ void AppListController::TotalPagesChanged() {
void AppListController::SelectedPageChanged(int old_selected,
int new_selected) {
+ current_app_page_ = new_selected;
}
void AppListController::TransitionStarted() {
@@ -459,6 +482,8 @@ void AppListController::TransitionChanged() {
if (!view_)
return;
+ DCHECK(pagination_model_);
+
const app_list::PaginationModel::Transition& transition =
pagination_model_->transition();
if (pagination_model_->is_valid_page(transition.target_page))

Powered by Google App Engine
This is Rietveld 408576698