Index: chrome/browser/signin/chrome_signin_client.cc |
diff --git a/chrome/browser/signin/chrome_signin_client.cc b/chrome/browser/signin/chrome_signin_client.cc |
index 223fb7a0a17c31cdeab19c02b0e1141ec72721fd..02f674e15a55701f2b09e0da4bead91b965a29bd 100644 |
--- a/chrome/browser/signin/chrome_signin_client.cc |
+++ b/chrome/browser/signin/chrome_signin_client.cc |
@@ -4,6 +4,9 @@ |
#include "chrome/browser/signin/chrome_signin_client.h" |
+#include "base/command_line.h" |
+#include "base/guid.h" |
+#include "base/prefs/pref_service.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/content_settings/cookie_settings.h" |
#include "chrome/browser/net/chrome_cookie_notification_details.h" |
@@ -11,6 +14,8 @@ |
#include "chrome/browser/webdata/web_data_service_factory.h" |
#include "chrome/common/chrome_version_info.h" |
#include "components/signin/core/common/profile_management_switches.h" |
+#include "components/signin/core/common/signin_pref_names.h" |
+#include "components/signin/core/common/signin_switches.h" |
#include "content/public/browser/notification_details.h" |
#include "content/public/browser/notification_source.h" |
#include "content/public/browser/render_process_host.h" |
@@ -127,10 +132,22 @@ bool ChromeSigninClient::CanRevokeCredentials() { |
} |
std::string ChromeSigninClient::GetSigninScopedDeviceId() { |
- // TODO(pavely): crbug/382968. In the future this method will read |
- // SigninScopedDeviceId from prefs, generating new one if it doesn't exist. |
- // For now it returns empty string to maintain existing behavior. |
- return std::string(); |
+ std::string signin_scoped_device_id = |
+ GetPrefs()->GetString(prefs::kGoogleServicesSigninScopedDeviceId); |
+ if (CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableSigninScopedDeviceId) && |
+ signin_scoped_device_id.empty()) { |
+ // If device_id doesn't exist then generate new and save in prefs. |
+ signin_scoped_device_id = base::GenerateGUID(); |
+ DCHECK(!signin_scoped_device_id.empty()); |
+ GetPrefs()->SetString(prefs::kGoogleServicesSigninScopedDeviceId, |
+ signin_scoped_device_id); |
+ } |
+ return signin_scoped_device_id; |
+} |
+ |
+void ChromeSigninClient::ClearSigninScopedDeviceId() { |
+ GetPrefs()->ClearPref(prefs::kGoogleServicesSigninScopedDeviceId); |
} |
net::URLRequestContextGetter* ChromeSigninClient::GetURLRequestContext() { |