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.
5 #ifndef CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_
6 #define CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/content_settings/permission_queue_controller.h"
12 #include "content/public/browser/geolocation_permission_context.h"
18 class PermissionRequestID;
21 // Chrome specific implementation of GeolocationPermissionContext; manages
22 // Geolocation permissions flow, and delegates UI handling via
23 // PermissionQueueController.
24 class ChromeGeolocationPermissionContext
25 : public content::GeolocationPermissionContext {
27 explicit ChromeGeolocationPermissionContext(Profile* profile);
29 // GeolocationPermissionContext:
30 virtual void RequestGeolocationPermission(
31 int render_process_id,
34 const GURL& requesting_frame,
35 base::Callback<void(bool)> callback) OVERRIDE;
36 virtual void CancelGeolocationPermissionRequest(
37 int render_process_id,
40 const GURL& requesting_frame) OVERRIDE;
42 // Called on the UI thread when the profile is about to be destroyed.
43 void ShutdownOnUIThread();
45 // Notifies whether or not the corresponding bridge is allowed to use
47 // GeolocationPermissionContext::SetGeolocationPermissionResponse().
48 // Called on the UI thread.
49 void NotifyPermissionSet(const PermissionRequestID& id,
50 const GURL& requesting_frame,
51 base::Callback<void(bool)> callback,
55 virtual ~ChromeGeolocationPermissionContext();
57 Profile* profile() const { return profile_; }
59 // Return an instance of the infobar queue controller, creating it
61 PermissionQueueController* QueueController();
63 // ChromeGeolocationPermissionContext implementation:
64 // Decide whether the geolocation permission should be granted.
65 // Calls PermissionDecided if permission can be decided non-interactively,
66 // or NotifyPermissionSet if permission decided by presenting an
67 // infobar to the user. Called on the UI thread.
68 virtual void DecidePermission(content::WebContents* web_contents,
69 const PermissionRequestID& id,
70 const GURL& requesting_frame,
72 base::Callback<void(bool)> callback);
74 // Called when permission is granted without interactively asking
75 // the user. Can be overridden to introduce additional UI flow.
76 // Should ultimately ensure that NotifyPermissionSet is called.
77 // Called on the UI thread.
78 virtual void PermissionDecided(const PermissionRequestID& id,
79 const GURL& requesting_frame,
81 base::Callback<void(bool)> callback,
84 // Create an PermissionQueueController. overriden in derived classes to
85 // provide additional UI flow. Called on the UI thread.
86 virtual PermissionQueueController* CreateQueueController();
89 // Removes any pending InfoBar request.
90 void CancelPendingInfobarRequest(const PermissionRequestID& id);
92 // These must only be accessed from the UI thread.
93 Profile* const profile_;
95 scoped_ptr<PermissionQueueController> permission_queue_controller_;
97 DISALLOW_COPY_AND_ASSIGN(ChromeGeolocationPermissionContext);
100 #endif // CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_