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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 422443008: New avatar menu: Don't show "Go incognito" if incognito is disabled by policy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac Created 6 years, 4 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
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/lifetime/application_lifetime.h" 10 #include "chrome/browser/lifetime/application_lifetime.h"
11 #include "chrome/browser/prefs/incognito_mode_prefs.h"
11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 12 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
12 #include "chrome/browser/profiles/profile_info_cache.h" 13 #include "chrome/browser/profiles/profile_info_cache.h"
13 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/profiles/profile_metrics.h" 15 #include "chrome/browser/profiles/profile_metrics.h"
15 #include "chrome/browser/profiles/profile_window.h" 16 #include "chrome/browser/profiles/profile_window.h"
16 #include "chrome/browser/profiles/profiles_state.h" 17 #include "chrome/browser/profiles/profiles_state.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_header_helper.h" 19 #include "chrome/browser/signin/signin_header_helper.h"
19 #include "chrome/browser/signin/signin_manager_factory.h" 20 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/signin/signin_promo.h" 21 #include "chrome/browser/signin/signin_promo.h"
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 // has no parent (like in tests) because that will also crash. 655 // has no parent (like in tests) because that will also crash.
655 if (sender->parent()) 656 if (sender->parent())
656 sender->SetEnabled(false); 657 sender->SetEnabled(false);
657 658
658 if (sender == users_button_) { 659 if (sender == users_button_) {
659 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); 660 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
660 // If this is a guest session, also close all the guest browser windows. 661 // If this is a guest session, also close all the guest browser windows.
661 if (browser_->profile()->IsGuestSession()) 662 if (browser_->profile()->IsGuestSession())
662 profiles::CloseGuestProfileWindows(); 663 profiles::CloseGuestProfileWindows();
663 } else if (sender == go_incognito_button_) { 664 } else if (sender == go_incognito_button_) {
664 DCHECK(!browser_->profile()->IsGuestSession()); 665 DCHECK(ShouldShowGoIncognito());
665 chrome::NewIncognitoWindow(browser_); 666 chrome::NewIncognitoWindow(browser_);
666 } else if (sender == lock_button_) { 667 } else if (sender == lock_button_) {
667 profiles::LockProfile(browser_->profile()); 668 profiles::LockProfile(browser_->profile());
668 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); 669 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK);
669 } else if (sender == auth_error_email_button_) { 670 } else if (sender == auth_error_email_button_) {
670 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); 671 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get());
671 } else if (sender == tutorial_ok_button_) { 672 } else if (sender == tutorial_ok_button_) {
672 // If the user manually dismissed the tutorial, never show it again by 673 // If the user manually dismissed the tutorial, never show it again by
673 // setting the number of times shown to the maximum plus 1, so that later we 674 // setting the number of times shown to the maximum plus 1, so that later we
674 // could distinguish between the dismiss case and the case when the tutorial 675 // could distinguish between the dismiss case and the case when the tutorial
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 return true; 819 return true;
819 820
820 profiles::UpdateProfileName(profile, new_profile_name); 821 profiles::UpdateProfileName(profile, new_profile_name);
821 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); 822 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME);
822 current_profile_name_->ShowReadOnlyView(); 823 current_profile_name_->ShowReadOnlyView();
823 return true; 824 return true;
824 } 825 }
825 return false; 826 return false;
826 } 827 }
827 828
828 void ProfileChooserView::PostActionPerformed( 829 void ProfileChooserView::PostActionPerformed(
msw 2014/08/04 17:09:40 nit: please reorder this definition to match its d
Marc Treib 2014/08/05 08:21:33 Done.
829 ProfileMetrics::ProfileDesktopMenu action_performed) { 830 ProfileMetrics::ProfileDesktopMenu action_performed) {
830 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 831 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
831 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 832 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
832 } 833 }
833 834
834 views::View* ProfileChooserView::CreateProfileChooserView( 835 views::View* ProfileChooserView::CreateProfileChooserView(
835 AvatarMenu* avatar_menu, 836 AvatarMenu* avatar_menu,
836 profiles::TutorialMode last_tutorial_mode) { 837 profiles::TutorialMode last_tutorial_mode) {
837 // TODO(guohui, noms): the view should be customized based on whether new 838 // TODO(guohui, noms): the view should be customized based on whether new
838 // profile management preview is enabled or not. 839 // profile management preview is enabled or not.
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : 1236 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) :
1236 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); 1237 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON);
1237 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1238 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1238 users_button_ = new BackgroundColorHoverButton( 1239 users_button_ = new BackgroundColorHoverButton(
1239 this, 1240 this,
1240 text, 1241 text,
1241 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_AVATAR)); 1242 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_AVATAR));
1242 layout->StartRow(1, 0); 1243 layout->StartRow(1, 0);
1243 layout->AddView(users_button_); 1244 layout->AddView(users_button_);
1244 1245
1245 if (!browser_->profile()->IsGuestSession()) { 1246 if (ShouldShowGoIncognito()) {
1246 layout->StartRow(1, 0); 1247 layout->StartRow(1, 0);
1247 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1248 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1248 1249
1249 // TODO(noms): Use the correct incognito icon when it's available. 1250 // TODO(noms): Use the correct incognito icon when it's available.
1250 go_incognito_button_ = new BackgroundColorHoverButton( 1251 go_incognito_button_ = new BackgroundColorHoverButton(
1251 this, 1252 this,
1252 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), 1253 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON),
1253 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_AVATAR)); 1254 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_AVATAR));
1254 layout->StartRow(1, 0); 1255 layout->StartRow(1, 0);
1255 layout->AddView(go_incognito_button_); 1256 layout->AddView(go_incognito_button_);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 gfx::ALIGN_CENTER); 1527 gfx::ALIGN_CENTER);
1527 layout->StartRowWithPadding( 1528 layout->StartRowWithPadding(
1528 1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1529 1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1529 layout->AddView(end_preview_and_relaunch_button_); 1530 layout->AddView(end_preview_and_relaunch_button_);
1530 1531
1531 TitleCard* title_card = new TitleCard( 1532 TitleCard* title_card = new TitleCard(
1532 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); 1533 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_);
1533 return TitleCard::AddPaddedTitleCard( 1534 return TitleCard::AddPaddedTitleCard(
1534 view, title_card, kFixedAccountRemovalViewWidth); 1535 view, title_card, kFixedAccountRemovalViewWidth);
1535 } 1536 }
1537
1538 bool ProfileChooserView::ShouldShowGoIncognito() const {
1539 bool incognito_available =
1540 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1541 IncognitoModePrefs::DISABLED;
1542 return incognito_available && !browser_->profile()->IsGuestSession();
1543 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698