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" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 if (profile->IsSupervised()) { | 91 if (profile->IsSupervised()) { |
92 name = l10n_util::GetStringFUTF16(IDS_SUPERVISED_USER_NEW_AVATAR_LABEL, | 92 name = l10n_util::GetStringFUTF16(IDS_SUPERVISED_USER_NEW_AVATAR_LABEL, |
93 name); | 93 name); |
94 } | 94 } |
95 return name; | 95 return name; |
96 } | 96 } |
97 | 97 |
98 void UpdateProfileName(Profile* profile, | 98 void UpdateProfileName(Profile* profile, |
99 const base::string16& new_profile_name) { | 99 const base::string16& new_profile_name) { |
100 PrefService* pref_service = profile->GetPrefs(); | 100 PrefService* pref_service = profile->GetPrefs(); |
| 101 ProfileInfoCache& cache = |
| 102 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 103 |
| 104 // Check whether the user has specifically chosen to use a default profile |
| 105 // name. |
| 106 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 107 if (profile_index != std::string::npos) { |
| 108 pref_service->SetInteger(prefs::kProfileUsingDefaultName, |
| 109 cache.IsDefaultProfileName(new_profile_name) ? 1 : 0); |
| 110 } |
| 111 |
101 // Updating the profile preference will cause the cache to be updated for | 112 // Updating the profile preference will cause the cache to be updated for |
102 // this preference. | 113 // this preference. |
103 pref_service->SetString(prefs::kProfileName, | 114 pref_service->SetString(prefs::kProfileName, |
104 base::UTF16ToUTF8(new_profile_name)); | 115 base::UTF16ToUTF8(new_profile_name)); |
105 } | 116 } |
106 | 117 |
107 std::vector<std::string> GetSecondaryAccountsForProfile( | 118 std::vector<std::string> GetSecondaryAccountsForProfile( |
108 Profile* profile, | 119 Profile* profile, |
109 const std::string& primary_account) { | 120 const std::string& primary_account) { |
110 std::vector<std::string> accounts = | 121 std::vector<std::string> accounts = |
(...skipping 25 matching lines...) Expand all Loading... |
136 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update(); | 147 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update(); |
137 } | 148 } |
138 | 149 |
139 SigninErrorController* GetSigninErrorController(Profile* profile) { | 150 SigninErrorController* GetSigninErrorController(Profile* profile) { |
140 ProfileOAuth2TokenService* token_service = | 151 ProfileOAuth2TokenService* token_service = |
141 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 152 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
142 return token_service ? token_service->signin_error_controller() : NULL; | 153 return token_service ? token_service->signin_error_controller() : NULL; |
143 } | 154 } |
144 | 155 |
145 } // namespace profiles | 156 } // namespace profiles |
OLD | NEW |