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

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: Changing to ContentBrowserClient::GetGeolocationServiceOverrides and impl'd in the 6 impl's. Unitte… Created 4 years, 6 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 ServiceOverrides {
Michael van Ouwerkerk 2016/06/24 13:57:19 I'd suggest calling it GeolocationProvider::Delega
mcasas 2016/06/24 19:25:52 Done.
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();
Michael van Ouwerkerk 2016/06/24 13:57:19 The first rule of the content API [1] is "content/
mcasas 2016/06/24 19:25:53 I didn't know that rule, but currently there are 5
38
39 // Creates a new AccessTokenStore for geolocation. May return nullptr.
40 virtual AccessTokenStore* CreateAccessTokenStore();
Michael van Ouwerkerk 2016/06/24 13:57:19 If you're here anyway, consider whether this shoul
mcasas 2016/06/24 19:25:52 Added a TODO and a bug. Smaller CLs are easier to
41
42 // Allows an embedder to return its own LocationProvider implementation.
43 // Return nullptr to use the default one for the platform to be created.
44 // Caller takes ownership of the returned LocationProvider. FYI: Used by an
45 // external project; please don't remove. Contact Viatcheslav Ostapenko at
46 // sl.ostapenko@samsung.com for more information.
47 virtual LocationProvider* OverrideSystemLocationProvider();
48 };
49
29 CONTENT_EXPORT static GeolocationProvider* GetInstance(); 50 CONTENT_EXPORT static GeolocationProvider* GetInstance();
30 51
31 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback; 52 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback;
32 typedef base::CallbackList<void(const Geoposition&)>::Subscription 53 typedef base::CallbackList<void(const Geoposition&)>::Subscription
33 Subscription; 54 Subscription;
34 55
35 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for 56 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for
36 // this particular observer, however the observer could receive updates for 57 // this particular observer, however the observer could receive updates for
37 // best available locations from any active provider whilst it is registered. 58 // best available locations from any active provider whilst it is registered.
38 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback( 59 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback(
(...skipping 18 matching lines...) Expand all
57 // (crbug.com/125931). 78 // (crbug.com/125931).
58 virtual void OverrideLocationForTesting(const Geoposition& position) = 0; 79 virtual void OverrideLocationForTesting(const Geoposition& position) = 0;
59 80
60 protected: 81 protected:
61 virtual~GeolocationProvider() {} 82 virtual~GeolocationProvider() {}
62 }; 83 };
63 84
64 } // namespace content 85 } // namespace content
65 86
66 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ 87 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698