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/gaia_info_update_service.h" | 12 #include "chrome/browser/profiles/gaia_info_update_service.h" |
13 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" | 13 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/profiles/profile_info_cache.h" | 15 #include "chrome/browser/profiles/profile_info_cache.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 18 #include "chrome/browser/signin/signin_error_controller_factory.h" |
18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
21 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
22 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 23 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
23 #include "components/signin/core/common/profile_management_switches.h" | 24 #include "components/signin/core/common/profile_management_switches.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/gfx/text_elider.h" | 26 #include "ui/gfx/text_elider.h" |
26 | 27 |
27 namespace profiles { | 28 namespace profiles { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 DCHECK(profile); | 161 DCHECK(profile); |
161 | 162 |
162 GAIAInfoUpdateService* service = | 163 GAIAInfoUpdateService* service = |
163 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile); | 164 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile); |
164 // The service may be null, for example during unit tests. | 165 // The service may be null, for example during unit tests. |
165 if (service) | 166 if (service) |
166 service->Update(); | 167 service->Update(); |
167 } | 168 } |
168 | 169 |
169 SigninErrorController* GetSigninErrorController(Profile* profile) { | 170 SigninErrorController* GetSigninErrorController(Profile* profile) { |
170 ProfileOAuth2TokenService* token_service = | 171 return SigninErrorControllerFactory::GetForProfile(profile); |
171 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | |
172 return token_service ? token_service->signin_error_controller() : NULL; | |
173 } | 172 } |
174 | 173 |
175 Profile* SetActiveProfileToGuestIfLocked() { | 174 Profile* SetActiveProfileToGuestIfLocked() { |
176 Profile* active_profile = ProfileManager::GetLastUsedProfile(); | 175 Profile* active_profile = ProfileManager::GetLastUsedProfile(); |
177 DCHECK(active_profile); | 176 DCHECK(active_profile); |
178 | 177 |
179 if (active_profile->IsGuestSession()) | 178 if (active_profile->IsGuestSession()) |
180 return active_profile; | 179 return active_profile; |
181 | 180 |
182 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 181 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
183 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 182 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
184 size_t index = cache.GetIndexOfProfileWithPath(active_profile->GetPath()); | 183 size_t index = cache.GetIndexOfProfileWithPath(active_profile->GetPath()); |
185 if (!cache.ProfileIsSigninRequiredAtIndex(index)) | 184 if (!cache.ProfileIsSigninRequiredAtIndex(index)) |
186 return NULL; | 185 return NULL; |
187 | 186 |
188 // The guest profile must have been loaded already. | 187 // The guest profile must have been loaded already. |
189 Profile* guest_profile = profile_manager->GetProfile( | 188 Profile* guest_profile = profile_manager->GetProfile( |
190 ProfileManager::GetGuestProfilePath()); | 189 ProfileManager::GetGuestProfilePath()); |
191 DCHECK(guest_profile); | 190 DCHECK(guest_profile); |
192 | 191 |
193 PrefService* local_state = g_browser_process->local_state(); | 192 PrefService* local_state = g_browser_process->local_state(); |
194 DCHECK(local_state); | 193 DCHECK(local_state); |
195 local_state->SetString(prefs::kProfileLastUsed, | 194 local_state->SetString(prefs::kProfileLastUsed, |
196 guest_profile->GetPath().BaseName().MaybeAsASCII()); | 195 guest_profile->GetPath().BaseName().MaybeAsASCII()); |
197 return guest_profile; | 196 return guest_profile; |
198 } | 197 } |
199 | 198 |
200 } // namespace profiles | 199 } // namespace profiles |
OLD | NEW |