Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/chromeos/settings/device_oauth2_token_service.cc

Issue 12647008: Refactor OAuth2TokenService to have profile- and device-based implementations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed final review comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 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.
4
5 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
6
7 #include "base/prefs/pref_registry_simple.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/cros/cert_library.h"
11 #include "chrome/browser/chromeos/cros/cros_library.h"
12 #include "chrome/common/pref_names.h"
13
14 namespace chromeos {
15
16 DeviceOAuth2TokenService::DeviceOAuth2TokenService(
17 net::URLRequestContextGetter* getter,
18 PrefService* local_state)
19 : OAuth2TokenService(getter),
20 local_state_(local_state) {
21 }
22
23 DeviceOAuth2TokenService::~DeviceOAuth2TokenService() {
24 }
25
26 // static
27 void DeviceOAuth2TokenService::RegisterPrefs(PrefRegistrySimple* registry) {
28 registry->RegisterStringPref(prefs::kDeviceRobotAnyApiRefreshToken, "");
29 }
30
31 void DeviceOAuth2TokenService::SetAndSaveRefreshToken(
32 const std::string& refresh_token) {
33 std::string encrypted_refresh_token =
34 CrosLibrary::Get()->GetCertLibrary()->EncryptWithSystemSalt(
35 refresh_token);
36
37 local_state_->SetString(prefs::kDeviceRobotAnyApiRefreshToken,
38 encrypted_refresh_token);
39 }
40
41 std::string DeviceOAuth2TokenService::GetRefreshToken() {
42 std::string encrypted_refresh_token =
43 local_state_->GetString(prefs::kDeviceRobotAnyApiRefreshToken);
44
45 return CrosLibrary::Get()->GetCertLibrary()->DecryptWithSystemSalt(
46 encrypted_refresh_token);
47 }
48
49 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698