Chromium Code Reviews| 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), | |
| 422 tutorial_mode_(TUTORIAL_MODE_NONE) { | 421 tutorial_mode_(TUTORIAL_MODE_NONE) { |
| 423 // Reset the default margins inherited from the BubbleDelegateView. | 422 // Reset the default margins inherited from the BubbleDelegateView. |
| 424 set_margins(gfx::Insets()); | 423 set_margins(gfx::Insets()); |
| 425 | 424 |
| 425 if (view_mode == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT_FROM_HEADER) { | |
| 426 view_mode = BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; | |
|
sky
2014/05/13 16:34:37
Can you set both view_mode_ and opened_from_header
Mike Lerman
2014/05/13 16:57:55
Done.
| |
| 427 opened_from_header_ = true; | |
| 428 } else { | |
| 429 opened_from_header_ = false; | |
| 430 } | |
| 431 view_mode_ = view_mode; | |
| 432 | |
| 426 ResetView(); | 433 ResetView(); |
| 427 | 434 |
| 428 avatar_menu_.reset(new AvatarMenu( | 435 avatar_menu_.reset(new AvatarMenu( |
| 429 &g_browser_process->profile_manager()->GetProfileInfoCache(), | 436 &g_browser_process->profile_manager()->GetProfileInfoCache(), |
| 430 this, | 437 this, |
| 431 browser_)); | 438 browser_)); |
| 432 avatar_menu_->RebuildMenu(); | 439 avatar_menu_->RebuildMenu(); |
| 433 | 440 |
| 434 ProfileOAuth2TokenService* oauth2_token_service = | 441 ProfileOAuth2TokenService* oauth2_token_service = |
| 435 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 442 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
| 436 if (oauth2_token_service) | 443 if (oauth2_token_service) |
| 437 oauth2_token_service->AddObserver(this); | 444 oauth2_token_service->AddObserver(this); |
| 445 | |
| 446 opened_from_header_ = (view_mode == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); | |
| 438 } | 447 } |
| 439 | 448 |
| 440 ProfileChooserView::~ProfileChooserView() { | 449 ProfileChooserView::~ProfileChooserView() { |
| 441 ProfileOAuth2TokenService* oauth2_token_service = | 450 ProfileOAuth2TokenService* oauth2_token_service = |
| 442 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 451 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
| 443 if (oauth2_token_service) | 452 if (oauth2_token_service) |
| 444 oauth2_token_service->RemoveObserver(this); | 453 oauth2_token_service->RemoveObserver(this); |
| 445 } | 454 } |
| 446 | 455 |
| 447 void ProfileChooserView::ResetView() { | 456 void ProfileChooserView::ResetView() { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 // has no parent (like in tests) because that will also crash. | 567 // has no parent (like in tests) because that will also crash. |
| 559 if (sender->parent()) | 568 if (sender->parent()) |
| 560 sender->SetEnabled(false); | 569 sender->SetEnabled(false); |
| 561 | 570 |
| 562 if (sender == users_button_) { | 571 if (sender == users_button_) { |
| 563 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); | 572 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); |
| 564 // If this is a guest session, also close all the guest browser windows. | 573 // If this is a guest session, also close all the guest browser windows. |
| 565 if (browser_->profile()->IsGuestSession()) | 574 if (browser_->profile()->IsGuestSession()) |
| 566 profiles::CloseGuestProfileWindows(); | 575 profiles::CloseGuestProfileWindows(); |
| 567 } else if (sender == lock_button_) { | 576 } else if (sender == lock_button_) { |
| 577 ProfileMetrics::LogProfileDesktopSignout( | |
| 578 ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK, opened_from_header_); | |
| 568 profiles::LockProfile(browser_->profile()); | 579 profiles::LockProfile(browser_->profile()); |
| 569 } else if (sender == tutorial_ok_button_) { | 580 } else if (sender == tutorial_ok_button_) { |
| 570 // If the user manually dismissed the tutorial, never show it again by | 581 // 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 | 582 // 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 | 583 // could distinguish between the dismiss case and the case when the tutorial |
| 573 // is indeed shown for the maximum number of times. | 584 // is indeed shown for the maximum number of times. |
| 574 browser_->profile()->GetPrefs()->SetInteger( | 585 browser_->profile()->GetPrefs()->SetInteger( |
| 575 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); | 586 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); |
| 576 | 587 |
| 577 ProfileMetrics::LogProfileUpgradeEnrollment( | 588 ProfileMetrics::LogProfileUpgradeEnrollment( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 if (switches::IsNewProfileManagement()) | 623 if (switches::IsNewProfileManagement()) |
| 613 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); | 624 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); |
| 614 else | 625 else |
| 615 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); | 626 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); |
| 616 } else { | 627 } else { |
| 617 // Either one of the "other profiles", or one of the profile accounts | 628 // Either one of the "other profiles", or one of the profile accounts |
| 618 // buttons was pressed. | 629 // buttons was pressed. |
| 619 ButtonIndexes::const_iterator profile_match = | 630 ButtonIndexes::const_iterator profile_match = |
| 620 open_other_profile_indexes_map_.find(sender); | 631 open_other_profile_indexes_map_.find(sender); |
| 621 if (profile_match != open_other_profile_indexes_map_.end()) { | 632 if (profile_match != open_other_profile_indexes_map_.end()) { |
| 633 ProfileMetrics::LogProfileDesktopSignout( | |
| 634 ProfileMetrics::PROFILE_DESKTOP_MENU_SWITCH, opened_from_header_); | |
| 622 avatar_menu_->SwitchToProfile( | 635 avatar_menu_->SwitchToProfile( |
| 623 profile_match->second, | 636 profile_match->second, |
| 624 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, | 637 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, |
| 625 ProfileMetrics::SWITCH_PROFILE_ICON); | 638 ProfileMetrics::SWITCH_PROFILE_ICON); |
| 626 } else { | 639 } else { |
| 627 // This was a profile accounts button. | 640 // This was a profile accounts button. |
| 641 ProfileMetrics::LogProfileDesktopSignout( | |
| 642 ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT, | |
| 643 opened_from_header_); | |
| 628 AccountButtonIndexes::const_iterator account_match = | 644 AccountButtonIndexes::const_iterator account_match = |
| 629 current_profile_accounts_map_.find(sender); | 645 current_profile_accounts_map_.find(sender); |
| 630 DCHECK(account_match != current_profile_accounts_map_.end()); | 646 DCHECK(account_match != current_profile_accounts_map_.end()); |
| 631 account_id_to_remove_ = account_match->second; | 647 account_id_to_remove_ = account_match->second; |
| 632 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); | 648 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); |
| 633 } | 649 } |
| 634 } | 650 } |
| 635 } | 651 } |
| 636 | 652 |
| 637 void ProfileChooserView::RemoveAccount() { | 653 void ProfileChooserView::RemoveAccount() { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 650 if (sender == manage_accounts_link_) { | 666 if (sender == manage_accounts_link_) { |
| 651 // This link can either mean show/hide the account management view, | 667 // This link can either mean show/hide the account management view, |
| 652 // depending on which view it is displayed. ShowView() will DCHECK if | 668 // depending on which view it is displayed. ShowView() will DCHECK if |
| 653 // the account management view is displayed for non signed-in users. | 669 // the account management view is displayed for non signed-in users. |
| 654 ShowView( | 670 ShowView( |
| 655 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? | 671 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? |
| 656 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : | 672 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
| 657 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, | 673 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, |
| 658 avatar_menu_.get()); | 674 avatar_menu_.get()); |
| 659 } else if (sender == add_account_link_) { | 675 } else if (sender == add_account_link_) { |
| 676 ProfileMetrics::LogProfileDesktopSignout( | |
| 677 ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT, opened_from_header_); | |
| 660 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 678 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
| 661 } else if (sender == tutorial_learn_more_link_) { | 679 } else if (sender == tutorial_learn_more_link_) { |
| 662 ProfileMetrics::LogProfileUpgradeEnrollment( | 680 ProfileMetrics::LogProfileUpgradeEnrollment( |
| 663 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); | 681 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); |
| 664 // TODO(guohui): update |learn_more_url| once it is decided. | 682 // TODO(guohui): update |learn_more_url| once it is decided. |
| 665 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); | 683 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); |
| 666 chrome::NavigateParams params( | 684 chrome::NavigateParams params( |
| 667 browser_->profile(), | 685 browser_->profile(), |
| 668 lear_more_url, | 686 lear_more_url, |
| 669 content::PAGE_TRANSITION_LINK); | 687 content::PAGE_TRANSITION_LINK); |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1297 layout->StartRowWithPadding( | 1315 layout->StartRowWithPadding( |
| 1298 1, 0, 0, views::kUnrelatedControlVerticalSpacing); | 1316 1, 0, 0, views::kUnrelatedControlVerticalSpacing); |
| 1299 layout->AddView(end_preview_and_relaunch_button_); | 1317 layout->AddView(end_preview_and_relaunch_button_); |
| 1300 | 1318 |
| 1301 TitleCard* title_card = new TitleCard( | 1319 TitleCard* title_card = new TitleCard( |
| 1302 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); | 1320 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); |
| 1303 return TitleCard::AddPaddedTitleCard( | 1321 return TitleCard::AddPaddedTitleCard( |
| 1304 view, title_card, kFixedAccountRemovalViewWidth); | 1322 view, title_card, kFixedAccountRemovalViewWidth); |
| 1305 } | 1323 } |
| 1306 | 1324 |
| OLD | NEW |