summaryrefslogtreecommitdiffstats
path: root/chrome/browser/geolocation
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-25 00:09:23 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-25 00:09:23 +0000
commit32538d988e57c52b951d95748a0a1fe53ed8c7b9 (patch)
tree97d0fbbeb9d40b7a0fe826943f7b7c8d6e16e039 /chrome/browser/geolocation
parent43df447aacfc08447360071d8c03bf76ee5c0fb9 (diff)
downloadchromium_src-32538d988e57c52b951d95748a0a1fe53ed8c7b9.zip
chromium_src-32538d988e57c52b951d95748a0a1fe53ed8c7b9.tar.gz
chromium_src-32538d988e57c52b951d95748a0a1fe53ed8c7b9.tar.bz2
Get rid of the link time dependency between content and chrome through the geolocation code.
BUG=76697 Review URL: http://codereview.chromium.org/7734005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation')
-rw-r--r--chrome/browser/geolocation/access_token_store_browsertest.cc10
-rw-r--r--chrome/browser/geolocation/chrome_access_token_store.cc (renamed from chrome/browser/geolocation/access_token_store.cc)60
-rw-r--r--chrome/browser/geolocation/chrome_access_token_store.h34
-rw-r--r--chrome/browser/geolocation/geolocation_prefs.cc4
4 files changed, 49 insertions, 59 deletions
diff --git a/chrome/browser/geolocation/access_token_store_browsertest.cc b/chrome/browser/geolocation/access_token_store_browsertest.cc
index 773a38c..5d138ae 100644
--- a/chrome/browser/geolocation/access_token_store_browsertest.cc
+++ b/chrome/browser/geolocation/access_token_store_browsertest.cc
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/geolocation/access_token_store.h"
-
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/geolocation/chrome_access_token_store.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/browser_thread.h"
@@ -45,7 +44,7 @@ void StartTestStepFromClientThread(
AccessTokenStore::LoadAccessTokensCallbackType* callback) {
ASSERT_TRUE(BrowserThread::CurrentlyOn(kExpectedClientThreadId));
if (*store == NULL)
- (*store) = NewChromePrefsAccessTokenStore();
+ (*store) = new ChromeAccessTokenStore();
(*store)->LoadAccessTokens(consumer, callback);
}
@@ -57,7 +56,7 @@ struct TokenLoadClientForTest {
void RunCancelTestInClientTread() {
ASSERT_TRUE(BrowserThread::CurrentlyOn(kExpectedClientThreadId));
- scoped_refptr<AccessTokenStore> store(NewChromePrefsAccessTokenStore());
+ scoped_refptr<AccessTokenStore> store(new ChromeAccessTokenStore());
CancelableRequestConsumer consumer;
TokenLoadClientForTest load_client;
@@ -117,8 +116,7 @@ void GeolocationAccessTokenStoreTest::OnAccessTokenStoresLoaded(
}
if (token_to_set_) {
- scoped_refptr<AccessTokenStore> store(
- NewChromePrefsAccessTokenStore());
+ scoped_refptr<AccessTokenStore> store(new ChromeAccessTokenStore());
store->SaveAccessToken(ref_url_, *token_to_set_);
}
BrowserThread::PostTask(
diff --git a/chrome/browser/geolocation/access_token_store.cc b/chrome/browser/geolocation/chrome_access_token_store.cc
index f76bcc5..2ba45a5 100644
--- a/chrome/browser/geolocation/access_token_store.cc
+++ b/chrome/browser/geolocation/chrome_access_token_store.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/geolocation/access_token_store.h"
+#include "chrome/browser/geolocation/chrome_access_token_store.h"
#include "base/string_piece.h"
#include "base/utf_string_conversions.h"
@@ -14,28 +14,14 @@
#include "content/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
-namespace {
-class ChromePrefsAccessTokenStore : public AccessTokenStore {
- public:
- ChromePrefsAccessTokenStore();
-
- private:
- void LoadDictionaryStoreInUIThread(
- scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > request);
-
- // AccessTokenStore
- virtual void DoLoadAccessTokens(
- scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > request);
- virtual void SaveAccessToken(
- const GURL& server_url, const string16& access_token);
-
- DISALLOW_COPY_AND_ASSIGN(ChromePrefsAccessTokenStore);
-};
+void ChromeAccessTokenStore::RegisterPrefs(PrefService* prefs) {
+ prefs->RegisterDictionaryPref(prefs::kGeolocationAccessToken);
+}
-ChromePrefsAccessTokenStore::ChromePrefsAccessTokenStore() {
+ChromeAccessTokenStore::ChromeAccessTokenStore() {
}
-void ChromePrefsAccessTokenStore::LoadDictionaryStoreInUIThread(
+void ChromeAccessTokenStore::LoadDictionaryStoreInUIThread(
scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > request) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (request->canceled())
@@ -59,10 +45,10 @@ void ChromePrefsAccessTokenStore::LoadDictionaryStoreInUIThread(
request->ForwardResultAsync(MakeTuple(access_token_set));
}
-void ChromePrefsAccessTokenStore::DoLoadAccessTokens(
+void ChromeAccessTokenStore::DoLoadAccessTokens(
scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > request) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod(
- this, &ChromePrefsAccessTokenStore::LoadDictionaryStoreInUIThread,
+ this, &ChromeAccessTokenStore::LoadDictionaryStoreInUIThread,
request));
}
@@ -75,36 +61,8 @@ void SetAccessTokenOnUIThread(const GURL& server_url, const string16& token) {
server_url.spec(), Value::CreateStringValue(token));
}
-void ChromePrefsAccessTokenStore::SaveAccessToken(
+void ChromeAccessTokenStore::SaveAccessToken(
const GURL& server_url, const string16& access_token) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableFunction(
&SetAccessTokenOnUIThread, server_url, access_token));
}
-} // namespace
-
-AccessTokenStore::AccessTokenStore() {
-}
-
-AccessTokenStore::~AccessTokenStore() {
-}
-
-void AccessTokenStore::RegisterPrefs(PrefService* prefs) {
- prefs->RegisterDictionaryPref(prefs::kGeolocationAccessToken);
-}
-
-AccessTokenStore::Handle AccessTokenStore::LoadAccessTokens(
- CancelableRequestConsumerBase* consumer,
- LoadAccessTokensCallbackType* callback) {
- scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > request(
- new CancelableRequest<LoadAccessTokensCallbackType>(callback));
- AddRequest(request, consumer);
- DCHECK(request->handle());
-
- DoLoadAccessTokens(request);
- return request->handle();
-}
-
-// Creates a new access token store backed by the global chome prefs.
-AccessTokenStore* NewChromePrefsAccessTokenStore() {
- return new ChromePrefsAccessTokenStore;
-}
diff --git a/chrome/browser/geolocation/chrome_access_token_store.h b/chrome/browser/geolocation/chrome_access_token_store.h
new file mode 100644
index 0000000..9bd6707
--- /dev/null
+++ b/chrome/browser/geolocation/chrome_access_token_store.h
@@ -0,0 +1,34 @@
+// 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.
+
+#ifndef CHROME_BROWSER_GEOLOCATION_CHROME_ACCESS_TOKEN_STORE_H_
+#define CHROME_BROWSER_GEOLOCATION_CHROME_ACCESS_TOKEN_STORE_H_
+#pragma once
+
+#include "base/memory/ref_counted.h"
+#include "content/browser/geolocation/access_token_store.h"
+
+class PrefService;
+
+// Creates a new access token store backed by the global chome prefs.
+class ChromeAccessTokenStore : public AccessTokenStore {
+ public:
+ static void RegisterPrefs(PrefService* prefs);
+
+ ChromeAccessTokenStore();
+
+ private:
+ void LoadDictionaryStoreInUIThread(
+ scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > request);
+
+ // AccessTokenStore
+ virtual void DoLoadAccessTokens(
+ scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > request);
+ virtual void SaveAccessToken(
+ const GURL& server_url, const string16& access_token);
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeAccessTokenStore);
+};
+
+#endif // CHROME_BROWSER_GEOLOCATION_CHROME_ACCESS_TOKEN_STORE_H_
diff --git a/chrome/browser/geolocation/geolocation_prefs.cc b/chrome/browser/geolocation/geolocation_prefs.cc
index c618ed9..be20326 100644
--- a/chrome/browser/geolocation/geolocation_prefs.cc
+++ b/chrome/browser/geolocation/geolocation_prefs.cc
@@ -4,11 +4,11 @@
#include "chrome/browser/geolocation/geolocation_prefs.h"
-#include "content/browser/geolocation/access_token_store.h"
+#include "chrome/browser/geolocation/chrome_access_token_store.h"
namespace geolocation {
void RegisterPrefs(PrefService* prefs) {
// Fan out to all geolocation sub-components that use prefs.
- AccessTokenStore::RegisterPrefs(prefs);
+ ChromeAccessTokenStore::RegisterPrefs(prefs);
}
} // namespace geolocation