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