| 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 | 594 |
| 595 // static | 595 // static |
| 596 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; | 596 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
| 597 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 597 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
| 598 | 598 |
| 599 // static | 599 // static |
| 600 void ProfileChooserView::ShowBubble( | 600 void ProfileChooserView::ShowBubble( |
| 601 profiles::BubbleViewMode view_mode, | 601 profiles::BubbleViewMode view_mode, |
| 602 profiles::TutorialMode tutorial_mode, | 602 profiles::TutorialMode tutorial_mode, |
| 603 const signin::ManageAccountsParams& manage_accounts_params, | 603 const signin::ManageAccountsParams& manage_accounts_params, |
| 604 signin_metrics::AccessPoint access_point, |
| 604 views::View* anchor_view, | 605 views::View* anchor_view, |
| 605 views::BubbleBorder::Arrow arrow, | 606 views::BubbleBorder::Arrow arrow, |
| 606 views::BubbleBorder::BubbleAlignment border_alignment, | 607 views::BubbleBorder::BubbleAlignment border_alignment, |
| 607 Browser* browser) { | 608 Browser* browser) { |
| 608 // Don't start creating the view if it would be an empty fast user switcher. | 609 // Don't start creating the view if it would be an empty fast user switcher. |
| 609 // It has to happen here to prevent the view system from creating an empty | 610 // It has to happen here to prevent the view system from creating an empty |
| 610 // container. | 611 // container. |
| 611 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && | 612 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && |
| 612 !profiles::HasProfileSwitchTargets(browser->profile())) { | 613 !profiles::HasProfileSwitchTargets(browser->profile())) { |
| 613 return; | 614 return; |
| 614 } | 615 } |
| 615 | 616 |
| 616 if (IsShowing()) { | 617 if (IsShowing()) { |
| 617 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { | 618 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { |
| 618 profile_bubble_->tutorial_mode_ = tutorial_mode; | 619 profile_bubble_->tutorial_mode_ = tutorial_mode; |
| 619 profile_bubble_->ShowViewFromMode(view_mode); | 620 profile_bubble_->ShowViewFromMode(view_mode); |
| 620 } | 621 } |
| 621 return; | 622 return; |
| 622 } | 623 } |
| 623 | 624 |
| 624 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser, | 625 profile_bubble_ = new ProfileChooserView( |
| 625 view_mode, tutorial_mode, manage_accounts_params.service_type); | 626 anchor_view, arrow, browser, view_mode, tutorial_mode, |
| 627 manage_accounts_params.service_type, access_point); |
| 626 views::BubbleDelegateView::CreateBubble(profile_bubble_); | 628 views::BubbleDelegateView::CreateBubble(profile_bubble_); |
| 627 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); | 629 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); |
| 628 profile_bubble_->SetAlignment(border_alignment); | 630 profile_bubble_->SetAlignment(border_alignment); |
| 629 profile_bubble_->GetWidget()->Show(); | 631 profile_bubble_->GetWidget()->Show(); |
| 630 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 632 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
| 631 } | 633 } |
| 632 | 634 |
| 633 // static | 635 // static |
| 634 bool ProfileChooserView::IsShowing() { | 636 bool ProfileChooserView::IsShowing() { |
| 635 return profile_bubble_ != NULL; | 637 return profile_bubble_ != NULL; |
| 636 } | 638 } |
| 637 | 639 |
| 638 // static | 640 // static |
| 639 void ProfileChooserView::Hide() { | 641 void ProfileChooserView::Hide() { |
| 640 if (IsShowing()) | 642 if (IsShowing()) |
| 641 profile_bubble_->GetWidget()->Close(); | 643 profile_bubble_->GetWidget()->Close(); |
| 642 } | 644 } |
| 643 | 645 |
| 644 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 646 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
| 645 views::BubbleBorder::Arrow arrow, | 647 views::BubbleBorder::Arrow arrow, |
| 646 Browser* browser, | 648 Browser* browser, |
| 647 profiles::BubbleViewMode view_mode, | 649 profiles::BubbleViewMode view_mode, |
| 648 profiles::TutorialMode tutorial_mode, | 650 profiles::TutorialMode tutorial_mode, |
| 649 signin::GAIAServiceType service_type) | 651 signin::GAIAServiceType service_type, |
| 652 signin_metrics::AccessPoint access_point) |
| 650 : BubbleDelegateView(anchor_view, arrow), | 653 : BubbleDelegateView(anchor_view, arrow), |
| 651 browser_(browser), | 654 browser_(browser), |
| 652 view_mode_(view_mode), | 655 view_mode_(view_mode), |
| 653 tutorial_mode_(tutorial_mode), | 656 tutorial_mode_(tutorial_mode), |
| 654 gaia_service_type_(service_type) { | 657 gaia_service_type_(service_type), |
| 658 access_point_(access_point) { |
| 655 // Reset the default margins inherited from the BubbleDelegateView. | 659 // Reset the default margins inherited from the BubbleDelegateView. |
| 656 // Add a small bottom inset so that the bubble's rounded corners show up. | 660 // Add a small bottom inset so that the bubble's rounded corners show up. |
| 657 set_margins(gfx::Insets(0, 0, 1, 0)); | 661 set_margins(gfx::Insets(0, 0, 1, 0)); |
| 658 ResetView(); | 662 ResetView(); |
| 659 | 663 |
| 660 avatar_menu_.reset(new AvatarMenu( | 664 avatar_menu_.reset(new AvatarMenu( |
| 661 &g_browser_process->profile_manager()->GetProfileInfoCache(), | 665 &g_browser_process->profile_manager()->GetProfileInfoCache(), |
| 662 this, | 666 this, |
| 663 browser_)); | 667 browser_)); |
| 664 avatar_menu_->RebuildMenu(); | 668 avatar_menu_->RebuildMenu(); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 BrowserWindow::AvatarBubbleMode converted_mode = | 840 BrowserWindow::AvatarBubbleMode converted_mode = |
| 837 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; | 841 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; |
| 838 if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN) { | 842 if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN) { |
| 839 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN; | 843 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN; |
| 840 } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) { | 844 } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) { |
| 841 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT; | 845 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT; |
| 842 } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { | 846 } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
| 843 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH; | 847 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH; |
| 844 } | 848 } |
| 845 | 849 |
| 846 browser_->window()->ShowModalSigninWindow(converted_mode); | 850 browser_->window()->ShowModalSigninWindow(converted_mode, access_point_); |
| 847 } else { | 851 } else { |
| 848 ShowView(mode, avatar_menu_.get()); | 852 ShowView(mode, avatar_menu_.get()); |
| 849 } | 853 } |
| 850 } | 854 } |
| 851 | 855 |
| 852 void ProfileChooserView::WindowClosing() { | 856 void ProfileChooserView::WindowClosing() { |
| 853 DCHECK_EQ(profile_bubble_, this); | 857 DCHECK_EQ(profile_bubble_, this); |
| 854 profile_bubble_ = NULL; | 858 profile_bubble_ = NULL; |
| 855 | 859 |
| 856 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { | 860 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 email_button->AddChildView(delete_button); | 1634 email_button->AddChildView(delete_button); |
| 1631 | 1635 |
| 1632 // Save the original email address, as the button text could be elided. | 1636 // Save the original email address, as the button text could be elided. |
| 1633 delete_account_button_map_[delete_button] = account_id; | 1637 delete_account_button_map_[delete_button] = account_id; |
| 1634 } | 1638 } |
| 1635 } | 1639 } |
| 1636 | 1640 |
| 1637 views::View* ProfileChooserView::CreateGaiaSigninView( | 1641 views::View* ProfileChooserView::CreateGaiaSigninView( |
| 1638 views::View** signin_content_view) { | 1642 views::View** signin_content_view) { |
| 1639 views::WebView* web_view = SigninViewController::CreateGaiaWebView( | 1643 views::WebView* web_view = SigninViewController::CreateGaiaWebView( |
| 1640 this, view_mode_, browser_->profile()); | 1644 this, view_mode_, browser_->profile(), access_point_); |
| 1641 | 1645 |
| 1642 int message_id; | 1646 int message_id; |
| 1643 switch (view_mode_) { | 1647 switch (view_mode_) { |
| 1644 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: | 1648 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
| 1645 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; | 1649 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; |
| 1646 break; | 1650 break; |
| 1647 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: | 1651 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
| 1648 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; | 1652 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; |
| 1649 break; | 1653 break; |
| 1650 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { | 1654 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1866 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 1863 IncognitoModePrefs::DISABLED; | 1867 IncognitoModePrefs::DISABLED; |
| 1864 return incognito_available && !browser_->profile()->IsGuestSession(); | 1868 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 1865 } | 1869 } |
| 1866 | 1870 |
| 1867 void ProfileChooserView::PostActionPerformed( | 1871 void ProfileChooserView::PostActionPerformed( |
| 1868 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1872 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 1869 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1873 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 1870 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1874 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 1871 } | 1875 } |
| OLD | NEW |