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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 profile_bubble_->GetWidget()->Show(); | 511 profile_bubble_->GetWidget()->Show(); |
512 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 512 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
513 } | 513 } |
514 | 514 |
515 // static | 515 // static |
516 bool ProfileChooserView::IsShowing() { | 516 bool ProfileChooserView::IsShowing() { |
517 return profile_bubble_ != NULL; | 517 return profile_bubble_ != NULL; |
518 } | 518 } |
519 | 519 |
520 // static | 520 // static |
| 521 ProfileChooserView::ShowingType ProfileChooserView::IsShowingInBrowser( |
| 522 const Browser* browser) { |
| 523 if (profile_bubble_ == nullptr) |
| 524 return IS_NOT_SHOWING; |
| 525 |
| 526 if (profile_bubble_->browser_ == browser || browser == nullptr) |
| 527 return IS_SHOWING; |
| 528 |
| 529 return IS_SHOWING_IN_ANOTHER_BROWSER; |
| 530 } |
| 531 |
| 532 // static |
521 void ProfileChooserView::Hide() { | 533 void ProfileChooserView::Hide() { |
522 if (IsShowing()) | 534 if (IsShowing()) |
523 profile_bubble_->GetWidget()->Close(); | 535 profile_bubble_->GetWidget()->Close(); |
524 } | 536 } |
525 | 537 |
526 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 538 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
527 views::BubbleBorder::Arrow arrow, | 539 views::BubbleBorder::Arrow arrow, |
528 Browser* browser, | 540 Browser* browser, |
529 profiles::BubbleViewMode view_mode, | 541 profiles::BubbleViewMode view_mode, |
530 profiles::TutorialMode tutorial_mode, | 542 profiles::TutorialMode tutorial_mode, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 691 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
680 break; | 692 break; |
681 default: | 693 default: |
682 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 694 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); |
683 sub_view = CreateProfileChooserView(avatar_menu); | 695 sub_view = CreateProfileChooserView(avatar_menu); |
684 } | 696 } |
685 // Clears tutorial mode for all non-profile-chooser views. | 697 // Clears tutorial mode for all non-profile-chooser views. |
686 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 698 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
687 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 699 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
688 | 700 |
| 701 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
| 702 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
| 703 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH || |
| 704 tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { |
| 705 profile_bubble_->set_close_on_deactivate(false); |
| 706 } else { |
| 707 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); |
| 708 } |
| 709 |
689 layout->StartRow(1, 0); | 710 layout->StartRow(1, 0); |
690 layout->AddView(sub_view); | 711 layout->AddView(sub_view); |
691 Layout(); | 712 Layout(); |
692 if (GetBubbleFrameView()) | 713 if (GetBubbleFrameView()) |
693 SizeToContents(); | 714 SizeToContents(); |
694 } | 715 } |
695 | 716 |
696 void ProfileChooserView::WindowClosing() { | 717 void ProfileChooserView::WindowClosing() { |
697 DCHECK_EQ(profile_bubble_, this); | 718 DCHECK_EQ(profile_bubble_, this); |
698 profile_bubble_ = NULL; | 719 profile_bubble_ = NULL; |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1725 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1705 IncognitoModePrefs::DISABLED; | 1726 IncognitoModePrefs::DISABLED; |
1706 return incognito_available && !browser_->profile()->IsGuestSession(); | 1727 return incognito_available && !browser_->profile()->IsGuestSession(); |
1707 } | 1728 } |
1708 | 1729 |
1709 void ProfileChooserView::PostActionPerformed( | 1730 void ProfileChooserView::PostActionPerformed( |
1710 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1731 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1711 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1732 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1712 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1733 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1713 } | 1734 } |
OLD | NEW |