Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_chooser_view.h" | 5 #include "chrome/browser/ui/views/profile_chooser_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile_info_util.h" | 9 #include "chrome/browser/profiles/profile_info_util.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 784 views::GridLayout* layout = CreateSingleColumnLayout(view); | 784 views::GridLayout* layout = CreateSingleColumnLayout(view); |
| 785 layout->SetInsets(views::kButtonVEdgeMarginNew, | 785 layout->SetInsets(views::kButtonVEdgeMarginNew, |
| 786 views::kButtonHEdgeMarginNew, | 786 views::kButtonHEdgeMarginNew, |
| 787 views::kButtonVEdgeMarginNew, | 787 views::kButtonVEdgeMarginNew, |
| 788 views::kButtonHEdgeMarginNew); | 788 views::kButtonHEdgeMarginNew); |
| 789 | 789 |
| 790 Profile* profile = browser_->profile(); | 790 Profile* profile = browser_->profile(); |
| 791 std::string primary_account = | 791 std::string primary_account = |
| 792 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); | 792 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); |
| 793 DCHECK(!primary_account.empty()); | 793 DCHECK(!primary_account.empty()); |
| 794 std::vector<std::string> accounts( | 794 std::vector<std::string>accounts = |
| 795 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->GetAccounts()); | 795 profiles::GetSecondaryAccountsForProfile(profile, primary_account); |
| 796 DCHECK_EQ(1, std::count_if(accounts.begin(), accounts.end(), | |
| 797 std::bind1st(std::equal_to<std::string>(), | |
| 798 primary_account))); | |
| 799 | 796 |
| 800 // The primary account should always be listed first. However, the vector | 797 // The primary account should always be listed first. |
| 801 // returned by ProfileOAuth2TokenService::GetAccounts() will contain the | |
| 802 // primary account too. Ignore it when it appears later. | |
| 803 // TODO(rogerta): we still need to further differentiate the primary account | 798 // TODO(rogerta): we still need to further differentiate the primary account |
| 804 // from the others, so more work is likely required here: crbug.com/311124. | 799 // from the others, so more work is likely required here: crbug.com/311124. |
| 805 CreateAccountButton(layout, primary_account, true); | 800 CreateAccountButton(layout, primary_account, true); |
| 806 for (size_t i = 0; i < accounts.size(); ++i) { | 801 for (size_t i = 0; i < accounts.size(); ++i) { |
|
sky
2014/01/08 21:00:15
nit: remove {}
noms (inactive)
2014/01/08 21:04:27
Eeek, oops. Done.
On 2014/01/08 21:00:15, sky wrot
| |
| 807 if (primary_account != accounts[i]) | 802 CreateAccountButton(layout, accounts[i], false); |
| 808 CreateAccountButton(layout, accounts[i], false); | |
| 809 } | 803 } |
| 810 | 804 |
| 811 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 805 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 812 | 806 |
| 813 add_account_button_ = new views::BlueButton( | 807 add_account_button_ = new views::BlueButton( |
| 814 this, | 808 this, |
| 815 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, | 809 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, |
| 816 avatar_item.name)); | 810 avatar_item.name)); |
| 817 layout->StartRow(1, 0); | 811 layout->StartRow(1, 0); |
| 818 layout->AddView(add_account_button_); | 812 layout->AddView(add_account_button_); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 838 email_button->set_menu_marker( | 832 email_button->set_menu_marker( |
| 839 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia()); | 833 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia()); |
| 840 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 834 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 841 } | 835 } |
| 842 layout->StartRow(1, 0); | 836 layout->StartRow(1, 0); |
| 843 layout->AddView(email_button); | 837 layout->AddView(email_button); |
| 844 | 838 |
| 845 // Save the original email address, as the button text could be elided. | 839 // Save the original email address, as the button text could be elided. |
| 846 current_profile_accounts_map_[email_button] = account; | 840 current_profile_accounts_map_[email_button] = account; |
| 847 } | 841 } |
| OLD | NEW |