| Index: trunk/src/ui/app_list/views/apps_grid_view.cc
|
| ===================================================================
|
| --- trunk/src/ui/app_list/views/apps_grid_view.cc (revision 230254)
|
| +++ trunk/src/ui/app_list/views/apps_grid_view.cc (working copy)
|
| @@ -237,7 +237,6 @@
|
| PaginationModel* pagination_model,
|
| content::WebContents* start_page_contents)
|
| : model_(NULL),
|
| - apps_(NULL),
|
| delegate_(delegate),
|
| pagination_model_(pagination_model),
|
| page_switcher_view_(new PageSwitcher(pagination_model)),
|
| @@ -273,12 +272,11 @@
|
| if (drag_view_)
|
| EndDrag(true);
|
|
|
| - if (model_)
|
| + if (model_) {
|
| model_->RemoveObserver(this);
|
| + model_->apps()->RemoveObserver(this);
|
| + }
|
| pagination_model_->RemoveObserver(this);
|
| -
|
| - if (apps_)
|
| - apps_->RemoveObserver(this);
|
| }
|
|
|
| void AppsGridView::SetLayout(int icon_size, int cols, int rows_per_page) {
|
| @@ -293,25 +291,19 @@
|
| }
|
|
|
| void AppsGridView::SetModel(AppListModel* model) {
|
| - if (model_)
|
| + if (model_) {
|
| model_->RemoveObserver(this);
|
| + model_->apps()->RemoveObserver(this);
|
| + }
|
|
|
| model_ = model;
|
| - if (model_)
|
| + if (model_) {
|
| model_->AddObserver(this);
|
| -
|
| + model_->apps()->AddObserver(this);
|
| + }
|
| Update();
|
| }
|
|
|
| -void AppsGridView::SetApps(AppListModel::Apps* apps) {
|
| - if (apps_)
|
| - apps_->RemoveObserver(this);
|
| -
|
| - apps_ = apps;
|
| - apps_->AddObserver(this);
|
| - Update();
|
| -}
|
| -
|
| void AppsGridView::SetSelectedView(views::View* view) {
|
| if (IsSelectedView(view) || IsDraggedView(view))
|
| return;
|
| @@ -633,14 +625,17 @@
|
| }
|
| }
|
|
|
| +// static
|
| +AppsGridView* AppsGridView::GetLastGridViewForTest() {
|
| + return last_created_grid_view_for_test;
|
| +}
|
| +
|
| void AppsGridView::Update() {
|
| DCHECK(!selected_view_ && !drag_view_);
|
| - if (!apps_)
|
| - return;
|
|
|
| view_model_.Clear();
|
| - if (apps_ && apps_->item_count())
|
| - ListItemsAdded(0, apps_->item_count());
|
| + if (model_ && model_->apps()->item_count())
|
| + ListItemsAdded(0, model_->apps()->item_count());
|
| }
|
|
|
| void AppsGridView::UpdatePaging() {
|
| @@ -653,7 +648,7 @@
|
|
|
| void AppsGridView::UpdatePulsingBlockViews() {
|
| const int available_slots =
|
| - tiles_per_page() - apps_->item_count() % tiles_per_page();
|
| + tiles_per_page() - model_->apps()->item_count() % tiles_per_page();
|
| const int desired = model_->status() == AppListModel::STATUS_SYNCING ?
|
| available_slots : 0;
|
|
|
| @@ -675,9 +670,9 @@
|
| }
|
|
|
| views::View* AppsGridView::CreateViewForItemAtIndex(size_t index) {
|
| - DCHECK_LT(index, apps_->item_count());
|
| + DCHECK_LT(index, model_->apps()->item_count());
|
| AppListItemView* view = new AppListItemView(this,
|
| - apps_->GetItemAt(index));
|
| + model_->apps()->GetItemAt(index));
|
| view->SetIconSize(icon_size_);
|
| #if defined(USE_AURA)
|
| view->SetPaintToLayer(true);
|
| @@ -1112,10 +1107,10 @@
|
| if (target_model_index == current_model_index)
|
| return;
|
|
|
| - apps_->RemoveObserver(this);
|
| - apps_->Move(current_model_index, target_model_index);
|
| + model_->apps()->RemoveObserver(this);
|
| + model_->apps()->Move(current_model_index, target_model_index);
|
| view_model_.Move(current_model_index, target_model_index);
|
| - apps_->AddObserver(this);
|
| + model_->apps()->AddObserver(this);
|
|
|
| if (pagination_model_->selected_page() != target.page)
|
| pagination_model_->SelectPage(target.page, false);
|
|
|