Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / public / provider / chrome / browser / geolocation_updater_provider.h
blob6a03f793c8c622489e3602691918146f8eb500d1
1 // Copyright 2015 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 IOS_PUBLIC_PROVIDER_CHROME_BROWSER_GEOLOCATION_UPDATER_H
6 #define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_GEOLOCATION_UPDATER_H
8 #import <CoreLocation/CoreLocation.h>
9 #import <Foundation/Foundation.h>
11 #include "base/macros.h"
13 // GeolocationUpdater tracks the current location of the user and sends
14 // NSNotifications when it changes.
15 // The notification names and keys can be obtained using
16 // GeolocationUpdaterProvider.
17 @protocol GeolocationUpdater<NSObject>
19 // Returns the most recently fetched location. Returns nil if disabled.
20 - (CLLocation*)currentLocation;
22 // Prompts the user to authorize access to location information while the app is
23 // in use. Only affects iOS 8+.
24 - (void)requestWhenInUseAuthorization;
26 // Set the |timeout| the before the manager gives up fetching the location
27 // information. If a timer has already been set to stop fetching location,
28 // it will be reset to |timeout| seconds from now.
29 - (void)setStopUpdateDelay:(NSTimeInterval)timeout;
31 // Sets how often should the location manager check for a fresh location.
32 - (void)setUpdateInterval:(NSTimeInterval)interval;
34 // Sets the desired accuracy, distance and update interval.
35 // Desired Accuracy defaults to: kCLLocationAccuracyBest.
36 // Distance Filter defaults to: 20m.
37 - (void)setDesiredAccuracy:(CLLocationAccuracy)desiredAccuracy
38 distanceFilter:(CLLocationDistance)distanceFilter;
40 // Does not take into consideration whether location is disabled by the OS.
41 - (BOOL)isEnabled;
43 // Turns the geolocation updater on or off, depending on the value of flag.
44 // if flag is false, then no more location updates will be requested, and
45 // currentLocation will return nil.
46 - (void)setEnabled:(BOOL)flag;
48 @end
50 namespace ios {
52 class GeolocationUpdaterProvider {
53 public:
54 GeolocationUpdaterProvider();
55 virtual ~GeolocationUpdaterProvider();
57 // Creates a new GeolocationUpdater.
58 // The returned object is retained and it is the responsability of the caller
59 // to release it.
60 virtual id<GeolocationUpdater> CreateGeolocationUpdater(bool enabled);
62 // Notification names:
64 // Name of NSNotificationCenter notification posted on user location update.
65 // Passes a |CLLocation| for the new location in the userInfo dictionary with
66 // the key returned by GetUpdateNewLocationKey().
67 virtual NSString* GetUpdateNotificationName();
68 // Name of NSNotificationCenter notification posted on when the location
69 // manager's stops.
70 virtual NSString* GetStopNotificationName();
71 // Name of NSNotificationCenter notification posted when the location
72 // manager's authorization status changes. For example when the user turns
73 // off Locations Services in Settings. The new status is passed as a
74 // |NSNumber| representing the |CLAuthorizationStatus| enum value.
75 virtual NSString* GetAuthorizationChangeNotificationName();
77 // Notification keys:
79 // Key used in the userInfo dictionaries of this class' notifications.
80 // Contains a |CLLocation *| and is used in the update notification.
81 virtual NSString* GetUpdateNewLocationKey();
83 private:
84 DISALLOW_COPY_AND_ASSIGN(GeolocationUpdaterProvider);
87 } // namespace ios
89 #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_GEOLOCATION_UPDATER_H