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/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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 gfx::CHARACTER_BREAK); | 86 gfx::CHARACTER_BREAK); |
| 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(); | |
| 97 ProfileInfoCache& cache = | 96 ProfileInfoCache& cache = |
| 98 g_browser_process->profile_manager()->GetProfileInfoCache(); | 97 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 98 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | |
| 99 if (profile_index == std::string::npos) | |
| 100 return; | |
|
Roger Tawa OOO till Jul 10th
2014/08/21 18:32:31
Should this be a DCHECK?
noms (inactive)
2014/08/21 18:36:18
Ugh, everything is peppered with this kind of chec
| |
| 101 | |
| 102 if (new_profile_name == cache.GetNameOfProfileAtIndex(profile_index)) | |
| 103 return; | |
| 99 | 104 |
| 100 // This is only called when updating the profile name through the UI, | 105 // This is only called when updating the profile name through the UI, |
| 101 // so we can assume the user has done this on purpose. | 106 // so we can assume the user has done this on purpose. |
| 102 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 107 PrefService* pref_service = profile->GetPrefs(); |
| 103 if (profile_index != std::string::npos) | 108 pref_service->SetBoolean(prefs::kProfileUsingDefaultName, false); |
| 104 pref_service->SetBoolean(prefs::kProfileUsingDefaultName, false); | |
| 105 | 109 |
| 106 // Updating the profile preference will cause the cache to be updated for | 110 // Updating the profile preference will cause the cache to be updated for |
| 107 // this preference. | 111 // this preference. |
| 108 pref_service->SetString(prefs::kProfileName, | 112 pref_service->SetString(prefs::kProfileName, |
| 109 base::UTF16ToUTF8(new_profile_name)); | 113 base::UTF16ToUTF8(new_profile_name)); |
| 110 } | 114 } |
| 111 | 115 |
| 112 std::vector<std::string> GetSecondaryAccountsForProfile( | 116 std::vector<std::string> GetSecondaryAccountsForProfile( |
| 113 Profile* profile, | 117 Profile* profile, |
| 114 const std::string& primary_account) { | 118 const std::string& primary_account) { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 141 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update(); | 145 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update(); |
| 142 } | 146 } |
| 143 | 147 |
| 144 SigninErrorController* GetSigninErrorController(Profile* profile) { | 148 SigninErrorController* GetSigninErrorController(Profile* profile) { |
| 145 ProfileOAuth2TokenService* token_service = | 149 ProfileOAuth2TokenService* token_service = |
| 146 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 150 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 147 return token_service ? token_service->signin_error_controller() : NULL; | 151 return token_service ? token_service->signin_error_controller() : NULL; |
| 148 } | 152 } |
| 149 | 153 |
| 150 } // namespace profiles | 154 } // namespace profiles |
| OLD | NEW |