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

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

Issue 683703002: Notify launcher page with onTransitionChanged event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@launcher_page_api_show_state_notify
Patch Set: nullptr like it's 1999 Created 6 years, 1 month 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 AppListViewDelegate* view_delegate) { 49 AppListViewDelegate* view_delegate) {
50 DCHECK(model); 50 DCHECK(model);
51 51
52 if (app_list::switches::IsExperimentalAppListEnabled()) { 52 if (app_list::switches::IsExperimentalAppListEnabled()) {
53 std::vector<views::View*> custom_page_views = 53 std::vector<views::View*> custom_page_views =
54 view_delegate->CreateCustomPageWebViews(GetLocalBounds().size()); 54 view_delegate->CreateCustomPageWebViews(GetLocalBounds().size());
55 for (std::vector<views::View*>::const_iterator it = 55 for (std::vector<views::View*>::const_iterator it =
56 custom_page_views.begin(); 56 custom_page_views.begin();
57 it != custom_page_views.end(); 57 it != custom_page_views.end();
58 ++it) { 58 ++it) {
59 AddLauncherPage(*it, IDR_APP_LIST_NOTIFICATIONS_ICON); 59 // Only the first launcher page should be the custom launcher page state.
60 if (it == custom_page_views.begin()) {
61 AddLauncherPage(*it,
62 IDR_APP_LIST_NOTIFICATIONS_ICON,
63 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE);
64 } else {
65 AddLauncherPage(*it, IDR_APP_LIST_NOTIFICATIONS_ICON);
66 }
60 } 67 }
61 68
62 start_page_view_ = new StartPageView(app_list_main_view_, view_delegate); 69 start_page_view_ = new StartPageView(app_list_main_view_, view_delegate);
63 AddLauncherPage( 70 AddLauncherPage(
64 start_page_view_, IDR_APP_LIST_SEARCH_ICON, AppListModel::STATE_START); 71 start_page_view_, IDR_APP_LIST_SEARCH_ICON, AppListModel::STATE_START);
65 } else { 72 } else {
66 search_results_view_ = 73 search_results_view_ =
67 new SearchResultListView(app_list_main_view_, view_delegate); 74 new SearchResultListView(app_list_main_view_, view_delegate);
68 AddLauncherPage( 75 AddLauncherPage(
69 search_results_view_, 0, AppListModel::STATE_SEARCH_RESULTS); 76 search_results_view_, 0, AppListModel::STATE_SEARCH_RESULTS);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 int ContentsView::GetPageIndexForState(AppListModel::State state) const { 137 int ContentsView::GetPageIndexForState(AppListModel::State state) const {
131 // Find the index of the view corresponding to the given state. 138 // Find the index of the view corresponding to the given state.
132 std::map<AppListModel::State, int>::const_iterator it = 139 std::map<AppListModel::State, int>::const_iterator it =
133 state_to_view_.find(state); 140 state_to_view_.find(state);
134 if (it == state_to_view_.end()) 141 if (it == state_to_view_.end())
135 return -1; 142 return -1;
136 143
137 return it->second; 144 return it->second;
138 } 145 }
139 146
147 AppListModel::State ContentsView::GetStateForPageIndex(int index) const {
148 std::map<int, AppListModel::State>::const_iterator it =
149 view_to_state_.find(index);
150 if (it == view_to_state_.end())
151 return AppListModel::INVALID_STATE;
152
153 return it->second;
154 }
155
140 int ContentsView::NumLauncherPages() const { 156 int ContentsView::NumLauncherPages() const {
141 return pagination_model_.total_pages(); 157 return pagination_model_.total_pages();
142 } 158 }
143 159
144 void ContentsView::SetActivePageInternal(int page_index, 160 void ContentsView::SetActivePageInternal(int page_index,
145 bool show_search_results) { 161 bool show_search_results) {
146 if (!show_search_results) 162 if (!show_search_results)
147 page_before_search_ = page_index; 163 page_before_search_ = page_index;
148 // Start animating to the new page. 164 // Start animating to the new page.
149 pagination_model_.SelectPage(page_index, true); 165 pagination_model_.SelectPage(page_index, true);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 372 }
357 373
358 void ContentsView::TransitionStarted() { 374 void ContentsView::TransitionStarted() {
359 } 375 }
360 376
361 void ContentsView::TransitionChanged() { 377 void ContentsView::TransitionChanged() {
362 UpdatePageBounds(); 378 UpdatePageBounds();
363 } 379 }
364 380
365 } // namespace app_list 381 } // namespace app_list
OLDNEW
« ui/app_list/views/app_list_view.cc ('K') | « ui/app_list/views/contents_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698