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

Unified 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698