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 LOG(WARNING) << "Supervised user attempted to add/remove account"; | 666 LOG(WARNING) << "Supervised user attempted to add/remove account"; |
667 return; | 667 return; |
668 } | 668 } |
669 | 669 |
670 ResetView(); | 670 ResetView(); |
671 RemoveAllChildViews(true); | 671 RemoveAllChildViews(true); |
672 view_mode_ = view_to_display; | 672 view_mode_ = view_to_display; |
673 | 673 |
674 views::GridLayout* layout; | 674 views::GridLayout* layout; |
675 views::View* sub_view; | 675 views::View* sub_view; |
| 676 views::View* view_to_focus = nullptr; |
676 switch (view_mode_) { | 677 switch (view_mode_) { |
677 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: | 678 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
678 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: | 679 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
679 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: | 680 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: |
680 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); | 681 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); |
681 sub_view = CreateGaiaSigninView(); | 682 sub_view = CreateGaiaSigninView(&view_to_focus); |
682 break; | 683 break; |
683 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: | 684 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
684 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); | 685 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); |
685 sub_view = CreateAccountRemovalView(); | 686 sub_view = CreateAccountRemovalView(); |
686 break; | 687 break; |
687 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 688 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
688 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 689 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
689 sub_view = CreateSwitchUserView(); | 690 sub_view = CreateSwitchUserView(); |
690 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 691 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
691 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 692 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
(...skipping 13 matching lines...) Expand all Loading... |
705 profile_bubble_->set_close_on_deactivate(false); | 706 profile_bubble_->set_close_on_deactivate(false); |
706 } else { | 707 } else { |
707 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); | 708 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); |
708 } | 709 } |
709 | 710 |
710 layout->StartRow(1, 0); | 711 layout->StartRow(1, 0); |
711 layout->AddView(sub_view); | 712 layout->AddView(sub_view); |
712 Layout(); | 713 Layout(); |
713 if (GetBubbleFrameView()) | 714 if (GetBubbleFrameView()) |
714 SizeToContents(); | 715 SizeToContents(); |
| 716 if (view_to_focus) |
| 717 view_to_focus->RequestFocus(); |
715 } | 718 } |
716 | 719 |
717 void ProfileChooserView::WindowClosing() { | 720 void ProfileChooserView::WindowClosing() { |
718 DCHECK_EQ(profile_bubble_, this); | 721 DCHECK_EQ(profile_bubble_, this); |
719 profile_bubble_ = NULL; | 722 profile_bubble_ = NULL; |
720 | 723 |
721 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { | 724 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { |
722 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 725 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
723 SyncConfirmationUIClosed(false /* configure_sync_first */); | 726 SyncConfirmationUIClosed(false /* configure_sync_first */); |
724 } | 727 } |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 0, kDeleteButtonWidth, kButtonHeight); | 1496 0, kDeleteButtonWidth, kButtonHeight); |
1494 | 1497 |
1495 email_button->set_notify_enter_exit_on_child(true); | 1498 email_button->set_notify_enter_exit_on_child(true); |
1496 email_button->AddChildView(delete_button); | 1499 email_button->AddChildView(delete_button); |
1497 | 1500 |
1498 // Save the original email address, as the button text could be elided. | 1501 // Save the original email address, as the button text could be elided. |
1499 delete_account_button_map_[delete_button] = account_id; | 1502 delete_account_button_map_[delete_button] = account_id; |
1500 } | 1503 } |
1501 } | 1504 } |
1502 | 1505 |
1503 views::View* ProfileChooserView::CreateGaiaSigninView() { | 1506 views::View* ProfileChooserView::CreateGaiaSigninView( |
| 1507 views::View** signin_content_view) { |
1504 GURL url; | 1508 GURL url; |
1505 int message_id; | 1509 int message_id; |
1506 | 1510 |
1507 switch (view_mode_) { | 1511 switch (view_mode_) { |
1508 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: | 1512 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
1509 url = signin::GetPromoURL(signin_metrics::SOURCE_AVATAR_BUBBLE_SIGN_IN, | 1513 url = signin::GetPromoURL(signin_metrics::SOURCE_AVATAR_BUBBLE_SIGN_IN, |
1510 false /* auto_close */, | 1514 false /* auto_close */, |
1511 true /* is_constrained */); | 1515 true /* is_constrained */); |
1512 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; | 1516 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; |
1513 break; | 1517 break; |
(...skipping 23 matching lines...) Expand all Loading... |
1537 web_view->GetWebContents()->SetDelegate(this); | 1541 web_view->GetWebContents()->SetDelegate(this); |
1538 web_view->SetPreferredSize( | 1542 web_view->SetPreferredSize( |
1539 gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight)); | 1543 gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight)); |
1540 content::RenderWidgetHostView* rwhv = | 1544 content::RenderWidgetHostView* rwhv = |
1541 web_view->GetWebContents()->GetRenderWidgetHostView(); | 1545 web_view->GetWebContents()->GetRenderWidgetHostView(); |
1542 if (rwhv) | 1546 if (rwhv) |
1543 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); | 1547 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); |
1544 TitleCard* title_card = new TitleCard(l10n_util::GetStringUTF16(message_id), | 1548 TitleCard* title_card = new TitleCard(l10n_util::GetStringUTF16(message_id), |
1545 this, | 1549 this, |
1546 &gaia_signin_cancel_button_); | 1550 &gaia_signin_cancel_button_); |
| 1551 if (signin_content_view) |
| 1552 *signin_content_view = web_view; |
1547 return TitleCard::AddPaddedTitleCard( | 1553 return TitleCard::AddPaddedTitleCard( |
1548 web_view, title_card, kFixedGaiaViewWidth); | 1554 web_view, title_card, kFixedGaiaViewWidth); |
1549 } | 1555 } |
1550 | 1556 |
1551 views::View* ProfileChooserView::CreateAccountRemovalView() { | 1557 views::View* ProfileChooserView::CreateAccountRemovalView() { |
1552 views::View* view = new views::View(); | 1558 views::View* view = new views::View(); |
1553 views::GridLayout* layout = CreateSingleColumnLayout( | 1559 views::GridLayout* layout = CreateSingleColumnLayout( |
1554 view, kFixedAccountRemovalViewWidth - 2 * views::kButtonHEdgeMarginNew); | 1560 view, kFixedAccountRemovalViewWidth - 2 * views::kButtonHEdgeMarginNew); |
1555 layout->SetInsets(0, | 1561 layout->SetInsets(0, |
1556 views::kButtonHEdgeMarginNew, | 1562 views::kButtonHEdgeMarginNew, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1749 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1744 IncognitoModePrefs::DISABLED; | 1750 IncognitoModePrefs::DISABLED; |
1745 return incognito_available && !browser_->profile()->IsGuestSession(); | 1751 return incognito_available && !browser_->profile()->IsGuestSession(); |
1746 } | 1752 } |
1747 | 1753 |
1748 void ProfileChooserView::PostActionPerformed( | 1754 void ProfileChooserView::PostActionPerformed( |
1749 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1755 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1750 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1756 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1751 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1757 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1752 } | 1758 } |
OLD | NEW |