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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 profile_bubble_->GetWidget()->Close(); | 411 profile_bubble_->GetWidget()->Close(); |
412 } | 412 } |
413 | 413 |
414 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 414 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
415 views::BubbleBorder::Arrow arrow, | 415 views::BubbleBorder::Arrow arrow, |
416 const gfx::Rect& anchor_rect, | 416 const gfx::Rect& anchor_rect, |
417 Browser* browser, | 417 Browser* browser, |
418 BubbleViewMode view_mode) | 418 BubbleViewMode view_mode) |
419 : BubbleDelegateView(anchor_view, arrow), | 419 : BubbleDelegateView(anchor_view, arrow), |
420 browser_(browser), | 420 browser_(browser), |
421 view_mode_(view_mode), | 421 tutorial_mode_(TUTORIAL_MODE_NONE), |
422 tutorial_mode_(TUTORIAL_MODE_NONE) { | 422 view_mode_(view_mode == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT_FROM_GAIA ? |
| 423 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : view_mode), |
| 424 opened_from_gaia_( |
| 425 view_mode == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT_FROM_GAIA) { |
423 // Reset the default margins inherited from the BubbleDelegateView. | 426 // Reset the default margins inherited from the BubbleDelegateView. |
424 set_margins(gfx::Insets()); | 427 set_margins(gfx::Insets()); |
425 | 428 |
426 ResetView(); | 429 ResetView(); |
427 | 430 |
428 avatar_menu_.reset(new AvatarMenu( | 431 avatar_menu_.reset(new AvatarMenu( |
429 &g_browser_process->profile_manager()->GetProfileInfoCache(), | 432 &g_browser_process->profile_manager()->GetProfileInfoCache(), |
430 this, | 433 this, |
431 browser_)); | 434 browser_)); |
432 avatar_menu_->RebuildMenu(); | 435 avatar_menu_->RebuildMenu(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 // has no parent (like in tests) because that will also crash. | 561 // has no parent (like in tests) because that will also crash. |
559 if (sender->parent()) | 562 if (sender->parent()) |
560 sender->SetEnabled(false); | 563 sender->SetEnabled(false); |
561 | 564 |
562 if (sender == users_button_) { | 565 if (sender == users_button_) { |
563 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); | 566 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); |
564 // If this is a guest session, also close all the guest browser windows. | 567 // If this is a guest session, also close all the guest browser windows. |
565 if (browser_->profile()->IsGuestSession()) | 568 if (browser_->profile()->IsGuestSession()) |
566 profiles::CloseGuestProfileWindows(); | 569 profiles::CloseGuestProfileWindows(); |
567 } else if (sender == lock_button_) { | 570 } else if (sender == lock_button_) { |
| 571 ProfileMetrics::LogProfileDesktopSignout( |
| 572 ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK, opened_from_gaia_); |
568 profiles::LockProfile(browser_->profile()); | 573 profiles::LockProfile(browser_->profile()); |
569 } else if (sender == tutorial_ok_button_) { | 574 } else if (sender == tutorial_ok_button_) { |
570 // If the user manually dismissed the tutorial, never show it again by | 575 // If the user manually dismissed the tutorial, never show it again by |
571 // setting the number of times shown to the maximum plus 1, so that later we | 576 // setting the number of times shown to the maximum plus 1, so that later we |
572 // could distinguish between the dismiss case and the case when the tutorial | 577 // could distinguish between the dismiss case and the case when the tutorial |
573 // is indeed shown for the maximum number of times. | 578 // is indeed shown for the maximum number of times. |
574 browser_->profile()->GetPrefs()->SetInteger( | 579 browser_->profile()->GetPrefs()->SetInteger( |
575 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); | 580 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); |
576 | 581 |
577 ProfileMetrics::LogProfileUpgradeEnrollment( | 582 ProfileMetrics::LogProfileUpgradeEnrollment( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 // buttons was pressed. | 623 // buttons was pressed. |
619 ButtonIndexes::const_iterator profile_match = | 624 ButtonIndexes::const_iterator profile_match = |
620 open_other_profile_indexes_map_.find(sender); | 625 open_other_profile_indexes_map_.find(sender); |
621 if (profile_match != open_other_profile_indexes_map_.end()) { | 626 if (profile_match != open_other_profile_indexes_map_.end()) { |
622 avatar_menu_->SwitchToProfile( | 627 avatar_menu_->SwitchToProfile( |
623 profile_match->second, | 628 profile_match->second, |
624 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, | 629 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, |
625 ProfileMetrics::SWITCH_PROFILE_ICON); | 630 ProfileMetrics::SWITCH_PROFILE_ICON); |
626 } else { | 631 } else { |
627 // This was a profile accounts button. | 632 // This was a profile accounts button. |
| 633 ProfileMetrics::LogProfileDesktopSignout( |
| 634 ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT, |
| 635 opened_from_gaia_); |
628 AccountButtonIndexes::const_iterator account_match = | 636 AccountButtonIndexes::const_iterator account_match = |
629 current_profile_accounts_map_.find(sender); | 637 current_profile_accounts_map_.find(sender); |
630 DCHECK(account_match != current_profile_accounts_map_.end()); | 638 DCHECK(account_match != current_profile_accounts_map_.end()); |
631 account_id_to_remove_ = account_match->second; | 639 account_id_to_remove_ = account_match->second; |
632 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); | 640 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); |
633 } | 641 } |
634 } | 642 } |
635 } | 643 } |
636 | 644 |
637 void ProfileChooserView::RemoveAccount() { | 645 void ProfileChooserView::RemoveAccount() { |
(...skipping 12 matching lines...) Expand all Loading... |
650 if (sender == manage_accounts_link_) { | 658 if (sender == manage_accounts_link_) { |
651 // This link can either mean show/hide the account management view, | 659 // This link can either mean show/hide the account management view, |
652 // depending on which view it is displayed. ShowView() will DCHECK if | 660 // depending on which view it is displayed. ShowView() will DCHECK if |
653 // the account management view is displayed for non signed-in users. | 661 // the account management view is displayed for non signed-in users. |
654 ShowView( | 662 ShowView( |
655 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? | 663 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? |
656 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : | 664 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
657 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, | 665 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, |
658 avatar_menu_.get()); | 666 avatar_menu_.get()); |
659 } else if (sender == add_account_link_) { | 667 } else if (sender == add_account_link_) { |
| 668 ProfileMetrics::LogProfileDesktopSignout( |
| 669 ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT, opened_from_gaia_); |
660 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 670 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
661 } else if (sender == tutorial_learn_more_link_) { | 671 } else if (sender == tutorial_learn_more_link_) { |
662 ProfileMetrics::LogProfileUpgradeEnrollment( | 672 ProfileMetrics::LogProfileUpgradeEnrollment( |
663 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); | 673 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); |
664 // TODO(guohui): update |learn_more_url| once it is decided. | 674 // TODO(guohui): update |learn_more_url| once it is decided. |
665 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); | 675 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); |
666 chrome::NavigateParams params( | 676 chrome::NavigateParams params( |
667 browser_->profile(), | 677 browser_->profile(), |
668 lear_more_url, | 678 lear_more_url, |
669 content::PAGE_TRANSITION_LINK); | 679 content::PAGE_TRANSITION_LINK); |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 layout->StartRowWithPadding( | 1307 layout->StartRowWithPadding( |
1298 1, 0, 0, views::kUnrelatedControlVerticalSpacing); | 1308 1, 0, 0, views::kUnrelatedControlVerticalSpacing); |
1299 layout->AddView(end_preview_and_relaunch_button_); | 1309 layout->AddView(end_preview_and_relaunch_button_); |
1300 | 1310 |
1301 TitleCard* title_card = new TitleCard( | 1311 TitleCard* title_card = new TitleCard( |
1302 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); | 1312 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); |
1303 return TitleCard::AddPaddedTitleCard( | 1313 return TitleCard::AddPaddedTitleCard( |
1304 view, title_card, kFixedAccountRemovalViewWidth); | 1314 view, title_card, kFixedAccountRemovalViewWidth); |
1305 } | 1315 } |
1306 | 1316 |
OLD | NEW |