Index: chrome/browser/chromeos/settings/device_oauth2_token_service.cc |
diff --git a/chrome/browser/chromeos/settings/device_oauth2_token_service.cc b/chrome/browser/chromeos/settings/device_oauth2_token_service.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..32ac316b303b765f7fd71990203161ca3f4d45c6 |
--- /dev/null |
+++ b/chrome/browser/chromeos/settings/device_oauth2_token_service.cc |
@@ -0,0 +1,55 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
+ |
+#include "base/bind.h" |
+#include "base/message_loop.h" |
+#include "base/prefs/pref_registry_simple.h" |
+#include "base/prefs/pref_service.h" |
+#include "base/time.h" |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/chromeos/cros/cert_library.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "google_apis/gaia/google_service_auth_error.h" |
+ |
+namespace { |
+const char kRobotAnyApiRefreshTokenPrefKey[] = "robot_refresh_token.any-api"; |
+} |
+ |
+namespace chromeos { |
+ |
+DeviceOAuth2TokenService::DeviceOAuth2TokenService( |
+ net::URLRequestContextGetter* getter) |
+ : OAuth2TokenService(NULL) { |
+} |
+ |
+DeviceOAuth2TokenService::~DeviceOAuth2TokenService() { |
+} |
+ |
+// static |
+void DeviceOAuth2TokenService::RegisterPrefs(PrefRegistrySimple* registry) { |
+ registry->RegisterStringPref(kRobotAnyApiRefreshTokenPrefKey, ""); |
+} |
+ |
+void DeviceOAuth2TokenService::SaveRefreshToken( |
+ const std::string& refresh_token) { |
+ // TODO: Encrypt this value when 12870010 is landed. |
+ // CrosLibrary::Get()->GetCertLibrary()->EncryptWithSystemSalt(token); |
+ |
+ g_browser_process->local_state()->SetString(kRobotAnyApiRefreshTokenPrefKey, |
Andrew T Wilson (Slow)
2013/03/19 19:58:44
Consider injecting the PrefRegistry in the constru
|
+ refresh_token); |
+ |
+ g_browser_process->local_state()->CommitPendingWrite(); |
+} |
+ |
+std::string DeviceOAuth2TokenService::GetRefreshToken() { |
+ // TODO: Decrypt this value when 12870010 is landed. |
+ // CrosLibrary::Get()->GetCertLibrary()->DecryptWithSystemSalt(token); |
+ |
+ return g_browser_process->local_state()->GetString( |
+ kRobotAnyApiRefreshTokenPrefKey); |
+} |
+ |
+} // namespace chromeos |