| 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_HEADER ? |
| 423 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : view_mode), |
| 424 opened_from_header_( |
| 425 view_mode == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT_FROM_HEADER) { |
| 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_header_); |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 if (switches::IsNewProfileManagement()) | 617 if (switches::IsNewProfileManagement()) |
| 613 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); | 618 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); |
| 614 else | 619 else |
| 615 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); | 620 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); |
| 616 } else { | 621 } else { |
| 617 // Either one of the "other profiles", or one of the profile accounts | 622 // Either one of the "other profiles", or one of the profile accounts |
| 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()) { |
| 627 ProfileMetrics::LogProfileDesktopSignout( |
| 628 ProfileMetrics::PROFILE_DESKTOP_MENU_SWITCH, opened_from_header_); |
| 622 avatar_menu_->SwitchToProfile( | 629 avatar_menu_->SwitchToProfile( |
| 623 profile_match->second, | 630 profile_match->second, |
| 624 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, | 631 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, |
| 625 ProfileMetrics::SWITCH_PROFILE_ICON); | 632 ProfileMetrics::SWITCH_PROFILE_ICON); |
| 626 } else { | 633 } else { |
| 627 // This was a profile accounts button. | 634 // This was a profile accounts button. |
| 635 ProfileMetrics::LogProfileDesktopSignout( |
| 636 ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT, |
| 637 opened_from_header_); |
| 628 AccountButtonIndexes::const_iterator account_match = | 638 AccountButtonIndexes::const_iterator account_match = |
| 629 current_profile_accounts_map_.find(sender); | 639 current_profile_accounts_map_.find(sender); |
| 630 DCHECK(account_match != current_profile_accounts_map_.end()); | 640 DCHECK(account_match != current_profile_accounts_map_.end()); |
| 631 account_id_to_remove_ = account_match->second; | 641 account_id_to_remove_ = account_match->second; |
| 632 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); | 642 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); |
| 633 } | 643 } |
| 634 } | 644 } |
| 635 } | 645 } |
| 636 | 646 |
| 637 void ProfileChooserView::RemoveAccount() { | 647 void ProfileChooserView::RemoveAccount() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 650 if (sender == manage_accounts_link_) { | 660 if (sender == manage_accounts_link_) { |
| 651 // This link can either mean show/hide the account management view, | 661 // This link can either mean show/hide the account management view, |
| 652 // depending on which view it is displayed. ShowView() will DCHECK if | 662 // depending on which view it is displayed. ShowView() will DCHECK if |
| 653 // the account management view is displayed for non signed-in users. | 663 // the account management view is displayed for non signed-in users. |
| 654 ShowView( | 664 ShowView( |
| 655 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? | 665 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? |
| 656 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : | 666 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
| 657 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, | 667 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, |
| 658 avatar_menu_.get()); | 668 avatar_menu_.get()); |
| 659 } else if (sender == add_account_link_) { | 669 } else if (sender == add_account_link_) { |
| 670 ProfileMetrics::LogProfileDesktopSignout( |
| 671 ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT, opened_from_header_); |
| 660 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 672 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
| 661 } else if (sender == tutorial_learn_more_link_) { | 673 } else if (sender == tutorial_learn_more_link_) { |
| 662 ProfileMetrics::LogProfileUpgradeEnrollment( | 674 ProfileMetrics::LogProfileUpgradeEnrollment( |
| 663 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); | 675 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); |
| 664 // TODO(guohui): update |learn_more_url| once it is decided. | 676 // TODO(guohui): update |learn_more_url| once it is decided. |
| 665 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); | 677 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); |
| 666 chrome::NavigateParams params( | 678 chrome::NavigateParams params( |
| 667 browser_->profile(), | 679 browser_->profile(), |
| 668 lear_more_url, | 680 lear_more_url, |
| 669 content::PAGE_TRANSITION_LINK); | 681 content::PAGE_TRANSITION_LINK); |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 layout->StartRowWithPadding( | 1309 layout->StartRowWithPadding( |
| 1298 1, 0, 0, views::kUnrelatedControlVerticalSpacing); | 1310 1, 0, 0, views::kUnrelatedControlVerticalSpacing); |
| 1299 layout->AddView(end_preview_and_relaunch_button_); | 1311 layout->AddView(end_preview_and_relaunch_button_); |
| 1300 | 1312 |
| 1301 TitleCard* title_card = new TitleCard( | 1313 TitleCard* title_card = new TitleCard( |
| 1302 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); | 1314 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); |
| 1303 return TitleCard::AddPaddedTitleCard( | 1315 return TitleCard::AddPaddedTitleCard( |
| 1304 view, title_card, kFixedAccountRemovalViewWidth); | 1316 view, title_card, kFixedAccountRemovalViewWidth); |
| 1305 } | 1317 } |
| 1306 | 1318 |
| OLD | NEW |