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/profiles/profiles_state.h" | 5 #include "chrome/browser/profiles/profiles_state.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_info_cache.h" | 13 #include "chrome/browser/profiles/profile_info_cache.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
15 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
18 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
19 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
20 | 22 |
21 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
22 #include "chrome/browser/chromeos/login/user_manager.h" | 24 #include "chrome/browser/chromeos/login/user_manager.h" |
23 #endif | 25 #endif |
24 | 26 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 96 |
95 // Changing the profile name can invalidate the profile index. | 97 // Changing the profile name can invalidate the profile index. |
96 profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); | 98 profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
97 if (profile_index == std::string::npos) | 99 if (profile_index == std::string::npos) |
98 return; | 100 return; |
99 | 101 |
100 cache.SetIsUsingGAIANameOfProfileAtIndex(profile_index, false); | 102 cache.SetIsUsingGAIANameOfProfileAtIndex(profile_index, false); |
101 } | 103 } |
102 } | 104 } |
103 | 105 |
| 106 std::vector<std::string> GetSecondaryAccountsForProfile( |
| 107 Profile* profile, |
| 108 const std::string& primary_account) { |
| 109 std::vector<std::string> accounts = |
| 110 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->GetAccounts(); |
| 111 |
| 112 // The vector returned by ProfileOAuth2TokenService::GetAccounts() contains |
| 113 // the primary account too, so we need to remove it from the list. |
| 114 std::vector<std::string>::iterator primary_index = |
| 115 std::find_if(accounts.begin(), accounts.end(), |
| 116 std::bind1st(std::equal_to<std::string>(), primary_account)); |
| 117 DCHECK(primary_index != accounts.end()); |
| 118 accounts.erase(primary_index); |
| 119 |
| 120 return accounts; |
| 121 } |
| 122 |
104 } // namespace profiles | 123 } // namespace profiles |
OLD | NEW |