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

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

Issue 27777002: Implement app list folder management page UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 7 years, 2 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: ui/app_list/views/apps_grid_view.cc
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index 491883e420fe14bb68c40c65f4d80f009da4b6e4..e252664d05872f5436be898d98c63bf07191b55a 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -237,6 +237,7 @@ AppsGridView::AppsGridView(AppsGridViewDelegate* delegate,
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)),
@@ -272,11 +273,12 @@ AppsGridView::~AppsGridView() {
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) {
@@ -291,16 +293,22 @@ void AppsGridView::SetLayout(int icon_size, int cols, int rows_per_page) {
}
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();
}
@@ -625,17 +633,14 @@ void AppsGridView::ViewHierarchyChanged(
}
}
-// 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 (model_ && model_->apps()->item_count())
- ListItemsAdded(0, model_->apps()->item_count());
+ if (apps_ && apps_->item_count())
+ ListItemsAdded(0, apps_->item_count());
}
void AppsGridView::UpdatePaging() {
@@ -648,7 +653,7 @@ void AppsGridView::UpdatePaging() {
void AppsGridView::UpdatePulsingBlockViews() {
const int available_slots =
- tiles_per_page() - model_->apps()->item_count() % tiles_per_page();
+ tiles_per_page() - apps_->item_count() % tiles_per_page();
const int desired = model_->status() == AppListModel::STATUS_SYNCING ?
available_slots : 0;
@@ -670,9 +675,9 @@ void AppsGridView::UpdatePulsingBlockViews() {
}
views::View* AppsGridView::CreateViewForItemAtIndex(size_t index) {
- DCHECK_LT(index, model_->apps()->item_count());
+ DCHECK_LT(index, apps_->item_count());
AppListItemView* view = new AppListItemView(this,
- model_->apps()->GetItemAt(index));
+ apps_->GetItemAt(index));
view->SetIconSize(icon_size_);
#if defined(USE_AURA)
view->SetPaintToLayer(true);
@@ -1107,10 +1112,10 @@ void AppsGridView::MoveItemInModel(views::View* item_view,
if (target_model_index == current_model_index)
return;
- model_->apps()->RemoveObserver(this);
- model_->apps()->Move(current_model_index, target_model_index);
+ apps_->RemoveObserver(this);
+ apps_->Move(current_model_index, target_model_index);
view_model_.Move(current_model_index, target_model_index);
- model_->apps()->AddObserver(this);
+ apps_->AddObserver(this);
if (pagination_model_->selected_page() != target.page)
pagination_model_->SelectPage(target.page, false);

Powered by Google App Engine
This is Rietveld 408576698