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

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

Issue 7734005: Get rid of the link time dependency between content and chrome through the geolocation code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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/geolocation/chrome_access_token_store.cc
===================================================================
--- chrome/browser/geolocation/chrome_access_token_store.cc (revision 0)
+++ chrome/browser/geolocation/chrome_access_token_store.cc (revision 0)
@@ -0,0 +1,68 @@
+// Copyright (c) 2011 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/chrome_access_token_store.h"
+
+#include "base/string_piece.h"
+#include "base/utf_string_conversions.h"
+#include "base/values.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/prefs/scoped_user_pref_update.h"
+#include "chrome/common/pref_names.h"
+#include "content/browser/browser_thread.h"
+#include "googleurl/src/gurl.h"
+
+void ChromeAccessTokenStore::RegisterPrefs(PrefService* prefs) {
+ prefs->RegisterDictionaryPref(prefs::kGeolocationAccessToken);
+}
+
+ChromeAccessTokenStore::ChromeAccessTokenStore() {
+}
+
+void ChromeAccessTokenStore::LoadDictionaryStoreInUIThread(
+ scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > request) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (request->canceled())
+ return;
+ const DictionaryValue* token_dictionary =
+ g_browser_process->local_state()->GetDictionary(
+ prefs::kGeolocationAccessToken);
+
+ AccessTokenStore::AccessTokenSet access_token_set;
+ // The dictionary value could be NULL if the pref has never been set.
+ if (token_dictionary != NULL) {
+ for (DictionaryValue::key_iterator it = token_dictionary->begin_keys();
+ it != token_dictionary->end_keys(); ++it) {
+ GURL url(*it);
+ if (!url.is_valid())
+ continue;
+ token_dictionary->GetStringWithoutPathExpansion(*it,
+ &access_token_set[url]);
+ }
+ }
+ request->ForwardResultAsync(MakeTuple(access_token_set));
+}
+
+void ChromeAccessTokenStore::DoLoadAccessTokens(
+ scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > request) {
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod(
+ this, &ChromeAccessTokenStore::LoadDictionaryStoreInUIThread,
+ request));
+}
+
+void SetAccessTokenOnUIThread(const GURL& server_url, const string16& token) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DictionaryPrefUpdate update(g_browser_process->local_state(),
+ prefs::kGeolocationAccessToken);
+ DictionaryValue* access_token_dictionary = update.Get();
+ access_token_dictionary->SetWithoutPathExpansion(
+ server_url.spec(), Value::CreateStringValue(token));
+}
+
+void ChromeAccessTokenStore::SaveAccessToken(
+ const GURL& server_url, const string16& access_token) {
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableFunction(
+ &SetAccessTokenOnUIThread, server_url, access_token));
+}
Property changes on: chrome\browser\geolocation\chrome_access_token_store.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/geolocation/chrome_access_token_store.h ('k') | chrome/browser/geolocation/geolocation_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698