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

Side by Side Diff: content/browser/geolocation/geolocation_provider.h

Issue 10316007: Make the Geoposition helper class public (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed. Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012 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 #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/content_export.h"
14 #include "content/common/geoposition.h" 14 #include "content/public/common/geoposition.h"
15 15
16 class GeolocationArbitrator; 16 class GeolocationArbitrator;
17 17
18 template<typename Type> 18 template<typename Type>
19 struct DefaultSingletonTraits; 19 struct DefaultSingletonTraits;
20 20
21 // This is the main API to the geolocation subsystem. The application 21 // This is the main API to the geolocation subsystem. The application
22 // will hold a single instance of this class, and can register multiple 22 // will hold a single instance of this class, and can register multiple
23 // observers which will be notified of location updates. Underlying location 23 // observers which will be notified of location updates. Underlying location
24 // arbitrator will only be enabled whilst there is at least one observer 24 // arbitrator will only be enabled whilst there is at least one observer
(...skipping 14 matching lines...) Expand all
39 const GeolocationObserverOptions& update_options); 39 const GeolocationObserverOptions& update_options);
40 40
41 // Remove a previously registered observer. No-op if not previously registered 41 // Remove a previously registered observer. No-op if not previously registered
42 // via AddObserver(). Returns true if the observer was removed. 42 // via AddObserver(). Returns true if the observer was removed.
43 bool RemoveObserver(GeolocationObserver* delegate); 43 bool RemoveObserver(GeolocationObserver* delegate);
44 44
45 void OnPermissionGranted(); 45 void OnPermissionGranted();
46 bool HasPermissionBeenGranted() const; 46 bool HasPermissionBeenGranted() const;
47 47
48 // GeolocationObserver 48 // GeolocationObserver
49 virtual void OnLocationUpdate(const Geoposition& position) OVERRIDE; 49 virtual void OnLocationUpdate(const content::Geoposition& position) OVERRIDE;
50 50
51 // Overrides the location for automation/testing. Updates any current 51 // Overrides the location for automation/testing. Updates any current
52 // observers with the overriden position. Any further updates from location 52 // observers with the overriden position. Any further updates from location
53 // providers will be ignored. 53 // providers will be ignored.
54 void OverrideLocationForTesting(const Geoposition& override_position); 54 void OverrideLocationForTesting(const content::Geoposition& override_position) ;
55 55
56 // Gets a pointer to the singleton instance of the location relayer, which 56 // Gets a pointer to the singleton instance of the location relayer, which
57 // is in turn bound to the browser's global context objects. Ownership is NOT 57 // is in turn bound to the browser's global context objects. Ownership is NOT
58 // returned. 58 // returned.
59 static GeolocationProvider* GetInstance(); 59 static GeolocationProvider* GetInstance();
60 60
61 typedef std::map<GeolocationObserver*, GeolocationObserverOptions> 61 typedef std::map<GeolocationObserver*, GeolocationObserverOptions>
62 ObserverMap; 62 ObserverMap;
63 63
64 private: 64 private:
(...skipping 12 matching lines...) Expand all
77 void StopProviders(); 77 void StopProviders();
78 78
79 // Starts or updates the observers' geolocation options 79 // Starts or updates the observers' geolocation options
80 // (delegates to arbitrator). 80 // (delegates to arbitrator).
81 void StartProviders(const GeolocationObserverOptions& options); 81 void StartProviders(const GeolocationObserverOptions& options);
82 82
83 // Update the providers on the geolocation thread, which must be running. 83 // Update the providers on the geolocation thread, which must be running.
84 void InformProvidersPermissionGranted(); 84 void InformProvidersPermissionGranted();
85 85
86 // Notifies observers when a new position fix is available. 86 // Notifies observers when a new position fix is available.
87 void NotifyObservers(const Geoposition& position); 87 void NotifyObservers(const content::Geoposition& position);
88 88
89 // Thread 89 // Thread
90 virtual void Init() OVERRIDE; 90 virtual void Init() OVERRIDE;
91 virtual void CleanUp() OVERRIDE; 91 virtual void CleanUp() OVERRIDE;
92 92
93 scoped_refptr<base::MessageLoopProxy> client_loop_; 93 scoped_refptr<base::MessageLoopProxy> client_loop_;
94 94
95 // Only used on client thread 95 // Only used on client thread
96 ObserverMap observers_; 96 ObserverMap observers_;
97 bool is_permission_granted_; 97 bool is_permission_granted_;
98 Geoposition position_; 98 content::Geoposition position_;
99 // True only in testing, where we want to use a custom position. 99 // True only in testing, where we want to use a custom position.
100 bool ignore_location_updates_; 100 bool ignore_location_updates_;
101 101
102 // Only to be used on the geolocation thread. 102 // Only to be used on the geolocation thread.
103 GeolocationArbitrator* arbitrator_; 103 GeolocationArbitrator* arbitrator_;
104 104
105 DISALLOW_COPY_AND_ASSIGN(GeolocationProvider); 105 DISALLOW_COPY_AND_ASSIGN(GeolocationProvider);
106 }; 106 };
107 107
108 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_ 108 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698