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

Side by Side Diff: ui/app_list/views/contents_view.cc

Issue 947903002: Change ContentsView::SetActivePage to use States rather than indexes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
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/contents_view.h" 5 #include "ui/app_list/views/contents_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 apps_container_view_->app_list_folder_view()->items_grid_view()->EndDrag( 124 apps_container_view_->app_list_folder_view()->items_grid_view()->EndDrag(
125 true); 125 true);
126 } 126 }
127 } 127 }
128 128
129 void ContentsView::SetDragAndDropHostOfCurrentAppList( 129 void ContentsView::SetDragAndDropHostOfCurrentAppList(
130 ApplicationDragAndDropHost* drag_and_drop_host) { 130 ApplicationDragAndDropHost* drag_and_drop_host) {
131 apps_container_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 131 apps_container_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
132 } 132 }
133 133
134 void ContentsView::SetActivePage(int page_index) { 134 void ContentsView::SetActivePage(AppListModel::State state) {
135 SetActivePage(page_index, true); 135 SetActivePage(state, true);
136 } 136 }
137 137
138 void ContentsView::SetActivePage(int page_index, bool animate) { 138 void ContentsView::SetActivePage(AppListModel::State state, bool animate) {
139 if (GetActivePageIndex() == page_index) 139 if (IsStateActive(state))
140 return; 140 return;
141 141
142 SetActivePageInternal(page_index, false, animate); 142 SetActivePageInternal(GetPageIndexForState(state), false, animate);
143 } 143 }
144 144
145 int ContentsView::GetActivePageIndex() const { 145 int ContentsView::GetActivePageIndex() const {
146 // The active page is changed at the beginning of an animation, not the end. 146 // The active page is changed at the beginning of an animation, not the end.
147 return pagination_model_.SelectedTargetPage(); 147 return pagination_model_.SelectedTargetPage();
148 } 148 }
149 149
150 AppListModel::State ContentsView::GetActiveState() const { 150 AppListModel::State ContentsView::GetActiveState() const {
151 return GetStateForPageIndex(GetActivePageIndex()); 151 return GetStateForPageIndex(GetActivePageIndex());
152 } 152 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 bool ContentsView::Back() { 425 bool ContentsView::Back() {
426 AppListModel::State state = view_to_state_[GetActivePageIndex()]; 426 AppListModel::State state = view_to_state_[GetActivePageIndex()];
427 switch (state) { 427 switch (state) {
428 case AppListModel::STATE_START: 428 case AppListModel::STATE_START:
429 // Close the app list when Back() is called from the start page. 429 // Close the app list when Back() is called from the start page.
430 return false; 430 return false;
431 case AppListModel::STATE_CUSTOM_LAUNCHER_PAGE: 431 case AppListModel::STATE_CUSTOM_LAUNCHER_PAGE:
432 if (app_list_main_view_->model()->PopCustomLauncherPageSubpage()) 432 if (app_list_main_view_->model()->PopCustomLauncherPageSubpage())
433 app_list_main_view_->view_delegate()->CustomLauncherPagePopSubpage(); 433 app_list_main_view_->view_delegate()->CustomLauncherPagePopSubpage();
434 else 434 else
435 SetActivePage(GetPageIndexForState(AppListModel::STATE_START)); 435 SetActivePage(AppListModel::STATE_START);
436 break; 436 break;
437 case AppListModel::STATE_APPS: 437 case AppListModel::STATE_APPS:
438 if (apps_container_view_->IsInFolderView()) 438 if (apps_container_view_->IsInFolderView())
439 apps_container_view_->app_list_folder_view()->CloseFolderPage(); 439 apps_container_view_->app_list_folder_view()->CloseFolderPage();
440 else 440 else
441 SetActivePage(GetPageIndexForState(AppListModel::STATE_START)); 441 SetActivePage(AppListModel::STATE_START);
442 break; 442 break;
443 case AppListModel::STATE_SEARCH_RESULTS: 443 case AppListModel::STATE_SEARCH_RESULTS:
444 GetSearchBoxView()->ClearSearch(); 444 GetSearchBoxView()->ClearSearch();
445 ShowSearchResults(false); 445 ShowSearchResults(false);
446 break; 446 break;
447 case AppListModel::INVALID_STATE: 447 case AppListModel::INVALID_STATE:
448 NOTREACHED(); 448 NOTREACHED();
449 break; 449 break;
450 } 450 }
451 return true; 451 return true;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } 547 }
548 548
549 void ContentsView::TransitionStarted() { 549 void ContentsView::TransitionStarted() {
550 } 550 }
551 551
552 void ContentsView::TransitionChanged() { 552 void ContentsView::TransitionChanged() {
553 UpdatePageBounds(); 553 UpdatePageBounds();
554 } 554 }
555 555
556 } // namespace app_list 556 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698