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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (profile->IsSupervised()) { | 87 if (profile->IsSupervised()) { |
88 name = l10n_util::GetStringFUTF16(IDS_SUPERVISED_USER_NEW_AVATAR_LABEL, | 88 name = l10n_util::GetStringFUTF16(IDS_SUPERVISED_USER_NEW_AVATAR_LABEL, |
89 name); | 89 name); |
90 } | 90 } |
91 return name; | 91 return name; |
92 } | 92 } |
93 | 93 |
94 void UpdateProfileName(Profile* profile, | 94 void UpdateProfileName(Profile* profile, |
95 const base::string16& new_profile_name) { | 95 const base::string16& new_profile_name) { |
96 PrefService* pref_service = profile->GetPrefs(); | 96 PrefService* pref_service = profile->GetPrefs(); |
| 97 ProfileInfoCache& cache = |
| 98 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 99 |
| 100 // This is only called when updating the profile name through the UI, |
| 101 // so we can assume the user has done this on purpose. |
| 102 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 103 if (profile_index != std::string::npos) |
| 104 pref_service->SetBoolean(prefs::kProfileUsingDefaultName, false); |
| 105 |
97 // Updating the profile preference will cause the cache to be updated for | 106 // Updating the profile preference will cause the cache to be updated for |
98 // this preference. | 107 // this preference. |
99 pref_service->SetString(prefs::kProfileName, | 108 pref_service->SetString(prefs::kProfileName, |
100 base::UTF16ToUTF8(new_profile_name)); | 109 base::UTF16ToUTF8(new_profile_name)); |
101 } | 110 } |
102 | 111 |
103 std::vector<std::string> GetSecondaryAccountsForProfile( | 112 std::vector<std::string> GetSecondaryAccountsForProfile( |
104 Profile* profile, | 113 Profile* profile, |
105 const std::string& primary_account) { | 114 const std::string& primary_account) { |
106 std::vector<std::string> accounts = | 115 std::vector<std::string> accounts = |
(...skipping 25 matching lines...) Expand all Loading... |
132 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update(); | 141 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update(); |
133 } | 142 } |
134 | 143 |
135 SigninErrorController* GetSigninErrorController(Profile* profile) { | 144 SigninErrorController* GetSigninErrorController(Profile* profile) { |
136 ProfileOAuth2TokenService* token_service = | 145 ProfileOAuth2TokenService* token_service = |
137 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 146 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
138 return token_service ? token_service->signin_error_controller() : NULL; | 147 return token_service ? token_service->signin_error_controller() : NULL; |
139 } | 148 } |
140 | 149 |
141 } // namespace profiles | 150 } // namespace profiles |
OLD | NEW |