| 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 "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/content_settings/cookie_settings.h" | 8 #include "chrome/browser/content_settings/cookie_settings.h" |
| 9 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 9 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 10 #include "chrome/browser/signin/local_auth.h" | 10 #include "chrome/browser/signin/local_auth.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // SigninScopedDeviceId from prefs, generating new one if it doesn't exist. | 132 // SigninScopedDeviceId from prefs, generating new one if it doesn't exist. |
| 133 // For now it returns empty string to maintain existing behavior. | 133 // For now it returns empty string to maintain existing behavior. |
| 134 return std::string(); | 134 return std::string(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 net::URLRequestContextGetter* ChromeSigninClient::GetURLRequestContext() { | 137 net::URLRequestContextGetter* ChromeSigninClient::GetURLRequestContext() { |
| 138 return profile_->GetRequestContext(); | 138 return profile_->GetRequestContext(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool ChromeSigninClient::ShouldMergeSigninCredentialsIntoCookieJar() { | 141 bool ChromeSigninClient::ShouldMergeSigninCredentialsIntoCookieJar() { |
| 142 // If inline sign in is enabled, but new profile management is not, the user's | 142 // If inline sign in is enabled, but account consistency is not, the user's |
| 143 // credentials should be merge into the cookie jar. | 143 // credentials should be merge into the cookie jar. |
| 144 return !switches::IsEnableWebBasedSignin() && | 144 return !switches::IsEnableWebBasedSignin() && |
| 145 !switches::IsNewProfileManagement(); | 145 !switches::IsEnableAccountConsistency(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 std::string ChromeSigninClient::GetProductVersion() { | 148 std::string ChromeSigninClient::GetProductVersion() { |
| 149 chrome::VersionInfo chrome_version; | 149 chrome::VersionInfo chrome_version; |
| 150 if (!chrome_version.is_valid()) | 150 if (!chrome_version.is_valid()) |
| 151 return "invalid"; | 151 return "invalid"; |
| 152 return chrome_version.CreateVersionString(); | 152 return chrome_version.CreateVersionString(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void ChromeSigninClient::SetCookieChangedCallback( | 155 void ChromeSigninClient::SetCookieChangedCallback( |
| 156 const CookieChangedCallback& callback) { | 156 const CookieChangedCallback& callback) { |
| 157 if (callback_.Equals(callback)) | 157 if (callback_.Equals(callback)) |
| 158 return; | 158 return; |
| 159 | 159 |
| 160 // There should be only one callback active at a time. | 160 // There should be only one callback active at a time. |
| 161 DCHECK(callback.is_null() || callback_.is_null()); | 161 DCHECK(callback.is_null() || callback_.is_null()); |
| 162 callback_ = callback; | 162 callback_ = callback; |
| 163 if (!callback_.is_null()) | 163 if (!callback_.is_null()) |
| 164 RegisterForCookieChangedNotification(); | 164 RegisterForCookieChangedNotification(); |
| 165 else | 165 else |
| 166 UnregisterForCookieChangedNotification(); | 166 UnregisterForCookieChangedNotification(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void ChromeSigninClient::GoogleSigninSucceeded(const std::string& username, | 169 void ChromeSigninClient::GoogleSigninSucceeded(const std::string& username, |
| 170 const std::string& password) { | 170 const std::string& password) { |
| 171 #if !defined(OS_ANDROID) | 171 #if !defined(OS_ANDROID) |
| 172 // Don't store password hash except for users of new profile features. | 172 // Don't store password hash except for users of account consistency features. |
| 173 if (switches::IsNewProfileManagement()) | 173 if (switches::IsEnableAccountConsistency()) |
| 174 chrome::SetLocalAuthCredentials(profile_, password); | 174 chrome::SetLocalAuthCredentials(profile_, password); |
| 175 #endif | 175 #endif |
| 176 } | 176 } |
| 177 | 177 |
| 178 void ChromeSigninClient::Observe(int type, | 178 void ChromeSigninClient::Observe(int type, |
| 179 const content::NotificationSource& source, | 179 const content::NotificationSource& source, |
| 180 const content::NotificationDetails& details) { | 180 const content::NotificationDetails& details) { |
| 181 switch (type) { | 181 switch (type) { |
| 182 case chrome::NOTIFICATION_COOKIE_CHANGED: { | 182 case chrome::NOTIFICATION_COOKIE_CHANGED: { |
| 183 DCHECK(!callback_.is_null()); | 183 DCHECK(!callback_.is_null()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 201 | 201 |
| 202 void ChromeSigninClient::UnregisterForCookieChangedNotification() { | 202 void ChromeSigninClient::UnregisterForCookieChangedNotification() { |
| 203 // Note that it's allowed to call this method multiple times without an | 203 // Note that it's allowed to call this method multiple times without an |
| 204 // intervening call to |RegisterForCookieChangedNotification()|. | 204 // intervening call to |RegisterForCookieChangedNotification()|. |
| 205 content::Source<Profile> source(profile_); | 205 content::Source<Profile> source(profile_); |
| 206 if (!registrar_.IsRegistered( | 206 if (!registrar_.IsRegistered( |
| 207 this, chrome::NOTIFICATION_COOKIE_CHANGED, source)) | 207 this, chrome::NOTIFICATION_COOKIE_CHANGED, source)) |
| 208 return; | 208 return; |
| 209 registrar_.Remove(this, chrome::NOTIFICATION_COOKIE_CHANGED, source); | 209 registrar_.Remove(this, chrome::NOTIFICATION_COOKIE_CHANGED, source); |
| 210 } | 210 } |
| OLD | NEW |