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

Unified Diff: ui/app_list/views/page_switcher.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
« ui/app_list/views/page_switcher.h ('K') | « ui/app_list/views/page_switcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/page_switcher.cc
diff --git a/ui/app_list/views/page_switcher.cc b/ui/app_list/views/page_switcher.cc
index 84077f9a6a86a46e2b588d64ce781504a059b75b..7da2593e7ca86169e9ec7af858ccb9ec2da0c059 100644
--- a/ui/app_list/views/page_switcher.cc
+++ b/ui/app_list/views/page_switcher.cc
@@ -128,7 +128,8 @@ PageSwitcher::PageSwitcher(PaginationModel* model)
}
PageSwitcher::~PageSwitcher() {
- model_->RemoveObserver(this);
+ if (model_)
+ model_->RemoveObserver(this);
}
int PageSwitcher::GetPageForPoint(const gfx::Point& point) const {
@@ -165,6 +166,13 @@ void PageSwitcher::UpdateUIForDragPoint(const gfx::Point& point) {
}
}
+void PageSwitcher::ReleasePaginationModel() {
+ if (!model_)
+ return;
+ model_->RemoveObserver(this);
+ model_ = NULL;
+}
+
gfx::Size PageSwitcher::GetPreferredSize() const {
// Always return a size with correct height so that container resize is not
// needed when more pages are added.
@@ -218,6 +226,9 @@ void PageSwitcher::CalculateButtonWidthAndSpacing(int contents_width) {
void PageSwitcher::ButtonPressed(views::Button* sender,
const ui::Event& event) {
+ if (!model_)
+ return;
+
for (int i = 0; i < buttons_->child_count(); ++i) {
if (sender == static_cast<views::Button*>(buttons_->child_at(i))) {
model_->SelectPage(i, true /* animate */);
@@ -227,6 +238,7 @@ void PageSwitcher::ButtonPressed(views::Button* sender,
}
void PageSwitcher::TotalPagesChanged() {
+ DCHECK(model_);
buttons_->RemoveAllChildViews(true);
for (int i = 0; i < model_->total_pages(); ++i) {
PageSwitcherButton* button = new PageSwitcherButton(this);
@@ -248,6 +260,7 @@ void PageSwitcher::TransitionStarted() {
}
void PageSwitcher::TransitionChanged() {
+ DCHECK(model_);
const int current_page = model_->selected_page();
const int target_page = model_->transition().target_page;
« ui/app_list/views/page_switcher.h ('K') | « ui/app_list/views/page_switcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698