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

Unified Diff: chrome/browser/geolocation/access_token_store.cc

Issue 603040: Add support for top level geolocation arbitrator, and access token persistenc... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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
« no previous file with comments | « chrome/browser/geolocation/access_token_store.h ('k') | chrome/browser/geolocation/geoposition.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/geolocation/access_token_store.cc
===================================================================
--- chrome/browser/geolocation/access_token_store.cc (revision 0)
+++ chrome/browser/geolocation/access_token_store.cc (revision 0)
@@ -0,0 +1,51 @@
+// Copyright (c) 2010 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/geolocation/access_token_store.h"
+
+#include "base/utf_string_conversions.h"
+#include "base/values.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
+#include "googleurl/src/gurl.h"
+
+namespace {
+// Implementation of the geolocation access token store using chrome's prefs
+// store (local_state) to persist these tokens.
+// TODO(joth): Calls APIs which probably can't be used from the thread that it
+// will be run on; needs prefs access bounced via UI thread.
+class ChromePrefsAccessTokenStore : public AccessTokenStore {
+ public:
+ // AccessTokenStore
+ virtual bool SetAccessToken(const GURL& url,
+ const string16& access_token) {
+ DictionaryValue* access_token_dictionary =
+ g_browser_process->local_state()->GetMutableDictionary(
+ prefs::kGeolocationAccessToken);
+ access_token_dictionary->SetWithoutPathExpansion(
+ UTF8ToWide(url.spec()),
+ Value::CreateStringValueFromUTF16(access_token));
+ return true;
+ }
+
+ virtual bool GetAccessToken(const GURL& url, string16* access_token) {
+ const DictionaryValue* access_token_dictionary =
+ g_browser_process->local_state()->GetDictionary(
+ prefs::kGeolocationAccessToken);
+ // Careful: The returned value could be NULL if the pref has never been set.
+ if (access_token_dictionary == NULL)
+ return false;
+ return access_token_dictionary->GetStringAsUTF16WithoutPathExpansion(
+ UTF8ToWide(url.spec()), access_token);
+ }
+};
+
+} // namespace
+
+void AccessTokenStore::RegisterPrefs(PrefService* prefs) {
+ prefs->RegisterDictionaryPref(prefs::kGeolocationAccessToken);
+}
+
+AccessTokenStore* NewChromePrefsAccessTokenStore();
Property changes on: chrome\browser\geolocation\access_token_store.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/geolocation/access_token_store.h ('k') | chrome/browser/geolocation/geoposition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698