| OLD | NEW |
| 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" |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 | 666 |
| 667 void ProfileChooserView::ButtonPressed(views::Button* sender, | 667 void ProfileChooserView::ButtonPressed(views::Button* sender, |
| 668 const ui::Event& event) { | 668 const ui::Event& event) { |
| 669 // Disable button after clicking so that it doesn't get clicked twice and | 669 // Disable button after clicking so that it doesn't get clicked twice and |
| 670 // start a second action... which can crash Chrome. But don't disable if it | 670 // start a second action... which can crash Chrome. But don't disable if it |
| 671 // has no parent (like in tests) because that will also crash. | 671 // has no parent (like in tests) because that will also crash. |
| 672 if (sender->parent()) | 672 if (sender->parent()) |
| 673 sender->SetEnabled(false); | 673 sender->SetEnabled(false); |
| 674 | 674 |
| 675 if (sender == users_button_) { | 675 if (sender == users_button_) { |
| 676 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); | 676 // If this is a guest session, also close all the guest browser windows. |
| 677 if (browser_->profile()->IsGuestSession()) { |
| 678 chrome::ShowUserManager(base::FilePath()); |
| 679 profiles::CloseGuestProfileWindows(); |
| 680 } else { |
| 681 chrome::ShowUserManager(browser_->profile()->GetPath()); |
| 682 } |
| 677 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); | 683 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); |
| 678 // If this is a guest session, also close all the guest browser windows. | |
| 679 if (browser_->profile()->IsGuestSession()) | |
| 680 profiles::CloseGuestProfileWindows(); | |
| 681 } else if (sender == go_incognito_button_) { | 684 } else if (sender == go_incognito_button_) { |
| 682 DCHECK(ShouldShowGoIncognito()); | 685 DCHECK(ShouldShowGoIncognito()); |
| 683 chrome::NewIncognitoWindow(browser_); | 686 chrome::NewIncognitoWindow(browser_); |
| 684 } else if (sender == lock_button_) { | 687 } else if (sender == lock_button_) { |
| 685 profiles::LockProfile(browser_->profile()); | 688 profiles::LockProfile(browser_->profile()); |
| 686 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); | 689 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); |
| 687 } else if (sender == auth_error_email_button_) { | 690 } else if (sender == auth_error_email_button_) { |
| 688 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); | 691 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); |
| 689 } else if (sender == tutorial_sync_settings_ok_button_) { | 692 } else if (sender == tutorial_sync_settings_ok_button_) { |
| 690 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 693 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 716 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 719 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
| 717 } else if (current_profile_photo_ && | 720 } else if (current_profile_photo_ && |
| 718 sender == current_profile_photo_->change_photo_button()) { | 721 sender == current_profile_photo_->change_photo_button()) { |
| 719 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 722 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
| 720 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | 723 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
| 721 } else if (sender == signin_current_profile_link_) { | 724 } else if (sender == signin_current_profile_link_) { |
| 722 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); | 725 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); |
| 723 } else if (sender == add_person_button_) { | 726 } else if (sender == add_person_button_) { |
| 724 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 727 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
| 725 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); | 728 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); |
| 726 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); | 729 chrome::ShowUserManager(browser_->profile()->GetPath()); |
| 727 } else if (sender == disconnect_button_) { | 730 } else if (sender == disconnect_button_) { |
| 728 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 731 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
| 729 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); | 732 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); |
| 730 chrome::ShowSettings(browser_); | 733 chrome::ShowSettings(browser_); |
| 731 } else if (sender == switch_user_cancel_button_) { | 734 } else if (sender == switch_user_cancel_button_) { |
| 732 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 735 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
| 733 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 736 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
| 734 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); | 737 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); |
| 735 } else { | 738 } else { |
| 736 // Either one of the "other profiles", or one of the profile accounts | 739 // Either one of the "other profiles", or one of the profile accounts |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 | 970 |
| 968 // Adds links and buttons. | 971 // Adds links and buttons. |
| 969 views::ColumnSet* button_columns = layout->AddColumnSet(1); | 972 views::ColumnSet* button_columns = layout->AddColumnSet(1); |
| 970 button_columns->AddColumn(views::GridLayout::LEADING, | 973 button_columns->AddColumn(views::GridLayout::LEADING, |
| 971 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 974 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
| 972 button_columns->AddPaddingColumn( | 975 button_columns->AddPaddingColumn( |
| 973 1, views::kUnrelatedControlHorizontalSpacing); | 976 1, views::kUnrelatedControlHorizontalSpacing); |
| 974 button_columns->AddColumn(views::GridLayout::TRAILING, | 977 button_columns->AddColumn(views::GridLayout::TRAILING, |
| 975 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 978 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
| 976 | 979 |
| 977 *link = CreateLink(link_text, this); | |
| 978 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 979 (*link)->SetAutoColorReadabilityEnabled(false); | |
| 980 (*link)->SetEnabledColor(SK_ColorWHITE); | |
| 981 layout->StartRowWithPadding(1, 1, 0, views::kUnrelatedControlVerticalSpacing); | 980 layout->StartRowWithPadding(1, 1, 0, views::kUnrelatedControlVerticalSpacing); |
| 982 layout->AddView(*link); | 981 if (!link_text.empty()) { |
| 982 *link = CreateLink(link_text, this); |
| 983 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 984 (*link)->SetAutoColorReadabilityEnabled(false); |
| 985 (*link)->SetEnabledColor(SK_ColorWHITE); |
| 986 layout->AddView(*link); |
| 987 } else { |
| 988 layout->SkipColumns(1); |
| 989 } |
| 983 | 990 |
| 984 *button = new views::LabelButton(this, button_text); | 991 *button = new views::LabelButton(this, button_text); |
| 985 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 992 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 986 (*button)->SetStyle(views::Button::STYLE_BUTTON); | 993 (*button)->SetStyle(views::Button::STYLE_BUTTON); |
| 987 layout->AddView(*button); | 994 layout->AddView(*button); |
| 988 | 995 |
| 989 return view; | 996 return view; |
| 990 } | 997 } |
| 991 | 998 |
| 992 views::View* ProfileChooserView::CreateCurrentProfileView( | 999 views::View* ProfileChooserView::CreateCurrentProfileView( |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 TitleCard* title_card = new TitleCard( | 1408 TitleCard* title_card = new TitleCard( |
| 1402 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), | 1409 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), |
| 1403 this, &account_removal_cancel_button_); | 1410 this, &account_removal_cancel_button_); |
| 1404 return TitleCard::AddPaddedTitleCard(view, title_card, | 1411 return TitleCard::AddPaddedTitleCard(view, title_card, |
| 1405 kFixedAccountRemovalViewWidth); | 1412 kFixedAccountRemovalViewWidth); |
| 1406 } | 1413 } |
| 1407 | 1414 |
| 1408 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded( | 1415 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded( |
| 1409 bool tutorial_shown, const AvatarMenu::Item& avatar_item){ | 1416 bool tutorial_shown, const AvatarMenu::Item& avatar_item){ |
| 1410 Profile* profile = browser_->profile(); | 1417 Profile* profile = browser_->profile(); |
| 1411 if (!avatar_item.signed_in) { | |
| 1412 profile->GetPrefs()->SetInteger( | |
| 1413 prefs::kProfileAvatarTutorialShown, | |
| 1414 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); | |
| 1415 return NULL; | |
| 1416 } | |
| 1417 | 1418 |
| 1418 const int show_count = profile->GetPrefs()->GetInteger( | 1419 const int show_count = profile->GetPrefs()->GetInteger( |
| 1419 prefs::kProfileAvatarTutorialShown); | 1420 prefs::kProfileAvatarTutorialShown); |
| 1420 // Do not show the tutorial if user has dismissed it. | 1421 // Do not show the tutorial if user has dismissed it. |
| 1421 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax) | 1422 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
| 1422 return NULL; | 1423 return NULL; |
| 1423 | 1424 |
| 1424 if (!tutorial_shown) { | 1425 if (!tutorial_shown) { |
| 1425 if (show_count == signin_ui_util::kUpgradeWelcomeTutorialShowMax) | 1426 if (show_count == signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
| 1426 return NULL; | 1427 return NULL; |
| 1427 profile->GetPrefs()->SetInteger( | 1428 profile->GetPrefs()->SetInteger( |
| 1428 prefs::kProfileAvatarTutorialShown, show_count + 1); | 1429 prefs::kProfileAvatarTutorialShown, show_count + 1); |
| 1429 } | 1430 } |
| 1430 | |
| 1431 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | 1431 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
| 1432 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW); | 1432 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW); |
| 1433 | 1433 |
| 1434 // For local profiles, the "Not you" link doesn't make sense. |
| 1435 base::string16 link_message = avatar_item.signed_in ? |
| 1436 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name) : |
| 1437 base::string16(); |
| 1438 |
| 1434 return CreateTutorialView( | 1439 return CreateTutorialView( |
| 1435 profiles::TUTORIAL_MODE_WELCOME_UPGRADE, | 1440 profiles::TUTORIAL_MODE_WELCOME_UPGRADE, |
| 1436 l10n_util::GetStringUTF16( | 1441 l10n_util::GetStringUTF16( |
| 1437 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE), | 1442 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE), |
| 1438 l10n_util::GetStringUTF16( | 1443 l10n_util::GetStringUTF16( |
| 1439 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT), | 1444 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT), |
| 1440 l10n_util::GetStringFUTF16( | 1445 link_message, |
| 1441 IDS_PROFILES_NOT_YOU, avatar_item.name), | |
| 1442 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON), | 1446 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON), |
| 1443 &tutorial_not_you_link_, | 1447 &tutorial_not_you_link_, |
| 1444 &tutorial_see_whats_new_button_); | 1448 &tutorial_see_whats_new_button_); |
| 1445 } | 1449 } |
| 1446 | 1450 |
| 1447 views::View* ProfileChooserView::CreateSigninConfirmationView(){ | 1451 views::View* ProfileChooserView::CreateSigninConfirmationView(){ |
| 1448 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 1452 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
| 1449 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_VIEW); | 1453 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_VIEW); |
| 1450 | 1454 |
| 1451 return CreateTutorialView( | 1455 return CreateTutorialView( |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1524 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 1521 IncognitoModePrefs::DISABLED; | 1525 IncognitoModePrefs::DISABLED; |
| 1522 return incognito_available && !browser_->profile()->IsGuestSession(); | 1526 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 1523 } | 1527 } |
| 1524 | 1528 |
| 1525 void ProfileChooserView::PostActionPerformed( | 1529 void ProfileChooserView::PostActionPerformed( |
| 1526 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1530 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 1527 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1531 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 1528 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1532 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 1529 } | 1533 } |
| OLD | NEW |