| 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/guid.h" |
| 8 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/content_settings/cookie_settings.h" | 10 #include "chrome/browser/content_settings/cookie_settings.h" |
| 9 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 11 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 10 #include "chrome/browser/signin/local_auth.h" | 12 #include "chrome/browser/signin/local_auth.h" |
| 11 #include "chrome/browser/webdata/web_data_service_factory.h" | 13 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 12 #include "chrome/common/chrome_version_info.h" | 14 #include "chrome/common/chrome_version_info.h" |
| 13 #include "components/signin/core/common/profile_management_switches.h" | 15 #include "components/signin/core/common/profile_management_switches.h" |
| 16 #include "components/signin/core/common/signin_pref_names.h" |
| 14 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
| 15 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 16 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/common/child_process_host.h" | 20 #include "content/public/common/child_process_host.h" |
| 18 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 19 | 22 |
| 20 #if defined(ENABLE_MANAGED_USERS) | 23 #if defined(ENABLE_MANAGED_USERS) |
| 21 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 24 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| 22 #endif | 25 #endif |
| 23 | 26 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 if (profile_->IsSupervised()) { | 123 if (profile_->IsSupervised()) { |
| 121 LOG(ERROR) << "Attempt to revoke supervised user refresh " | 124 LOG(ERROR) << "Attempt to revoke supervised user refresh " |
| 122 << "token detected, ignoring."; | 125 << "token detected, ignoring."; |
| 123 return false; | 126 return false; |
| 124 } | 127 } |
| 125 #endif | 128 #endif |
| 126 return true; | 129 return true; |
| 127 } | 130 } |
| 128 | 131 |
| 129 std::string ChromeSigninClient::GetSigninScopedDeviceId() { | 132 std::string ChromeSigninClient::GetSigninScopedDeviceId() { |
| 130 // TODO(pavely): crbug/382968. In the future this method will read | 133 std::string signin_scoped_device_id = |
| 131 // SigninScopedDeviceId from prefs, generating new one if it doesn't exist. | 134 GetPrefs()->GetString(prefs::kGoogleServicesSigninScopedDeviceId); |
| 132 // For now it returns empty string to maintain existing behavior. | 135 if (signin_scoped_device_id.empty()) { |
| 133 return std::string(); | 136 // If device_id doesn't exist then generate new and save in prefs. |
| 137 signin_scoped_device_id = base::GenerateGUID(); |
| 138 DCHECK(!signin_scoped_device_id.empty()); |
| 139 GetPrefs()->SetString(prefs::kGoogleServicesSigninScopedDeviceId, |
| 140 signin_scoped_device_id); |
| 141 } |
| 142 return signin_scoped_device_id; |
| 143 } |
| 144 |
| 145 void ChromeSigninClient::ClearSigninScopedDeviceId() { |
| 146 GetPrefs()->ClearPref(prefs::kGoogleServicesSigninScopedDeviceId); |
| 134 } | 147 } |
| 135 | 148 |
| 136 net::URLRequestContextGetter* ChromeSigninClient::GetURLRequestContext() { | 149 net::URLRequestContextGetter* ChromeSigninClient::GetURLRequestContext() { |
| 137 return profile_->GetRequestContext(); | 150 return profile_->GetRequestContext(); |
| 138 } | 151 } |
| 139 | 152 |
| 140 bool ChromeSigninClient::ShouldMergeSigninCredentialsIntoCookieJar() { | 153 bool ChromeSigninClient::ShouldMergeSigninCredentialsIntoCookieJar() { |
| 141 // If inline sign in is enabled, but new profile management is not, the user's | 154 // If inline sign in is enabled, but new profile management is not, the user's |
| 142 // credentials should be merge into the cookie jar. | 155 // credentials should be merge into the cookie jar. |
| 143 return !switches::IsEnableWebBasedSignin() && | 156 return !switches::IsEnableWebBasedSignin() && |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 213 |
| 201 void ChromeSigninClient::UnregisterForCookieChangedNotification() { | 214 void ChromeSigninClient::UnregisterForCookieChangedNotification() { |
| 202 // Note that it's allowed to call this method multiple times without an | 215 // Note that it's allowed to call this method multiple times without an |
| 203 // intervening call to |RegisterForCookieChangedNotification()|. | 216 // intervening call to |RegisterForCookieChangedNotification()|. |
| 204 content::Source<Profile> source(profile_); | 217 content::Source<Profile> source(profile_); |
| 205 if (!registrar_.IsRegistered( | 218 if (!registrar_.IsRegistered( |
| 206 this, chrome::NOTIFICATION_COOKIE_CHANGED, source)) | 219 this, chrome::NOTIFICATION_COOKIE_CHANGED, source)) |
| 207 return; | 220 return; |
| 208 registrar_.Remove(this, chrome::NOTIFICATION_COOKIE_CHANGED, source); | 221 registrar_.Remove(this, chrome::NOTIFICATION_COOKIE_CHANGED, source); |
| 209 } | 222 } |
| OLD | NEW |