diff options
author | allanwoj@chromium.org <allanwoj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 11:38:40 +0000 |
---|---|---|
committer | allanwoj@chromium.org <allanwoj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 11:38:40 +0000 |
commit | 04d75b6f37e104c672db22cbbba84fa3b21a510d (patch) | |
tree | aa891d17f51169fbb698da2bc3ad6181939b0fe5 /chrome | |
parent | 48ba228626cee0fba98a0d204580bc0aacb750bb (diff) | |
download | chromium_src-04d75b6f37e104c672db22cbbba84fa3b21a510d.zip chromium_src-04d75b6f37e104c672db22cbbba84fa3b21a510d.tar.gz chromium_src-04d75b6f37e104c672db22cbbba84fa3b21a510d.tar.bz2 |
Location provider using Windows 7 Location API
Implementation of a location provider that uses the Windows 7 Location API. Currently uses polling to get the users location, I will update this to use signals provided by the API in a future patch.
BUG=45535
TEST=Two test files included.
Review URL: http://codereview.chromium.org/3015053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/geolocation/gps_location_provider_linux.cc | 2 | ||||
-rw-r--r-- | chrome/browser/geolocation/location_arbitrator.cc | 12 | ||||
-rw-r--r-- | chrome/browser/geolocation/location_arbitrator.h | 2 | ||||
-rw-r--r-- | chrome/browser/geolocation/location_arbitrator_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/geolocation/location_provider.cc | 5 | ||||
-rw-r--r-- | chrome/browser/geolocation/location_provider.h | 10 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 12 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 |
10 files changed, 35 insertions, 18 deletions
diff --git a/chrome/browser/geolocation/gps_location_provider_linux.cc b/chrome/browser/geolocation/gps_location_provider_linux.cc index 9c918a9..4b23ff2 100644 --- a/chrome/browser/geolocation/gps_location_provider_linux.cc +++ b/chrome/browser/geolocation/gps_location_provider_linux.cc @@ -121,6 +121,6 @@ void GpsLocationProviderLinux::ScheduleNextGpsPoll(int interval) { interval); } -LocationProviderBase* NewGpsLocationProvider() { +LocationProviderBase* NewSystemLocationProvider() { return new GpsLocationProviderLinux(LibGps::New); } diff --git a/chrome/browser/geolocation/location_arbitrator.cc b/chrome/browser/geolocation/location_arbitrator.cc index 050407b..bf47ed7 100644 --- a/chrome/browser/geolocation/location_arbitrator.cc +++ b/chrome/browser/geolocation/location_arbitrator.cc @@ -105,10 +105,10 @@ class DefaultLocationProviderFactory return ::NewNetworkLocationProvider(access_token_store, context, url, access_token); } - virtual LocationProviderBase* NewGpsLocationProvider() { + virtual LocationProviderBase* NewSystemLocationProvider() { if (g_provider_factory_function_for_test) return NULL; - return ::NewGpsLocationProvider(); + return ::NewSystemLocationProvider(); } }; @@ -222,7 +222,7 @@ void GeolocationArbitratorImpl::OnAccessTokenStoresLoaded( i->first, i->second), &providers_); } - RegisterProvider(provider_factory_->NewGpsLocationProvider(), + RegisterProvider(provider_factory_->NewSystemLocationProvider(), &providers_); StartProviders(); } @@ -255,9 +255,9 @@ bool GeolocationArbitratorImpl::IsNewPositionBetter( // Updates location_info if it's better than what we currently have, // or if it's a newer update from the same provider. if (!old_position.IsValidFix()) { - // Older location wasn't locked. - return true; - } + // Older location wasn't locked. + return true; + } if (new_position.IsValidFix()) { // New location is locked, let's check if it's any better. if (old_position.accuracy >= new_position.accuracy) { diff --git a/chrome/browser/geolocation/location_arbitrator.h b/chrome/browser/geolocation/location_arbitrator.h index eeb2e9c..a4d166f 100644 --- a/chrome/browser/geolocation/location_arbitrator.h +++ b/chrome/browser/geolocation/location_arbitrator.h @@ -43,7 +43,7 @@ class GeolocationArbitrator : public base::RefCounted<GeolocationArbitrator> { URLRequestContextGetter* context, const GURL& url, const string16& access_token) = 0; - virtual LocationProviderBase* NewGpsLocationProvider() = 0; + virtual LocationProviderBase* NewSystemLocationProvider() = 0; protected: friend class base::RefCounted<ProviderFactory>; diff --git a/chrome/browser/geolocation/location_arbitrator_unittest.cc b/chrome/browser/geolocation/location_arbitrator_unittest.cc index 669ac45..76351ac 100644 --- a/chrome/browser/geolocation/location_arbitrator_unittest.cc +++ b/chrome/browser/geolocation/location_arbitrator_unittest.cc @@ -16,7 +16,7 @@ namespace { class MockLocationObserver : public GeolocationArbitrator::Delegate { public: void InvalidateLastPosition() { - last_position_.accuracy = -1; + last_position_.latitude = 100; last_position_.error_code = Geoposition::ERROR_CODE_NONE; ASSERT_FALSE(last_position_.IsInitialized()); } @@ -40,7 +40,7 @@ class MockProviderFactory : public GeolocationArbitrator::ProviderFactory { const string16& access_token) { return new MockLocationProvider(&cell_); } - virtual LocationProviderBase* NewGpsLocationProvider() { + virtual LocationProviderBase* NewSystemLocationProvider() { return new MockLocationProvider(&gps_); } diff --git a/chrome/browser/geolocation/location_provider.cc b/chrome/browser/geolocation/location_provider.cc index cdfd797..ecd066e 100644 --- a/chrome/browser/geolocation/location_provider.cc +++ b/chrome/browser/geolocation/location_provider.cc @@ -56,9 +56,8 @@ void LocationProviderBase::UpdateListeners() { } } -// Currently only Linux has a GPS provider. -#if !defined(OS_LINUX) -LocationProviderBase* NewGpsLocationProvider() { +#if !defined(OS_LINUX) && !defined(OS_WIN) +LocationProviderBase* NewSystemLocationProvider() { return NULL; } #endif diff --git a/chrome/browser/geolocation/location_provider.h b/chrome/browser/geolocation/location_provider.h index 08e191e..6c4d8da 100644 --- a/chrome/browser/geolocation/location_provider.h +++ b/chrome/browser/geolocation/location_provider.h @@ -7,8 +7,8 @@ // providers to obtain a position fix. // // This file declares a base class to be used by all location providers. -// Primarily, this class declares interface methods to be implemented by derived -// classes. +// Primarily, this class declares interface methods to be implemented by +// derived classes. #ifndef CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ #define CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ @@ -85,13 +85,13 @@ class LocationProviderBase : public NonThreadSafe { ListenerMap listeners_; }; -// Factory functions for the various types of location provider to abstract over -// the platform-dependent implementations. -LocationProviderBase* NewGpsLocationProvider(); +// Factory functions for the various types of location provider to abstract +// over the platform-dependent implementations. LocationProviderBase* NewNetworkLocationProvider( AccessTokenStore* access_token_store, URLRequestContextGetter* context, const GURL& url, const string16& access_token); +LocationProviderBase* NewSystemLocationProvider(); #endif // CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 8c05212..45ed49f 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1496,6 +1496,10 @@ 'browser/geolocation/wifi_data_provider_mac.h', 'browser/geolocation/wifi_data_provider_win.cc', 'browser/geolocation/wifi_data_provider_win.h', + 'browser/geolocation/win7_location_api_win.cc', + 'browser/geolocation/win7_location_api_win.h', + 'browser/geolocation/win7_location_provider_win.cc', + 'browser/geolocation/win7_location_provider_win.h', 'browser/google_service_auth_error.h', 'browser/google_update.cc', 'browser/google_update.h', @@ -3252,6 +3256,14 @@ 'export_dependent_settings': [ '../views/views.gyp:views', ], + 'direct_dependent_settings': { + 'link_settings': { + 'libraries': [ + '-llocationapi.lib', + '-lsensorsapi.lib', + ], + } + }, 'sources': [ 'browser/net/ssl_config_service_manager_system.cc', # Using built-in rule in vstudio for midl. diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index ba62cf2..d7f5e26 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -962,6 +962,8 @@ 'browser/geolocation/wifi_data_provider_common_unittest.cc', 'browser/geolocation/wifi_data_provider_unittest_chromeos.cc', 'browser/geolocation/wifi_data_provider_unittest_win.cc', + 'browser/geolocation/win7_location_api_unittest_win.cc', + 'browser/geolocation/win7_location_provider_unittest_win.cc', 'browser/global_keyboard_shortcuts_mac_unittest.mm', 'browser/google_update_settings_unittest.cc', 'browser/google_url_tracker_unittest.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 5a6b770..2242966 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -470,6 +470,9 @@ const char kEnableVideoLogging[] = "enable-video-logging"; // Order of the listed sub-arguments does not matter. const char kEnableWatchdog[] = "enable-watchdog"; +// Enables Windows 7 Location Platform provider for geolocation API. +const char kEnableWin7Location[] = "enable-win7-location"; + // Disable WebKit's XSSAuditor. The XSSAuditor mitigates reflective XSS. const char kEnableXSSAuditor[] = "enable-xss-auditor"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 8fa9a2d..9ffd444 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -149,6 +149,7 @@ extern const char kEnableVideoFullscreen[]; extern const char kEnableVideoLayering[]; extern const char kEnableVideoLogging[]; extern const char kEnableWatchdog[]; +extern const char kEnableWin7Location[]; extern const char kEnableXSSAuditor[]; // Experimental features. extern const char kExperimentalEnableNegotiateAuth[]; |