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

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

Issue 2104193002: Geolocation: Extract GeolocationProvider::Delegate into GeolocationDelegate (no new code) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jam@ nit: content/browser/geolocation/geolocation_delegate.cc --> content/public/browser Created 4 years, 5 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_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_
6 #define CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ 6 #define CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback_list.h" 10 #include "base/callback_list.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 12
13 namespace content { 13 namespace content {
14 class AccessTokenStore;
15 struct Geoposition; 14 struct Geoposition;
16 class LocationProvider;
17 15
18 // This is the main API to the geolocation subsystem. The application will hold 16 // This is the main API to the geolocation subsystem. The application will hold
19 // a single instance of this class and can register multiple clients to be 17 // a single instance of this class and can register multiple clients to be
20 // notified of location changes: 18 // notified of location changes:
21 // * Callbacks are registered by AddLocationUpdateCallback() and will keep 19 // * Callbacks are registered by AddLocationUpdateCallback() and will keep
22 // receiving updates until the returned subscription object is destructed. 20 // receiving updates until the returned subscription object is destructed.
23 // The application must instantiate the GeolocationProvider on the UI thread and 21 // The application must instantiate the GeolocationProvider on the UI thread and
24 // must communicate with it on the same thread. 22 // must communicate with it on the same thread.
25 // The underlying location arbitrator will only be enabled whilst there is at 23 // The underlying location arbitrator will only be enabled whilst there is at
26 // least one registered observer or pending callback (and only after 24 // least one registered observer or pending callback (and only after
27 // UserDidOptIntoLocationServices). The arbitrator and the location providers it 25 // UserDidOptIntoLocationServices). The arbitrator and the location providers it
28 // uses run on a separate Geolocation thread. 26 // uses run on a separate Geolocation thread.
29 class GeolocationProvider { 27 class GeolocationProvider {
30 public: 28 public:
31 // An embedder of Geolocation may override these class' methods to provide
32 // specific functionality.
33 // TODO(mcasas): Extract this class into a file of its own.
34 class CONTENT_EXPORT Delegate {
35 public:
36 // Returns true if the location API should use network-based location
37 // approximation in addition to the system provider, if any.
38 virtual bool UseNetworkLocationProviders();
39
40 // Creates a new AccessTokenStore for geolocation. May return nullptr.
41 // TODO(mcasas): consider changing it return type to std::unique_ptr<> to
42 // clarify ownership, https://crbug.com/623114.
43 virtual AccessTokenStore* CreateAccessTokenStore();
44
45 // Allows an embedder to return its own LocationProvider implementation.
46 // Return nullptr to use the default one for the platform to be created.
47 // Caller takes ownership of the returned LocationProvider. FYI: Used by an
48 // external project; please don't remove. Contact Viatcheslav Ostapenko at
49 // sl.ostapenko@samsung.com for more information.
50 // TODO(mcasas): return std::unique_ptr<> instead, https://crbug.com/623132.
51 virtual LocationProvider* OverrideSystemLocationProvider();
52 };
53
54 CONTENT_EXPORT static GeolocationProvider* GetInstance(); 29 CONTENT_EXPORT static GeolocationProvider* GetInstance();
55 30
56 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback; 31 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback;
57 typedef base::CallbackList<void(const Geoposition&)>::Subscription 32 typedef base::CallbackList<void(const Geoposition&)>::Subscription
58 Subscription; 33 Subscription;
59 34
60 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for 35 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for
61 // this particular observer, however the observer could receive updates for 36 // this particular observer, however the observer could receive updates for
62 // best available locations from any active provider whilst it is registered. 37 // best available locations from any active provider whilst it is registered.
63 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback( 38 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback(
(...skipping 18 matching lines...) Expand all
82 // (crbug.com/125931). 57 // (crbug.com/125931).
83 virtual void OverrideLocationForTesting(const Geoposition& position) = 0; 58 virtual void OverrideLocationForTesting(const Geoposition& position) = 0;
84 59
85 protected: 60 protected:
86 virtual~GeolocationProvider() {} 61 virtual~GeolocationProvider() {}
87 }; 62 };
88 63
89 } // namespace content 64 } // namespace content
90 65
91 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ 66 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/public/browser/geolocation_delegate.cc ('k') | content/public/browser/geolocation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698