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

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

Issue 968733002: Remove duplicate launcher page switching logic in AppListMainView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_set_enabled
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list_main_view.h" 5 #include "ui/app_list/views/app_list_main_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 parent()->SchedulePaint(); 244 parent()->SchedulePaint();
245 } 245 }
246 246
247 bool AppListMainView::ShouldShowCustomLauncherPage() const { 247 bool AppListMainView::ShouldShowCustomLauncherPage() const {
248 return contents_view_->custom_page_view() && 248 return contents_view_->custom_page_view() &&
249 model_->custom_launcher_page_enabled() && 249 model_->custom_launcher_page_enabled() &&
250 model_->search_engine_is_google(); 250 model_->search_engine_is_google();
251 } 251 }
252 252
253 void AppListMainView::UpdateCustomLauncherPageVisibility() { 253 void AppListMainView::UpdateCustomLauncherPageVisibility() {
254 if (ShouldShowCustomLauncherPage()) {
255 // Make the custom page view visible again.
256 contents_view_->custom_page_view()->SetVisible(true);
257 } else if (contents_view_->IsStateActive(
258 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)) {
259 // Animate to the start page if currently on the custom page view. The view
260 // will hide on animation completion.
261 contents_view_->SetActivePage(
262 contents_view_->GetPageIndexForState(AppListModel::STATE_START));
263 } else {
264 // Hide the view immediately otherwise.
265 contents_view_->custom_page_view()->SetVisible(false);
266 }
267 }
268
269 void AppListMainView::OnCustomLauncherPageEnabledStateChanged(bool enabled) {
270 views::View* custom_page = contents_view_->custom_page_view(); 254 views::View* custom_page = contents_view_->custom_page_view();
271 if (!custom_page) 255 if (!custom_page)
272 return; 256 return;
273 257
274 if (ShouldShowCustomLauncherPage()) { 258 if (ShouldShowCustomLauncherPage()) {
275 // Make the custom page view visible again. 259 // Make the custom page view visible again.
276 custom_page->SetVisible(true); 260 custom_page->SetVisible(true);
277 } else if (contents_view_->IsStateActive( 261 } else if (contents_view_->IsStateActive(
278 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)) { 262 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)) {
279 // Animate to the start page if currently on the custom page view. The view 263 // Animate to the start page if currently on the custom page view. The view
280 // will hide on animation completion. 264 // will hide on animation completion.
281 contents_view_->SetActivePage( 265 contents_view_->SetActivePage(
282 contents_view_->GetPageIndexForState(AppListModel::STATE_START)); 266 contents_view_->GetPageIndexForState(AppListModel::STATE_START));
283 } else { 267 } else {
284 // Hide the view immediately otherwise. 268 // Hide the view immediately otherwise.
285 custom_page->SetVisible(false); 269 custom_page->SetVisible(false);
286 } 270 }
287 } 271 }
288 272
273 void AppListMainView::OnCustomLauncherPageEnabledStateChanged(bool enabled) {
274 UpdateCustomLauncherPageVisibility();
275 }
276
289 void AppListMainView::OnSearchEngineIsGoogleChanged(bool is_google) { 277 void AppListMainView::OnSearchEngineIsGoogleChanged(bool is_google) {
290 if (contents_view_->custom_page_view()) 278 if (contents_view_->custom_page_view())
291 OnCustomLauncherPageEnabledStateChanged(is_google); 279 UpdateCustomLauncherPageVisibility();
292 280
293 if (contents_view_->start_page_view()) { 281 if (contents_view_->start_page_view()) {
294 contents_view_->start_page_view()->instant_container()->SetVisible( 282 contents_view_->start_page_view()->instant_container()->SetVisible(
295 is_google); 283 is_google);
296 } 284 }
297 } 285 }
298 286
299 void AppListMainView::ActivateApp(AppListItem* item, int event_flags) { 287 void AppListMainView::ActivateApp(AppListItem* item, int event_flags) {
300 // TODO(jennyz): Activate the folder via AppListModel notification. 288 // TODO(jennyz): Activate the folder via AppListModel notification.
301 if (item->GetItemType() == AppListFolderItem::kItemType) 289 if (item->GetItemType() == AppListFolderItem::kItemType)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 contents_view_->search_results_page_view()->SetSelection(select); 323 contents_view_->search_results_page_view()->SetSelection(select);
336 } 324 }
337 325
338 void AppListMainView::OnResultInstalled(SearchResult* result) { 326 void AppListMainView::OnResultInstalled(SearchResult* result) {
339 // Clears the search to show the apps grid. The last installed app 327 // Clears the search to show the apps grid. The last installed app
340 // should be highlighted and made visible already. 328 // should be highlighted and made visible already.
341 search_box_view_->ClearSearch(); 329 search_box_view_->ClearSearch();
342 } 330 }
343 331
344 } // namespace app_list 332 } // namespace app_list
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698