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

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

Issue 2127973002: Geolocation: change GeolocationDelegate to injected by content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplified shell_content_browser_client.cc 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 GeolocationDelegate;
14 struct Geoposition; 15 struct Geoposition;
15 16
16 // This is the main API to the geolocation subsystem. The application will hold 17 // 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 18 // a single instance of this class and can register multiple clients to be
18 // notified of location changes: 19 // notified of location changes:
19 // * Callbacks are registered by AddLocationUpdateCallback() and will keep 20 // * Callbacks are registered by AddLocationUpdateCallback() and will keep
20 // receiving updates until the returned subscription object is destructed. 21 // receiving updates until the returned subscription object is destructed.
21 // The application must instantiate the GeolocationProvider on the UI thread and 22 // The application must instantiate the GeolocationProvider on the UI thread and
22 // must communicate with it on the same thread. 23 // must communicate with it on the same thread.
23 // The underlying location arbitrator will only be enabled whilst there is at 24 // The underlying location arbitrator will only be enabled whilst there is at
24 // least one registered observer or pending callback (and only after 25 // least one registered observer or pending callback (and only after
25 // UserDidOptIntoLocationServices). The arbitrator and the location providers it 26 // UserDidOptIntoLocationServices). The arbitrator and the location providers it
26 // uses run on a separate Geolocation thread. 27 // uses run on a separate Geolocation thread.
27 class GeolocationProvider { 28 class GeolocationProvider {
28 public: 29 public:
29 CONTENT_EXPORT static GeolocationProvider* GetInstance(); 30 CONTENT_EXPORT static GeolocationProvider* GetInstance();
30 31
32 // Optional: provide a Delegate to override typical services.
33 CONTENT_EXPORT static void SetGeolocationDelegate(
34 GeolocationDelegate* delegate);
35
31 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback; 36 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback;
32 typedef base::CallbackList<void(const Geoposition&)>::Subscription 37 typedef base::CallbackList<void(const Geoposition&)>::Subscription
33 Subscription; 38 Subscription;
34 39
35 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for 40 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for
36 // this particular observer, however the observer could receive updates for 41 // this particular observer, however the observer could receive updates for
37 // best available locations from any active provider whilst it is registered. 42 // best available locations from any active provider whilst it is registered.
38 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback( 43 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback(
39 const LocationUpdateCallback& callback, 44 const LocationUpdateCallback& callback,
40 bool enable_high_accuracy) = 0; 45 bool enable_high_accuracy) = 0;
(...skipping 16 matching lines...) Expand all
57 // (crbug.com/125931). 62 // (crbug.com/125931).
58 virtual void OverrideLocationForTesting(const Geoposition& position) = 0; 63 virtual void OverrideLocationForTesting(const Geoposition& position) = 0;
59 64
60 protected: 65 protected:
61 virtual~GeolocationProvider() {} 66 virtual~GeolocationProvider() {}
62 }; 67 };
63 68
64 } // namespace content 69 } // namespace content
65 70
66 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ 71 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/browser/geolocation/geolocation_provider_impl.cc ('k') | content/shell/browser/shell_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698