| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A location provider provides position information from a particular source | 5 // A location provider provides position information from a particular source |
| 6 // (GPS, network etc). | 6 // (GPS, network etc). |
| 7 // | 7 // |
| 8 // This file declares a base class to be used by all location providers. | 8 // This file declares a base class to be used by all location providers. |
| 9 // Primarily, this class declares interface methods to be implemented by | 9 // Primarily, this class declares interface methods to be implemented by |
| 10 // derived classes. | 10 // derived classes. |
| 11 | 11 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // which prevented the provider from starting. | 68 // which prevented the provider from starting. |
| 69 virtual bool StartProvider(bool high_accuracy) = 0; | 69 virtual bool StartProvider(bool high_accuracy) = 0; |
| 70 virtual void StopProvider() = 0; | 70 virtual void StopProvider() = 0; |
| 71 // Gets the current best position estimate. | 71 // Gets the current best position estimate. |
| 72 virtual void GetPosition(Geoposition* position) = 0; | 72 virtual void GetPosition(Geoposition* position) = 0; |
| 73 // Provides a hint to the provider that new location data is needed as soon | 73 // Provides a hint to the provider that new location data is needed as soon |
| 74 // as possible. Default implementation does nothing. | 74 // as possible. Default implementation does nothing. |
| 75 virtual void UpdatePosition() {} | 75 virtual void UpdatePosition() {} |
| 76 // Delegated to the provider by GeolocationArbitrator. See the corresponding | 76 // Delegated to the provider by GeolocationArbitrator. See the corresponding |
| 77 // method on that class for more details. | 77 // method on that class for more details. |
| 78 virtual void OnPermissionGranted(const GURL& requesting_frame) {} | 78 virtual void OnPermissionGranted() {} |
| 79 | 79 |
| 80 bool has_listeners() const; | 80 bool has_listeners() const; |
| 81 | 81 |
| 82 protected: | 82 protected: |
| 83 LocationProviderBase(); | 83 LocationProviderBase(); |
| 84 | 84 |
| 85 // Inform listeners that a new position or error is available, using | 85 // Inform listeners that a new position or error is available, using |
| 86 // LocationUpdateAvailable. | 86 // LocationUpdateAvailable. |
| 87 void UpdateListeners(); | 87 void UpdateListeners(); |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 // The listeners registered to this provider. For each listener, we store a | 90 // The listeners registered to this provider. For each listener, we store a |
| 91 // ref count. | 91 // ref count. |
| 92 typedef std::map<ListenerInterface*, int> ListenerMap; | 92 typedef std::map<ListenerInterface*, int> ListenerMap; |
| 93 ListenerMap listeners_; | 93 ListenerMap listeners_; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 // Factory functions for the various types of location provider to abstract | 96 // Factory functions for the various types of location provider to abstract |
| 97 // over the platform-dependent implementations. | 97 // over the platform-dependent implementations. |
| 98 CONTENT_EXPORT LocationProviderBase* NewNetworkLocationProvider( | 98 CONTENT_EXPORT LocationProviderBase* NewNetworkLocationProvider( |
| 99 content::AccessTokenStore* access_token_store, | 99 content::AccessTokenStore* access_token_store, |
| 100 net::URLRequestContextGetter* context, | 100 net::URLRequestContextGetter* context, |
| 101 const GURL& url, | 101 const GURL& url, |
| 102 const string16& access_token); | 102 const string16& access_token); |
| 103 LocationProviderBase* NewSystemLocationProvider(); | 103 LocationProviderBase* NewSystemLocationProvider(); |
| 104 | 104 |
| 105 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ | 105 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ |
| OLD | NEW |