geolocation_permission_context_android.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
6#define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
7
8#include "chrome/browser/content_settings/permission_request_id.h"
9#include "chrome/browser/geolocation/geolocation_permission_context.h"
10#include "url/gurl.h"
11
12namespace content {
13class WebContents;
14}
15
16class GoogleLocationSettingsHelper;
17
18// Android-specific geolocation permission flow, taking into account the
19// Google Location Settings, if available.
20class GeolocationPermissionContextAndroid
21    : public GeolocationPermissionContext {
22 public:
23  explicit GeolocationPermissionContextAndroid(Profile* profile);
24
25 private:
26  struct PermissionRequestInfo {
27    PermissionRequestInfo();
28
29    PermissionRequestID id;
30    GURL requesting_frame;
31    bool user_gesture;
32    GURL embedder;
33  };
34
35  friend class GeolocationPermissionContext;
36
37  virtual ~GeolocationPermissionContextAndroid();
38
39  // GeolocationPermissionContext implementation:
40  virtual void DecidePermission(content::WebContents* web_contents,
41                                const PermissionRequestID& id,
42                                const GURL& requesting_frame,
43                                bool user_gesture,
44                                const GURL& embedder,
45                                const std::string& accept_button_label,
46                                base::Callback<void(bool)> callback) OVERRIDE;
47
48  virtual void PermissionDecided(const PermissionRequestID& id,
49                                 const GURL& requesting_frame,
50                                 const GURL& embedder,
51                                 base::Callback<void(bool)> callback,
52                                 bool allowed) OVERRIDE;
53
54  void ProceedDecidePermission(content::WebContents* web_contents,
55                               const PermissionRequestInfo& info,
56                               const std::string& accept_button_label,
57                               base::Callback<void(bool)> callback);
58
59  scoped_ptr<GoogleLocationSettingsHelper> google_location_settings_helper_;
60
61 private:
62  void CheckMasterLocation(content::WebContents* web_contents,
63                           const PermissionRequestInfo& info,
64                           base::Callback<void(bool)> callback);
65
66  DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid);
67};
68
69#endif  // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
70