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

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: move function to minimize diff 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/bind.h"
8 #include "base/message_loop.h"
9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h"
11 #include "base/time.h"
12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chromeos/cros/cert_library.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "google_apis/gaia/google_service_auth_error.h"
16
17 namespace {
18 const char kRobotAnyApiRefreshTokenPrefKey[] = "robot_refresh_token.any-api";
19 }
20
21 namespace chromeos {
22
23 DeviceOAuth2TokenService::DeviceOAuth2TokenService(
24 net::URLRequestContextGetter* getter)
25 : OAuth2TokenService(NULL) {
26 }
27
28 DeviceOAuth2TokenService::~DeviceOAuth2TokenService() {
29 }
30
31 // static
32 void DeviceOAuth2TokenService::RegisterPrefs(PrefRegistrySimple* registry) {
33 registry->RegisterStringPref(kRobotAnyApiRefreshTokenPrefKey, "");
34 }
35
36 void DeviceOAuth2TokenService::SaveRefreshToken(
37 const std::string& refresh_token) {
38 // TODO: Encrypt this value when 12870010 is landed.
39 // CrosLibrary::Get()->GetCertLibrary()->EncryptWithSystemSalt(token);
40
41 g_browser_process->local_state()->SetString(kRobotAnyApiRefreshTokenPrefKey,
Andrew T Wilson (Slow) 2013/03/19 19:58:44 Consider injecting the PrefRegistry in the constru
42 refresh_token);
43
44 g_browser_process->local_state()->CommitPendingWrite();
45 }
46
47 std::string DeviceOAuth2TokenService::GetRefreshToken() {
48 // TODO: Decrypt this value when 12870010 is landed.
49 // CrosLibrary::Get()->GetCertLibrary()->DecryptWithSystemSalt(token);
50
51 return g_browser_process->local_state()->GetString(
52 kRobotAnyApiRefreshTokenPrefKey);
53 }
54
55 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698