OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signin/chrome_signin_client.h" | 5 #include "chrome/browser/signin/chrome_signin_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 void ChromeSigninClient::ClearSigninScopedDeviceId() { | 150 void ChromeSigninClient::ClearSigninScopedDeviceId() { |
151 GetPrefs()->ClearPref(prefs::kGoogleServicesSigninScopedDeviceId); | 151 GetPrefs()->ClearPref(prefs::kGoogleServicesSigninScopedDeviceId); |
152 } | 152 } |
153 | 153 |
154 net::URLRequestContextGetter* ChromeSigninClient::GetURLRequestContext() { | 154 net::URLRequestContextGetter* ChromeSigninClient::GetURLRequestContext() { |
155 return profile_->GetRequestContext(); | 155 return profile_->GetRequestContext(); |
156 } | 156 } |
157 | 157 |
158 bool ChromeSigninClient::ShouldMergeSigninCredentialsIntoCookieJar() { | 158 bool ChromeSigninClient::ShouldMergeSigninCredentialsIntoCookieJar() { |
159 // If inline sign in is enabled, but new profile management is not, the user's | 159 // If inline sign in is enabled, but account consistency is not, the user's |
160 // credentials should be merge into the cookie jar. | 160 // credentials should be merge into the cookie jar. |
161 return !switches::IsEnableWebBasedSignin() && | 161 return !switches::IsEnableWebBasedSignin() && |
162 !switches::IsNewProfileManagement(); | 162 !switches::IsEnableAccountConsistency(); |
163 } | 163 } |
164 | 164 |
165 std::string ChromeSigninClient::GetProductVersion() { | 165 std::string ChromeSigninClient::GetProductVersion() { |
166 chrome::VersionInfo chrome_version; | 166 chrome::VersionInfo chrome_version; |
167 if (!chrome_version.is_valid()) | 167 if (!chrome_version.is_valid()) |
168 return "invalid"; | 168 return "invalid"; |
169 return chrome_version.CreateVersionString(); | 169 return chrome_version.CreateVersionString(); |
170 } | 170 } |
171 | 171 |
172 void ChromeSigninClient::SetCookieChangedCallback( | 172 void ChromeSigninClient::SetCookieChangedCallback( |
173 const CookieChangedCallback& callback) { | 173 const CookieChangedCallback& callback) { |
174 if (callback_.Equals(callback)) | 174 if (callback_.Equals(callback)) |
175 return; | 175 return; |
176 | 176 |
177 // There should be only one callback active at a time. | 177 // There should be only one callback active at a time. |
178 DCHECK(callback.is_null() || callback_.is_null()); | 178 DCHECK(callback.is_null() || callback_.is_null()); |
179 callback_ = callback; | 179 callback_ = callback; |
180 if (!callback_.is_null()) | 180 if (!callback_.is_null()) |
181 RegisterForCookieChangedNotification(); | 181 RegisterForCookieChangedNotification(); |
182 else | 182 else |
183 UnregisterForCookieChangedNotification(); | 183 UnregisterForCookieChangedNotification(); |
184 } | 184 } |
185 | 185 |
186 void ChromeSigninClient::GoogleSigninSucceeded(const std::string& username, | 186 void ChromeSigninClient::GoogleSigninSucceeded(const std::string& username, |
187 const std::string& password) { | 187 const std::string& password) { |
188 #if !defined(OS_ANDROID) | 188 #if !defined(OS_ANDROID) |
189 // Don't store password hash except for users of new profile features. | 189 // Don't store password hash except for users of account consistency features. |
190 if (switches::IsNewProfileManagement()) | 190 if (switches::IsEnableAccountConsistency()) |
191 chrome::SetLocalAuthCredentials(profile_, password); | 191 chrome::SetLocalAuthCredentials(profile_, password); |
192 #endif | 192 #endif |
193 } | 193 } |
194 | 194 |
195 void ChromeSigninClient::Observe(int type, | 195 void ChromeSigninClient::Observe(int type, |
196 const content::NotificationSource& source, | 196 const content::NotificationSource& source, |
197 const content::NotificationDetails& details) { | 197 const content::NotificationDetails& details) { |
198 switch (type) { | 198 switch (type) { |
199 case chrome::NOTIFICATION_COOKIE_CHANGED: { | 199 case chrome::NOTIFICATION_COOKIE_CHANGED: { |
200 DCHECK(!callback_.is_null()); | 200 DCHECK(!callback_.is_null()); |
(...skipping 17 matching lines...) Expand all Loading... |
218 | 218 |
219 void ChromeSigninClient::UnregisterForCookieChangedNotification() { | 219 void ChromeSigninClient::UnregisterForCookieChangedNotification() { |
220 // Note that it's allowed to call this method multiple times without an | 220 // Note that it's allowed to call this method multiple times without an |
221 // intervening call to |RegisterForCookieChangedNotification()|. | 221 // intervening call to |RegisterForCookieChangedNotification()|. |
222 content::Source<Profile> source(profile_); | 222 content::Source<Profile> source(profile_); |
223 if (!registrar_.IsRegistered( | 223 if (!registrar_.IsRegistered( |
224 this, chrome::NOTIFICATION_COOKIE_CHANGED, source)) | 224 this, chrome::NOTIFICATION_COOKIE_CHANGED, source)) |
225 return; | 225 return; |
226 registrar_.Remove(this, chrome::NOTIFICATION_COOKIE_CHANGED, source); | 226 registrar_.Remove(this, chrome::NOTIFICATION_COOKIE_CHANGED, source); |
227 } | 227 } |
OLD | NEW |