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

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: Moved DeviceOAuth2TokenService factory method to g_browser_process Created 7 years, 9 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 : OAuth2TokenService(NULL) {
19 }
20
21 DeviceOAuth2TokenService::~DeviceOAuth2TokenService() {
22 }
23
24 // static
25 void DeviceOAuth2TokenService::RegisterPrefs(PrefRegistrySimple* registry) {
26 registry->RegisterStringPref(prefs::kDeviceRobotAnyApiRefreshToken, "");
27 }
28
29 void DeviceOAuth2TokenService::SetAndSaveRefreshToken(
30 const std::string& refresh_token) {
31 std::string encrypted_refresh_token =
32 CrosLibrary::Get()->GetCertLibrary()->EncryptWithSystemSalt(
33 refresh_token);
34
35 g_browser_process->local_state()->SetString(
36 prefs::kDeviceRobotAnyApiRefreshToken,
37 encrypted_refresh_token);
38 }
39
40 std::string DeviceOAuth2TokenService::GetRefreshToken() {
41 std::string encrypted_refresh_token =
42 g_browser_process->local_state()->GetString(
Mattias Nissler (ping if slow) 2013/03/26 12:04:32 Seems like the local state pointer could be passed
David Roche 2013/03/27 05:09:51 Done.
43 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