Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.location.Criteria; | 8 import android.location.Criteria; |
| 9 import android.location.Location; | 9 import android.location.Location; |
| 10 import android.location.LocationListener; | 10 import android.location.LocationListener; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 ensureLocationManagerCreated(); | 143 ensureLocationManagerCreated(); |
| 144 if (usePassiveOneShotLocation()) return; | 144 if (usePassiveOneShotLocation()) return; |
| 145 | 145 |
| 146 assert !mIsRunning; | 146 assert !mIsRunning; |
| 147 mIsRunning = true; | 147 mIsRunning = true; |
| 148 | 148 |
| 149 // We're running on the main thread. The C++ side is responsible to | 149 // We're running on the main thread. The C++ side is responsible to |
| 150 // bounce notifications to the Geolocation thread as they arrive in the mainLooper. | 150 // bounce notifications to the Geolocation thread as they arrive in the mainLooper. |
| 151 try { | 151 try { |
| 152 Criteria criteria = new Criteria(); | 152 Criteria criteria = new Criteria(); |
| 153 if (isGpsEnabled) | |
| 154 criteria.setAccuracy(Criteria.ACCURACY_FINE); | |
|
jdduke (slow)
2014/09/07 13:19:26
The if body should be on the same line as the if c
| |
| 153 mLocationManager.requestLocationUpdates(0, 0, criteria, this, | 155 mLocationManager.requestLocationUpdates(0, 0, criteria, this, |
| 154 ThreadUtils.getUiThreadLooper()); | 156 ThreadUtils.getUiThreadLooper()); |
| 155 if (isGpsEnabled) { | |
| 156 criteria.setAccuracy(Criteria.ACCURACY_FINE); | |
| 157 mLocationManager.requestLocationUpdates(0, 0, criteria, this , | |
| 158 ThreadUtils.getUiThreadLooper()); | |
| 159 } | |
| 160 } catch (SecurityException e) { | 157 } catch (SecurityException e) { |
| 161 Log.e(TAG, "Caught security exception registering for location u pdates from " + | 158 Log.e(TAG, "Caught security exception registering for location u pdates from " + |
| 162 "system. This should only happen in DumpRenderTree."); | 159 "system. This should only happen in DumpRenderTree."); |
| 163 } catch (IllegalArgumentException e) { | 160 } catch (IllegalArgumentException e) { |
| 164 Log.e(TAG, "Caught IllegalArgumentException registering for loca tion updates."); | 161 Log.e(TAG, "Caught IllegalArgumentException registering for loca tion updates."); |
| 165 } | 162 } |
| 166 } | 163 } |
| 167 | 164 |
| 168 /** | 165 /** |
| 169 * Unregisters this object from the location service. | 166 * Unregisters this object from the location service. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 200 */ | 197 */ |
| 201 private boolean isOnlyPassiveLocationProviderEnabled() { | 198 private boolean isOnlyPassiveLocationProviderEnabled() { |
| 202 List<String> providers = mLocationManager.getProviders(true); | 199 List<String> providers = mLocationManager.getProviders(true); |
| 203 return providers != null && providers.size() == 1 | 200 return providers != null && providers.size() == 1 |
| 204 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER) ; | 201 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER) ; |
| 205 } | 202 } |
| 206 } | 203 } |
| 207 } | 204 } |
| 208 | 205 |
| 209 | 206 |
| OLD | NEW |