blob: 23918318936489709a85cc3ef1e62fd7862aecdd [file] [log] [blame]
[email protected]c31d8042014-08-06 16:35:391// Copyright 2012 The Chromium Authors. All rights reserved.
[email protected]b2cf4522012-10-23 00:11:572// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]487974a2014-06-13 16:49:015#ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
6#define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
[email protected]b2cf4522012-10-23 00:11:577
[email protected]c31d8042014-08-06 16:35:398// The flow for geolocation permissions on Android needs to take into account
9// the global geolocation settings so it differs from the desktop one. It
10// works as follows.
miguelge10a8252015-01-16 14:24:0911// GeolocationPermissionContextAndroid::RequestPermission intercepts the flow
12// and proceeds to check the system location.
13// This will in fact check several possible settings
[email protected]c31d8042014-08-06 16:35:3914// - The global system geolocation setting
15// - The Google location settings on pre KK devices
finnurdd716132014-12-11 15:07:5316// - An old internal Chrome setting on pre-JB MR1 devices
[email protected]c31d8042014-08-06 16:35:3917// With all that information it will decide if system location is enabled.
18// If enabled, it proceeds with the per site flow via
19// GeolocationPermissionContext (which will check per site permissions, create
20// infobars, etc.).
21//
22// Otherwise the permission is already decided.
miguelgfa052072014-09-29 15:31:3823#include "base/memory/scoped_ptr.h"
tedchoc76bf8122015-07-22 19:52:0624#include "base/memory/weak_ptr.h"
[email protected]487974a2014-06-13 16:49:0125#include "chrome/browser/geolocation/geolocation_permission_context.h"
[email protected]b2cf4522012-10-23 00:11:5726
[email protected]f068ad0e2014-02-11 13:48:2327namespace content {
28class WebContents;
29}
30
newte587c6d2015-01-21 20:45:1231class LocationSettings;
miguelge10a8252015-01-16 14:24:0932class GURL;
33class PermissionRequestID;
[email protected]b2cf4522012-10-23 00:11:5734
[email protected]487974a2014-06-13 16:49:0135class GeolocationPermissionContextAndroid
36 : public GeolocationPermissionContext {
[email protected]b2cf4522012-10-23 00:11:5737 public:
[email protected]487974a2014-06-13 16:49:0138 explicit GeolocationPermissionContextAndroid(Profile* profile);
newtad75c732015-01-13 20:21:3739 ~GeolocationPermissionContextAndroid() override;
[email protected]b2cf4522012-10-23 00:11:5740
41 private:
newtad75c732015-01-13 20:21:3742 friend class GeolocationPermissionContextTests;
43
miguelge10a8252015-01-16 14:24:0944 // GeolocationPermissionContext:
newtad75c732015-01-13 20:21:3745 void RequestPermission(
miguelgfa052072014-09-29 15:31:3846 content::WebContents* web_contents,
tedchoc76bf8122015-07-22 19:52:0647 const PermissionRequestID& id,
48 const GURL& requesting_frame_origin,
49 bool user_gesture,
50 const BrowserPermissionCallback& callback) override;
51
52 void HandleUpdateAndroidPermissions(const PermissionRequestID& id,
53 const GURL& requesting_frame_origin,
54 const GURL& embedding_origin,
55 const BrowserPermissionCallback& callback,
56 bool permissions_updated);
[email protected]b2cf4522012-10-23 00:11:5757
newte587c6d2015-01-21 20:45:1258 // Overrides the LocationSettings object used to determine whether
newtad75c732015-01-13 20:21:3759 // system and Chrome-wide location permissions are enabled.
newte587c6d2015-01-21 20:45:1260 void SetLocationSettingsForTesting(scoped_ptr<LocationSettings> settings);
newtad75c732015-01-13 20:21:3761
newte587c6d2015-01-21 20:45:1262 scoped_ptr<LocationSettings> location_settings_;
[email protected]cc19a3262014-02-27 13:02:5963
tedchoc76bf8122015-07-22 19:52:0664 // Must be the last member, to ensure that it will be destroyed first, which
65 // will invalidate weak pointers.
66 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_;
67
[email protected]487974a2014-06-13 16:49:0168 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid);
[email protected]b2cf4522012-10-23 00:11:5769};
70
[email protected]487974a2014-06-13 16:49:0171#endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_