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

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

Issue 6597044: Revert 76228 - Move core pieces of geolocation from chrome to content.This is... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_
6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_
7 #pragma once
8
9 #include <map>
10
11 #include "base/threading/thread.h"
12 #include "chrome/common/geoposition.h"
13 #include "content/browser/geolocation/geolocation_observer.h"
14 #include "googleurl/src/gurl.h"
15
16 class GeolocationArbitrator;
17
18 template<typename Type>
19 struct DefaultSingletonTraits;
20
21 // 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 // observers which will be notified of location updates. Underlying location
24 // arbitrator will only be enabled whilst there is at least one observer
25 // registered.
26 class GeolocationProvider : public base::Thread, public GeolocationObserver {
27 public:
28 GeolocationProvider();
29
30 // Must be called from the same thread as the GeolocationProvider was created
31 // on. The GeolocationObserverOptions passed are used as a 'hint' for the
32 // provider preferences for this particular observer, however the observer
33 // could receive callbacks for best available locations from any active
34 // provider whilst it is registered.
35 // 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 void AddObserver(GeolocationObserver* delegate,
38 const GeolocationObserverOptions& update_options);
39
40 // Remove a previously registered observer. No-op if not previously registered
41 // via AddObserver(). Returns true if the observer was removed.
42 bool RemoveObserver(GeolocationObserver* delegate);
43
44 void OnPermissionGranted(const GURL& requesting_frame);
45 bool HasPermissionBeenGranted() const;
46
47 // GeolocationObserver
48 virtual void OnLocationUpdate(const Geoposition& position);
49
50 // 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 // returned.
53 static GeolocationProvider* GetInstance();
54
55 typedef std::map<GeolocationObserver*, GeolocationObserverOptions>
56 ObserverMap;
57
58 private:
59 friend struct DefaultSingletonTraits<GeolocationProvider>;
60 ~GeolocationProvider();
61
62 bool OnClientThread() const;
63 bool OnGeolocationThread() const;
64
65 // When the observer list changes, we may start the thread and the required
66 // providers, or stop them.
67 void OnObserversChanged();
68
69 // Stop the providers when there are no more observers. Note that once our
70 // thread is started, we'll keep it alive (but with no pending messages).
71 void StopProviders();
72
73 // Starts or updates the observers' geolocation options
74 // (delegates to arbitrator).
75 void StartProviders(const GeolocationObserverOptions& options);
76
77 // Update the providers on the geolocation thread, which must be running.
78 void InformProvidersPermissionGranted(const GURL& requesting_frame);
79
80 // Notifies observers when a new position fix is available.
81 void NotifyObservers(const Geoposition& position);
82
83 // Thread
84 virtual void Init();
85 virtual void CleanUp();
86
87 scoped_refptr<base::MessageLoopProxy> client_loop_;
88
89 // Only used on client thread
90 ObserverMap observers_;
91 GURL most_recent_authorized_frame_;
92 Geoposition position_;
93
94 // Only to be used on the geolocation thread.
95 GeolocationArbitrator* arbitrator_;
96
97 DISALLOW_COPY_AND_ASSIGN(GeolocationProvider);
98 };
99
100 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/browser/geolocation/geolocation_permission_context.h ('k') | content/browser/geolocation/geolocation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698