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