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

Side by Side Diff: ui/app_list/views/apps_grid_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 tests and bugs. Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/app_list/views/apps_grid_view.h" 5 #include "ui/app_list/views/apps_grid_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 gfx::Point drag_view_offset_; 328 gfx::Point drag_view_offset_;
329 bool has_shortcut_path_; 329 bool has_shortcut_path_;
330 base::FilePath shortcut_path_; 330 base::FilePath shortcut_path_;
331 bool running_; 331 bool running_;
332 bool canceled_; 332 bool canceled_;
333 333
334 DISALLOW_COPY_AND_ASSIGN(SynchronousDrag); 334 DISALLOW_COPY_AND_ASSIGN(SynchronousDrag);
335 }; 335 };
336 #endif // defined(OS_WIN) 336 #endif // defined(OS_WIN)
337 337
338 AppsGridView::AppsGridView(AppsGridViewDelegate* delegate, 338 AppsGridView::AppsGridView(AppsGridViewDelegate* delegate)
339 PaginationModel* pagination_model)
340 : model_(NULL), 339 : model_(NULL),
341 item_list_(NULL), 340 item_list_(NULL),
342 delegate_(delegate), 341 delegate_(delegate),
343 folder_delegate_(NULL), 342 folder_delegate_(NULL),
344 pagination_model_(pagination_model), 343 pagination_model_(new PaginationModel),
345 page_switcher_view_(new PageSwitcher(pagination_model)), 344 page_switcher_view_(new PageSwitcher(pagination_model_.get())),
346 cols_(0), 345 cols_(0),
347 rows_per_page_(0), 346 rows_per_page_(0),
348 selected_view_(NULL), 347 selected_view_(NULL),
349 drag_view_(NULL), 348 drag_view_(NULL),
350 drag_start_page_(-1), 349 drag_start_page_(-1),
351 #if defined(OS_WIN) 350 #if defined(OS_WIN)
352 use_synchronous_drag_(true), 351 use_synchronous_drag_(true),
353 #endif 352 #endif
354 drag_pointer_(NONE), 353 drag_pointer_(NONE),
355 drop_attempt_(DROP_FOR_NONE), 354 drop_attempt_(DROP_FOR_NONE),
(...skipping 21 matching lines...) Expand all
377 DCHECK(!drag_view_); 376 DCHECK(!drag_view_);
378 if (drag_view_) 377 if (drag_view_)
379 EndDrag(true); 378 EndDrag(true);
380 379
381 if (model_) 380 if (model_)
382 model_->RemoveObserver(this); 381 model_->RemoveObserver(this);
383 pagination_model_->RemoveObserver(this); 382 pagination_model_->RemoveObserver(this);
384 383
385 if (item_list_) 384 if (item_list_)
386 item_list_->RemoveObserver(this); 385 item_list_->RemoveObserver(this);
386
387 // Since |pagination_model_| will be destroyed before the views,
388 // |page_switcher_view_| must stop observing. (We cannot simply call
389 // RemoveAllChildViews, since that will trigger a ViewHierarchyChanged which
390 // should not be called during destruction.)
xiyuan 2014/05/30 15:47:47 RemoveAllChildViews could be called from a view's
tapted 2014/06/02 04:02:21 (#guessing) Perhaps because PageSwitcher is a "sib
Matt Giuca 2014/06/02 07:11:23 I can't call RemoveAllChildViews from this view's
tapted 2014/06/02 08:36:49 yep - that ;) True, it's a lazy/not-ideal way to
xiyuan 2014/06/02 17:02:08 CHECK_EQ is added to catch a crash where view_mode
Matt Giuca 2014/06/03 01:52:36 Ah OK, I didn't realise it was as simple as cleari
391 page_switcher_view_->ReleasePaginationModel();
387 } 392 }
388 393
389 void AppsGridView::SetLayout(int icon_size, int cols, int rows_per_page) { 394 void AppsGridView::SetLayout(int icon_size, int cols, int rows_per_page) {
390 icon_size_.SetSize(icon_size, icon_size); 395 icon_size_.SetSize(icon_size, icon_size);
391 cols_ = cols; 396 cols_ = cols;
392 rows_per_page_ = rows_per_page; 397 rows_per_page_ = rows_per_page;
393 398
394 SetBorder(views::Border::CreateEmptyBorder( 399 SetBorder(views::Border::CreateEmptyBorder(
395 kTopPadding, kLeftRightPadding, 0, kLeftRightPadding)); 400 kTopPadding, kLeftRightPadding, 0, kLeftRightPadding));
396 } 401 }
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, 2171 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index,
2167 bool is_target_folder) { 2172 bool is_target_folder) {
2168 AppListItemView* target_view = 2173 AppListItemView* target_view =
2169 static_cast<AppListItemView*>( 2174 static_cast<AppListItemView*>(
2170 GetViewAtSlotOnCurrentPage(target_index.slot)); 2175 GetViewAtSlotOnCurrentPage(target_index.slot));
2171 if (target_view) 2176 if (target_view)
2172 target_view->SetAsAttemptedFolderTarget(is_target_folder); 2177 target_view->SetAsAttemptedFolderTarget(is_target_folder);
2173 } 2178 }
2174 2179
2175 } // namespace app_list 2180 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698