| Index: content/browser/geolocation/location_arbitrator_impl.cc
|
| diff --git a/content/browser/geolocation/location_arbitrator_impl.cc b/content/browser/geolocation/location_arbitrator_impl.cc
|
| index b9dc791ac27c184d9d91fc510cff18083aca20fb..d8aba903f5498a6ee411da683630e5c468f554ab 100644
|
| --- a/content/browser/geolocation/location_arbitrator_impl.cc
|
| +++ b/content/browser/geolocation/location_arbitrator_impl.cc
|
| @@ -51,26 +51,31 @@ void LocationArbitratorImpl::OnPermissionGranted() {
|
| provider->OnPermissionGranted();
|
| }
|
|
|
| -void LocationArbitratorImpl::StartProviders(bool enable_high_accuracy) {
|
| - // GetAccessTokenStore() will return NULL for embedders not implementing
|
| - // the AccessTokenStore class, so we report an error to avoid JavaScript
|
| - // requests of location to wait eternally for a reply.
|
| - AccessTokenStore* access_token_store = GetAccessTokenStore();
|
| - if (!access_token_store) {
|
| - Geoposition position;
|
| - position.error_code = Geoposition::ERROR_CODE_PERMISSION_DENIED;
|
| - arbitrator_update_callback_.Run(position);
|
| - return;
|
| - }
|
| -
|
| +void LocationArbitratorImpl::StartProviders(bool enable_high_accuracy,
|
| + bool use_network) {
|
| // Stash options as OnAccessTokenStoresLoaded has not yet been called.
|
| is_running_ = true;
|
| enable_high_accuracy_ = enable_high_accuracy;
|
| +
|
| if (providers_.empty()) {
|
| - DCHECK(DefaultNetworkProviderURL().is_valid());
|
| - access_token_store->LoadAccessTokens(
|
| - base::Bind(&LocationArbitratorImpl::OnAccessTokenStoresLoaded,
|
| - base::Unretained(this)));
|
| + if (use_network) {
|
| + // GetAccessTokenStore() will return NULL for embedders not implementing
|
| + // the AccessTokenStore class, so we report an error to avoid JavaScript
|
| + // requests of location to wait eternally for a reply.
|
| + AccessTokenStore* access_token_store = GetAccessTokenStore();
|
| + if (!access_token_store) {
|
| + Geoposition position;
|
| + position.error_code = Geoposition::ERROR_CODE_PERMISSION_DENIED;
|
| + arbitrator_update_callback_.Run(position);
|
| + return;
|
| + }
|
| + DCHECK(DefaultNetworkProviderURL().is_valid());
|
| + access_token_store->LoadAccessTokens(
|
| + base::Bind(&LocationArbitratorImpl::OnAccessTokenStoresLoaded,
|
| + base::Unretained(this)));
|
| + } else {
|
| + RegisterSystemProvider();
|
| + }
|
| } else {
|
| DoStartProviders();
|
| }
|
| @@ -92,6 +97,14 @@ void LocationArbitratorImpl::StopProviders() {
|
| is_running_ = false;
|
| }
|
|
|
| +void LocationArbitratorImpl::RegisterSystemProvider() {
|
| + LocationProvider* provider = GetOverrideSystemLocationProvider();
|
| + if (!provider)
|
| + provider = NewSystemLocationProvider();
|
| + RegisterProvider(provider);
|
| + DoStartProviders();
|
| +}
|
| +
|
| void LocationArbitratorImpl::OnAccessTokenStoresLoaded(
|
| AccessTokenStore::AccessTokenMap access_token_map,
|
| net::URLRequestContextGetter* context_getter) {
|
| @@ -100,9 +113,7 @@ void LocationArbitratorImpl::OnAccessTokenStoresLoaded(
|
| // completed.
|
| return;
|
| }
|
| - LocationProvider* sole_provider =
|
| - GetContentClient()->browser()->SoleLocationProvider();
|
| - if (!sole_provider) {
|
| + if (GetContentClient()->browser()->UseNetworkLocationProviders()) {
|
| // If there are no access tokens, boot strap it with the default server URL.
|
| if (access_token_map.empty())
|
| access_token_map[DefaultNetworkProviderURL()];
|
| @@ -110,16 +121,8 @@ void LocationArbitratorImpl::OnAccessTokenStoresLoaded(
|
| RegisterProvider(NewNetworkLocationProvider(
|
| GetAccessTokenStore(), context_getter, entry.first, entry.second));
|
| }
|
| -
|
| - LocationProvider* provider =
|
| - GetContentClient()->browser()->OverrideSystemLocationProvider();
|
| - if (!provider)
|
| - provider = NewSystemLocationProvider();
|
| - RegisterProvider(provider);
|
| - } else {
|
| - RegisterProvider(sole_provider);
|
| }
|
| - DoStartProviders();
|
| + RegisterSystemProvider();
|
| }
|
|
|
| void LocationArbitratorImpl::RegisterProvider(
|
| @@ -176,6 +179,10 @@ LocationProvider* LocationArbitratorImpl::NewSystemLocationProvider() {
|
| #endif
|
| }
|
|
|
| +LocationProvider* LocationArbitratorImpl::GetOverrideSystemLocationProvider() {
|
| + return GetContentClient()->browser()->OverrideSystemLocationProvider();
|
| +}
|
| +
|
| base::Time LocationArbitratorImpl::GetTimeNow() const {
|
| return base::Time::Now();
|
| }
|
|
|