ApplicationImpl cleanup, part 1:
[chromium-blink-merge.git] / content / public / browser / location_provider.h
blob8752a902e1e91462a0398b835388cba5618d69a9
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_LOCATION_PROVIDER_H_
6 #define CONTENT_PUBLIC_BROWSER_LOCATION_PROVIDER_H_
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "content/public/common/geoposition.h"
12 namespace content {
14 class LocationProvider;
16 // The interface for providing location information.
17 class LocationProvider {
18 public:
19 virtual ~LocationProvider() {}
21 typedef base::Callback<void(const LocationProvider*, const Geoposition&)>
22 LocationProviderUpdateCallback;
24 // This callback will be used to notify when a new Geoposition becomes
25 // available.
26 virtual void SetUpdateCallback(
27 const LocationProviderUpdateCallback& callback) = 0;
29 // StartProvider maybe called multiple times, e.g. to alter the
30 // |high_accuracy| setting. Returns false if a fatal error was encountered
31 // which prevented the provider from starting.
32 virtual bool StartProvider(bool high_accuracy) = 0;
34 // Stops the provider from sending more requests.
35 // Important: a LocationProvider may be instantiated and StartProvider() may
36 // be called before the user has granted permission via OnPermissionGranted().
37 // This is to allow underlying providers to warm up, load their internal
38 // libraries, etc. No |LocationProviderUpdateCallback| can be run and no
39 // network requests can be done until OnPermissionGranted() has been called.
40 virtual void StopProvider() = 0;
42 // Gets the current best position estimate.
43 virtual void GetPosition(Geoposition* position) = 0;
45 // Provides a hint to the provider that new location data is needed as soon
46 // as possible.
47 virtual void RequestRefresh() = 0;
49 // Called everytime permission is granted to a page for using geolocation.
50 // This may either be through explicit user action (e.g. responding to the
51 // infobar prompt) or inferred from a persisted site permission.
52 // Note: See |StartProvider()| for more information.
53 virtual void OnPermissionGranted() = 0;
56 } // namespace content
58 #endif // CONTENT_PUBLIC_BROWSER_LOCATION_PROVIDER_H_