Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/browser/extensions/api/location/location_manager.h

Issue 166053003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: | Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" 12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
13 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 15
16 class Profile; 16 class Profile;
17 17
18 namespace content { 18 namespace content {
19 class BrowserContext;
19 struct Geoposition; 20 struct Geoposition;
20 } // namespace content 21 } // namespace content
21 22
22 namespace extensions { 23 namespace extensions {
23 class LocationManager; 24 class LocationManager;
24 class LocationRequest; 25 class LocationRequest;
25 26
26 namespace api { 27 namespace api {
27 namespace location { 28 namespace location {
28 29
29 struct Coordinates; 30 struct Coordinates;
30 31
31 } // namespace location 32 } // namespace location
32 } // namespace api 33 } // namespace api
33 34
34 // Profile's manager of all location watch requests created by chrome.location 35 // Profile's manager of all location watch requests created by chrome.location
35 // API. Lives in the UI thread. 36 // API. Lives in the UI thread.
36 class LocationManager 37 class LocationManager
37 : public ProfileKeyedAPI, 38 : public ProfileKeyedAPI,
38 public content::NotificationObserver, 39 public content::NotificationObserver,
39 public base::SupportsWeakPtr<LocationManager> { 40 public base::SupportsWeakPtr<LocationManager> {
40 public: 41 public:
41 explicit LocationManager(Profile* profile); 42 explicit LocationManager(content::BrowserContext* context);
42 virtual ~LocationManager(); 43 virtual ~LocationManager();
43 44
44 // Adds location request for the given extension, and starts the location 45 // Adds location request for the given extension, and starts the location
45 // tracking. 46 // tracking.
46 void AddLocationRequest( 47 void AddLocationRequest(
47 const std::string& extension_id, 48 const std::string& extension_id,
48 const std::string& request_name, 49 const std::string& request_name,
49 const double* distance_update_threshold_meters, 50 const double* distance_update_threshold_meters,
50 const double* time_between_updates_ms); 51 const double* time_between_updates_ms);
51 52
52 // Cancels and removes the request with the given |name| for the given 53 // Cancels and removes the request with the given |name| for the given
53 // extension. 54 // extension.
54 void RemoveLocationRequest(const std::string& extension_id, 55 void RemoveLocationRequest(const std::string& extension_id,
55 const std::string& name); 56 const std::string& name);
56 57
57 // ProfileKeyedAPI implementation. 58 // ProfileKeyedAPI implementation.
58 static ProfileKeyedAPIFactory<LocationManager>* GetFactoryInstance(); 59 static ProfileKeyedAPIFactory<LocationManager>* GetFactoryInstance();
59 60
60 // Convenience method to get the LocationManager for a profile. 61 // Convenience method to get the LocationManager for a profile.
61 static LocationManager* Get(Profile* profile); 62 static LocationManager* Get(content::BrowserContext* context);
62 63
63 private: 64 private:
64 friend class LocationRequest; 65 friend class LocationRequest;
65 friend class ProfileKeyedAPIFactory<LocationManager>; 66 friend class ProfileKeyedAPIFactory<LocationManager>;
66 67
67 typedef std::string ExtensionId; 68 typedef std::string ExtensionId;
68 typedef scoped_refptr<LocationRequest> LocationRequestPointer; 69 typedef scoped_refptr<LocationRequest> LocationRequestPointer;
69 typedef std::multimap<ExtensionId, LocationRequestPointer> LocationRequestMap; 70 typedef std::multimap<ExtensionId, LocationRequestPointer> LocationRequestMap;
70 typedef LocationRequestMap::iterator LocationRequestIterator; 71 typedef LocationRequestMap::iterator LocationRequestIterator;
71 72
(...skipping 25 matching lines...) Expand all
97 98
98 // Used for tracking registrations to profile's extensions events. 99 // Used for tracking registrations to profile's extensions events.
99 content::NotificationRegistrar registrar_; 100 content::NotificationRegistrar registrar_;
100 101
101 DISALLOW_COPY_AND_ASSIGN(LocationManager); 102 DISALLOW_COPY_AND_ASSIGN(LocationManager);
102 }; 103 };
103 104
104 } // namespace extensions 105 } // namespace extensions
105 106
106 #endif // CHROME_BROWSER_EXTENSIONS_API_LOCATION_LOCATION_MANAGER_H_ 107 #endif // CHROME_BROWSER_EXTENSIONS_API_LOCATION_LOCATION_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/input_ime/input_ime_api.cc ('k') | chrome/browser/extensions/api/location/location_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698