Chromium Code Reviews| 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..9838986b86cdc59e6957c6d4cc441aae8354d1e1 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" |
|
tapted
2014/06/02 08:36:49
nit: these 3 includes, and app_list_main_view.h ab
Matt Giuca
2014/06/03 01:52:36
Done.
|
| +#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,24 @@ 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), |
| + 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_) { |
| + view_->GetAppsPaginationModel()->RemoveObserver(this); |
| + if (view_->GetWidget()) |
| + view_->GetWidget()->CloseNow(); |
| + } |
| Shell::GetInstance()->RemoveShellObserver(this); |
| - pagination_model_->RemoveObserver(this); |
| } |
| void AppListController::SetVisible(bool visible, aura::Window* window) { |
| @@ -208,7 +213,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 +229,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()-> |
| @@ -277,6 +280,11 @@ void AppListController::SetView(app_list::AppListView* view) { |
| widget->GetNativeView()->GetRootWindow()->AddObserver(this); |
| aura::client::GetFocusClient(widget->GetNativeView())->AddObserver(this); |
| + app_list::PaginationModel* pagination_model = view_->GetAppsPaginationModel(); |
| + pagination_model->AddObserver(this); |
| + if (pagination_model->is_valid_page(current_app_page_)) |
| + pagination_model->SelectPage(current_app_page_, false); |
| + |
| view_->ShowWhenReady(); |
| } |
| @@ -295,6 +303,9 @@ void AppListController::ResetView() { |
| Shelf::ForWindow(widget->GetNativeWindow())->RemoveIconObserver(this); |
| widget->GetNativeView()->GetRootWindow()->RemoveObserver(this); |
| aura::client::GetFocusClient(widget->GetNativeView())->RemoveObserver(this); |
| + |
| + view_->GetAppsPaginationModel()->RemoveObserver(this); |
| + |
| view_ = NULL; |
| } |
| @@ -449,6 +460,7 @@ void AppListController::TotalPagesChanged() { |
| void AppListController::SelectedPageChanged(int old_selected, |
| int new_selected) { |
| + current_app_page_ = new_selected; |
| } |
| void AppListController::TransitionStarted() { |
| @@ -459,20 +471,22 @@ void AppListController::TransitionChanged() { |
| if (!view_) |
| return; |
| + app_list::PaginationModel* pagination_model = view_->GetAppsPaginationModel(); |
| + |
| const app_list::PaginationModel::Transition& transition = |
| - pagination_model_->transition(); |
| - if (pagination_model_->is_valid_page(transition.target_page)) |
| + pagination_model->transition(); |
| + if (pagination_model->is_valid_page(transition.target_page)) |
| return; |
| views::Widget* widget = view_->GetWidget(); |
| ui::LayerAnimator* widget_animator = GetLayer(widget)->GetAnimator(); |
| - if (!pagination_model_->IsRevertingCurrentTransition()) { |
| + if (!pagination_model->IsRevertingCurrentTransition()) { |
| // Update cached |view_bounds_| if it is the first over-scroll move and |
| // widget does not have running animations. |
| if (!should_snap_back_ && !widget_animator->is_animating()) |
| view_bounds_ = widget->GetWindowBoundsInScreen(); |
| - const int current_page = pagination_model_->selected_page(); |
| + const int current_page = pagination_model->selected_page(); |
| const int dir = transition.target_page > current_page ? -1 : 1; |
| const double progress = 1.0 - pow(1.0 - transition.progress, 4); |