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
3 // found in the LICENSE file.
5 #include "components/signin/core/browser/signin_client.h"
8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h"
10 #include "components/signin/core/common/signin_pref_names.h"
13 const char kEphemeralUserDeviceIDPrefix
[] = "t_";
17 std::string
SigninClient::GenerateSigninScopedDeviceID(bool for_ephemeral
) {
18 std::string guid
= base::GenerateGUID();
19 return for_ephemeral
? kEphemeralUserDeviceIDPrefix
+ guid
: guid
;
22 std::string
SigninClient::GetOrCreateScopedDeviceIdPref(PrefService
* prefs
) {
23 std::string signin_scoped_device_id
=
24 prefs
->GetString(prefs::kGoogleServicesSigninScopedDeviceId
);
25 if (signin_scoped_device_id
.empty()) {
26 // If device_id doesn't exist then generate new and save in prefs.
27 signin_scoped_device_id
= GenerateSigninScopedDeviceID(false);
28 DCHECK(!signin_scoped_device_id
.empty());
29 prefs
->SetString(prefs::kGoogleServicesSigninScopedDeviceId
,
30 signin_scoped_device_id
);
32 return signin_scoped_device_id
;
35 void SigninClient::SignOut() {
36 GetPrefs()->ClearPref(prefs::kGoogleServicesSigninScopedDeviceId
);