summaryrefslogtreecommitdiffstats
path: root/chrome/browser/geolocation
diff options
context:
space:
mode:
authorallanwoj@chromium.org <allanwoj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-31 11:08:19 +0000
committerallanwoj@chromium.org <allanwoj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-31 11:08:19 +0000
commitabfb89d06c8062df02660aa4b4efbae1f5320823 (patch)
tree63f7bcc2df6a5ada50ae11f9e674bdf9e4da9026 /chrome/browser/geolocation
parent569d127f862832145c979308ba1d2f4144d72bec (diff)
downloadchromium_src-abfb89d06c8062df02660aa4b4efbae1f5320823.zip
chromium_src-abfb89d06c8062df02660aa4b4efbae1f5320823.tar.gz
chromium_src-abfb89d06c8062df02660aa4b4efbae1f5320823.tar.bz2
Use new network location service protocol
Changed NetworkLocationRequest to point to the new Geolocation API. All data is now sent in the url as an HTTP GET. Altered unit tests to reflect this and removed a test fixture related to gateway data as this API does not support it. Further removal of gateway code to be done in a separate CL. BUG=http://b/5094774 TEST=--gtest_filter=GeolocationNetwork* Review URL: http://codereview.chromium.org/7718028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98954 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation')
-rw-r--r--chrome/browser/geolocation/access_token_store_browsertest.cc15
-rw-r--r--chrome/browser/geolocation/chrome_access_token_store.cc24
2 files changed, 33 insertions, 6 deletions
diff --git a/chrome/browser/geolocation/access_token_store_browsertest.cc b/chrome/browser/geolocation/access_token_store_browsertest.cc
index 5d138ae..426a1ce 100644
--- a/chrome/browser/geolocation/access_token_store_browsertest.cc
+++ b/chrome/browser/geolocation/access_token_store_browsertest.cc
@@ -17,6 +17,7 @@ namespace {
const BrowserThread::ID kExpectedClientThreadId = BrowserThread::IO;
const char* kRefServerUrl1 = "https://test.domain.example/foo?id=bar.bar";
const char* kRefServerUrl2 = "http://another.domain.example/foo?id=bar.bar#2";
+const char* kOldDefaultNetworkProviderUrl = "https://www.google.com/loc/json";
class GeolocationAccessTokenStoreTest
: public InProcessBrowserTest {
@@ -105,7 +106,6 @@ void GeolocationAccessTokenStoreTest::OnAccessTokenStoresLoaded(
ASSERT_TRUE(BrowserThread::CurrentlyOn(kExpectedClientThreadId))
<< "Callback from token factory should be from the same thread as the "
"LoadAccessTokenStores request was made on";
- EXPECT_TRUE(token_to_set_ || token_to_expect_) << "No work to do?";
AccessTokenStore::AccessTokenSet::const_iterator item =
access_token_set.find(ref_url_);
if (!token_to_expect_) {
@@ -141,6 +141,19 @@ IN_PROC_BROWSER_TEST_F(GeolocationAccessTokenStoreTest, SetAcrossInstances) {
DoTestStepAndWaitForResults(kRefServerUrl1, &ref_token1, NULL);
}
+IN_PROC_BROWSER_TEST_F(GeolocationAccessTokenStoreTest, OldUrlRemoval) {
+ const string16 ref_token1 = ASCIIToUTF16("jksdfo90,'s#\"#1*(");
+ ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // Set a token for the old default network provider url.
+ DoTestStepAndWaitForResults(kOldDefaultNetworkProviderUrl,
+ NULL, &ref_token1);
+ // Check that the token related to the old default network provider url
+ // was deleted.
+ DoTestStepAndWaitForResults(kOldDefaultNetworkProviderUrl,
+ NULL, NULL);
+}
+
IN_PROC_BROWSER_TEST_F(GeolocationAccessTokenStoreTest, CancelRequest) {
BrowserThread::PostTask(
kExpectedClientThreadId, FROM_HERE, NewRunnableFunction(
diff --git a/chrome/browser/geolocation/chrome_access_token_store.cc b/chrome/browser/geolocation/chrome_access_token_store.cc
index 2ba45a5..140261d 100644
--- a/chrome/browser/geolocation/chrome_access_token_store.cc
+++ b/chrome/browser/geolocation/chrome_access_token_store.cc
@@ -14,6 +14,12 @@
#include "content/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
+namespace {
+// This was the default location service url for Chrome versions 14 and earlier
+// but is no longer supported.
+const char* kOldDefaultNetworkProviderUrl = "https://www.google.com/loc/json";
+} // namespace
+
void ChromeAccessTokenStore::RegisterPrefs(PrefService* prefs) {
prefs->RegisterDictionaryPref(prefs::kGeolocationAccessToken);
}
@@ -26,11 +32,12 @@ void ChromeAccessTokenStore::LoadDictionaryStoreInUIThread(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (request->canceled())
return;
- const DictionaryValue* token_dictionary =
- g_browser_process->local_state()->GetDictionary(
- prefs::kGeolocationAccessToken);
+ DictionaryPrefUpdate update(g_browser_process->local_state(),
+ prefs::kGeolocationAccessToken);
+ DictionaryValue* token_dictionary = update.Get();
AccessTokenStore::AccessTokenSet access_token_set;
+ bool has_old_network_provider_url = false;
// 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();
@@ -38,9 +45,16 @@ void ChromeAccessTokenStore::LoadDictionaryStoreInUIThread(
GURL url(*it);
if (!url.is_valid())
continue;
+ if (url.spec() == kOldDefaultNetworkProviderUrl) {
+ has_old_network_provider_url = true;
+ continue;
+ }
token_dictionary->GetStringWithoutPathExpansion(*it,
&access_token_set[url]);
}
+ if (has_old_network_provider_url)
+ token_dictionary->RemoveWithoutPathExpansion(
+ kOldDefaultNetworkProviderUrl, NULL);
}
request->ForwardResultAsync(MakeTuple(access_token_set));
}
@@ -61,8 +75,8 @@ void SetAccessTokenOnUIThread(const GURL& server_url, const string16& token) {
server_url.spec(), Value::CreateStringValue(token));
}
-void ChromeAccessTokenStore::SaveAccessToken(
- const GURL& server_url, const string16& access_token) {
+void ChromeAccessTokenStore::SaveAccessToken(const GURL& server_url,
+ const string16& access_token) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableFunction(
&SetAccessTokenOnUIThread, server_url, access_token));
}