OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_LOCATION_LOCATION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_LOCATION_LOCATION_MANAGER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_LOCATION_LOCATION_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_LOCATION_LOCATION_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 } // namespace location | 29 } // namespace location |
30 } // namespace api | 30 } // namespace api |
31 | 31 |
32 // BrowserContext's manager of all location watch requests created by | 32 // BrowserContext's manager of all location watch requests created by |
33 // chrome.location API. Lives in the UI thread. | 33 // chrome.location API. Lives in the UI thread. |
34 class LocationManager : public BrowserContextKeyedAPI, | 34 class LocationManager : public BrowserContextKeyedAPI, |
35 public ExtensionRegistryObserver { | 35 public ExtensionRegistryObserver { |
36 public: | 36 public: |
37 explicit LocationManager(content::BrowserContext* context); | 37 explicit LocationManager(content::BrowserContext* context); |
38 virtual ~LocationManager(); | 38 ~LocationManager() override; |
39 | 39 |
40 // Adds location request for the given extension, and starts the location | 40 // Adds location request for the given extension, and starts the location |
41 // tracking. | 41 // tracking. |
42 void AddLocationRequest( | 42 void AddLocationRequest( |
43 const std::string& extension_id, | 43 const std::string& extension_id, |
44 const std::string& request_name, | 44 const std::string& request_name, |
45 const double* distance_update_threshold_meters, | 45 const double* distance_update_threshold_meters, |
46 const double* time_between_updates_ms); | 46 const double* time_between_updates_ms); |
47 | 47 |
48 // Cancels and removes the request with the given |name| for the given | 48 // Cancels and removes the request with the given |name| for the given |
(...skipping 21 matching lines...) Expand all Loading... |
70 static void GeopositionToApiCoordinates( | 70 static void GeopositionToApiCoordinates( |
71 const content::Geoposition& position, | 71 const content::Geoposition& position, |
72 api::location::Coordinates* coordinates); | 72 api::location::Coordinates* coordinates); |
73 | 73 |
74 // Sends a location update to the extension. | 74 // Sends a location update to the extension. |
75 void SendLocationUpdate(const std::string& extension_id, | 75 void SendLocationUpdate(const std::string& extension_id, |
76 const std::string& request_name, | 76 const std::string& request_name, |
77 const content::Geoposition& position); | 77 const content::Geoposition& position); |
78 | 78 |
79 // ExtensionRegistryObserver implementation. | 79 // ExtensionRegistryObserver implementation. |
80 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 80 void OnExtensionLoaded(content::BrowserContext* browser_context, |
81 const Extension* extension) override; | 81 const Extension* extension) override; |
82 virtual void OnExtensionUnloaded( | 82 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
83 content::BrowserContext* browser_context, | 83 const Extension* extension, |
84 const Extension* extension, | 84 UnloadedExtensionInfo::Reason reason) override; |
85 UnloadedExtensionInfo::Reason reason) override; | |
86 | 85 |
87 // BrowserContextKeyedAPI implementation. | 86 // BrowserContextKeyedAPI implementation. |
88 static const char* service_name() { return "LocationManager"; } | 87 static const char* service_name() { return "LocationManager"; } |
89 | 88 |
90 content::BrowserContext* const browser_context_; | 89 content::BrowserContext* const browser_context_; |
91 | 90 |
92 // A map of our pending location requests, per extension. | 91 // A map of our pending location requests, per extension. |
93 // Invariant: None of the LocationRequestLists are empty. | 92 // Invariant: None of the LocationRequestLists are empty. |
94 LocationRequestMap location_requests_; | 93 LocationRequestMap location_requests_; |
95 | 94 |
96 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 95 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
97 extension_registry_observer_; | 96 extension_registry_observer_; |
98 | 97 |
99 DISALLOW_COPY_AND_ASSIGN(LocationManager); | 98 DISALLOW_COPY_AND_ASSIGN(LocationManager); |
100 }; | 99 }; |
101 | 100 |
102 } // namespace extensions | 101 } // namespace extensions |
103 | 102 |
104 #endif // CHROME_BROWSER_EXTENSIONS_API_LOCATION_LOCATION_MANAGER_H_ | 103 #endif // CHROME_BROWSER_EXTENSIONS_API_LOCATION_LOCATION_MANAGER_H_ |
OLD | NEW |