| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_ | 5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_ |
| 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_ | 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "content/browser/geolocation/geolocation_observer.h" | 12 #include "content/browser/geolocation/geolocation_observer.h" |
| 13 #include "content/common/content_export.h" |
| 13 #include "content/common/geoposition.h" | 14 #include "content/common/geoposition.h" |
| 14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 15 | 16 |
| 16 class GeolocationArbitrator; | 17 class GeolocationArbitrator; |
| 17 | 18 |
| 18 template<typename Type> | 19 template<typename Type> |
| 19 struct DefaultSingletonTraits; | 20 struct DefaultSingletonTraits; |
| 20 | 21 |
| 21 // This is the main API to the geolocaiton subsystem. The application | 22 // This is the main API to the geolocaiton subsystem. The application |
| 22 // will hold a single instance of this class, and can register multiple | 23 // will hold a single instance of this class, and can register multiple |
| (...skipping 11 matching lines...) Expand all Loading... |
| 34 // provider whilst it is registered. | 35 // provider whilst it is registered. |
| 35 // If an existing observer is added a second time it's options are updated | 36 // If an existing observer is added a second time it's options are updated |
| 36 // but only a single call to RemoveObserver() is required to remove it. | 37 // but only a single call to RemoveObserver() is required to remove it. |
| 37 void AddObserver(GeolocationObserver* delegate, | 38 void AddObserver(GeolocationObserver* delegate, |
| 38 const GeolocationObserverOptions& update_options); | 39 const GeolocationObserverOptions& update_options); |
| 39 | 40 |
| 40 // Remove a previously registered observer. No-op if not previously registered | 41 // Remove a previously registered observer. No-op if not previously registered |
| 41 // via AddObserver(). Returns true if the observer was removed. | 42 // via AddObserver(). Returns true if the observer was removed. |
| 42 bool RemoveObserver(GeolocationObserver* delegate); | 43 bool RemoveObserver(GeolocationObserver* delegate); |
| 43 | 44 |
| 44 void OnPermissionGranted(const GURL& requesting_frame); | 45 CONTENT_EXPORT void OnPermissionGranted(const GURL& requesting_frame); |
| 45 bool HasPermissionBeenGranted() const; | 46 bool HasPermissionBeenGranted() const; |
| 46 | 47 |
| 47 // GeolocationObserver | 48 // GeolocationObserver |
| 48 virtual void OnLocationUpdate(const Geoposition& position); | 49 virtual void OnLocationUpdate(const Geoposition& position); |
| 49 | 50 |
| 50 // Gets a pointer to the singleton instance of the location relayer, which | 51 // Gets a pointer to the singleton instance of the location relayer, which |
| 51 // is in turn bound to the browser's global context objects. Ownership is NOT | 52 // is in turn bound to the browser's global context objects. Ownership is NOT |
| 52 // returned. | 53 // returned. |
| 53 static GeolocationProvider* GetInstance(); | 54 CONTENT_EXPORT static GeolocationProvider* GetInstance(); |
| 54 | 55 |
| 55 typedef std::map<GeolocationObserver*, GeolocationObserverOptions> | 56 typedef std::map<GeolocationObserver*, GeolocationObserverOptions> |
| 56 ObserverMap; | 57 ObserverMap; |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 friend struct DefaultSingletonTraits<GeolocationProvider>; | 60 friend struct DefaultSingletonTraits<GeolocationProvider>; |
| 60 virtual ~GeolocationProvider(); | 61 virtual ~GeolocationProvider(); |
| 61 | 62 |
| 62 bool OnClientThread() const; | 63 bool OnClientThread() const; |
| 63 bool OnGeolocationThread() const; | 64 bool OnGeolocationThread() const; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 91 GURL most_recent_authorized_frame_; | 92 GURL most_recent_authorized_frame_; |
| 92 Geoposition position_; | 93 Geoposition position_; |
| 93 | 94 |
| 94 // Only to be used on the geolocation thread. | 95 // Only to be used on the geolocation thread. |
| 95 GeolocationArbitrator* arbitrator_; | 96 GeolocationArbitrator* arbitrator_; |
| 96 | 97 |
| 97 DISALLOW_COPY_AND_ASSIGN(GeolocationProvider); | 98 DISALLOW_COPY_AND_ASSIGN(GeolocationProvider); |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_ | 101 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_ |
| OLD | NEW |