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

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: Added a TODO 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 // 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
29 CONTENT_EXPORT static GeolocationProvider* GetInstance(); 54 CONTENT_EXPORT static GeolocationProvider* GetInstance();
30 55
31 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback; 56 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback;
32 typedef base::CallbackList<void(const Geoposition&)>::Subscription 57 typedef base::CallbackList<void(const Geoposition&)>::Subscription
33 Subscription; 58 Subscription;
34 59
35 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for 60 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for
36 // this particular observer, however the observer could receive updates for 61 // this particular observer, however the observer could receive updates for
37 // best available locations from any active provider whilst it is registered. 62 // best available locations from any active provider whilst it is registered.
38 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback( 63 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback(
(...skipping 18 matching lines...) Expand all
57 // (crbug.com/125931). 82 // (crbug.com/125931).
58 virtual void OverrideLocationForTesting(const Geoposition& position) = 0; 83 virtual void OverrideLocationForTesting(const Geoposition& position) = 0;
59 84
60 protected: 85 protected:
61 virtual~GeolocationProvider() {} 86 virtual~GeolocationProvider() {}
62 }; 87 };
63 88
64 } // namespace content 89 } // namespace content
65 90
66 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ 91 #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