Chromium Code Reviews| 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 d6cb78b1657aa34b3567a864563d71f8477ceffb..b08bb7b11f911eb55666304237513683dba0da71 100644 |
| --- a/content/browser/geolocation/location_arbitrator_impl.cc |
| +++ b/content/browser/geolocation/location_arbitrator_impl.cc |
| @@ -55,22 +55,27 @@ void LocationArbitratorImpl::StartProviders(bool enable_high_accuracy) { |
| // GetAccessTokenStore() will return NULL for embedders not implementing |
|
Michael van Ouwerkerk
2016/06/02 10:04:32
Keep this comment with the code it documents.
CJ
2016/06/02 22:12:05
Done.
|
| // 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; |
| - } |
| // 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 (GetContentClient()->browser()->UseNetworkLocationProviders()) { |
| + 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,15 @@ void LocationArbitratorImpl::StopProviders() { |
| is_running_ = false; |
| } |
| +void LocationArbitratorImpl::RegisterSystemProvider() { |
| + LocationProvider* provider = |
| + GetContentClient()->browser()->OverrideSystemLocationProvider(); |
| + if (!provider) |
| + provider = NewSystemLocationProvider(); |
| + RegisterProvider(provider); |
| + DoStartProviders(); |
| +} |
| + |
| void LocationArbitratorImpl::OnAccessTokenStoresLoaded( |
| AccessTokenStore::AccessTokenMap access_token_map, |
| net::URLRequestContextGetter* context_getter) { |
| @@ -100,20 +114,16 @@ void LocationArbitratorImpl::OnAccessTokenStoresLoaded( |
| // completed. |
| return; |
| } |
| - // If there are no access tokens, boot strap it with the default server URL. |
| - if (access_token_map.empty()) |
| - access_token_map[DefaultNetworkProviderURL()]; |
| - for (const auto& entry : access_token_map) { |
| - RegisterProvider(NewNetworkLocationProvider( |
| - GetAccessTokenStore(), context_getter, entry.first, entry.second)); |
| + 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()]; |
| + for (const auto& entry : access_token_map) { |
| + RegisterProvider(NewNetworkLocationProvider( |
| + GetAccessTokenStore(), context_getter, entry.first, entry.second)); |
| + } |
| } |
| - |
| - LocationProvider* provider = |
| - GetContentClient()->browser()->OverrideSystemLocationProvider(); |
| - if (!provider) |
| - provider = NewSystemLocationProvider(); |
| - RegisterProvider(provider); |
| - DoStartProviders(); |
| + RegisterSystemProvider(); |
| } |
| void LocationArbitratorImpl::RegisterProvider( |