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

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

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

Powered by Google App Engine
This is Rietveld 408576698