Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / geolocation / chrome_geolocation_permission_context.h
blobacc9448a21aa567c3574853fb7fd677d00d0093a
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_
8 #include <string>
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"
14 class PermissionRequestID;
15 class Profile;
17 // Chrome specific implementation of GeolocationPermissionContext; manages
18 // Geolocation permissions flow, and delegates UI handling via
19 // PermissionQueueController.
20 class ChromeGeolocationPermissionContext
21 : public content::GeolocationPermissionContext {
22 public:
23 explicit ChromeGeolocationPermissionContext(Profile* profile);
25 // GeolocationPermissionContext:
26 virtual void RequestGeolocationPermission(
27 int render_process_id,
28 int render_view_id,
29 int bridge_id,
30 const GURL& requesting_frame,
31 base::Callback<void(bool)> callback) OVERRIDE;
32 virtual void CancelGeolocationPermissionRequest(
33 int render_process_id,
34 int render_view_id,
35 int bridge_id,
36 const GURL& requesting_frame) OVERRIDE;
38 // Called on the UI thread when the profile is about to be destroyed.
39 void ShutdownOnUIThread();
41 protected:
42 virtual ~ChromeGeolocationPermissionContext();
44 Profile* profile() const { return profile_; }
46 // Return an instance of the infobar queue controller, creating it
47 // if necessary.
48 PermissionQueueController* QueueController();
50 // Notifies whether or not the corresponding bridge is allowed to use
51 // geolocation via
52 // GeolocationPermissionContext::SetGeolocationPermissionResponse().
53 // Called on the UI thread.
54 void NotifyPermissionSet(const PermissionRequestID& id,
55 const GURL& requesting_frame,
56 base::Callback<void(bool)> callback,
57 bool allowed);
59 // ChromeGeolocationPermissionContext implementation:
60 // Decide whether the geolocation permission should be granted.
61 // Calls PermissionDecided if permission can be decided non-interactively,
62 // or NotifyPermissionSet if permission decided by presenting an
63 // infobar to the user. Called on the UI thread.
64 virtual void DecidePermission(const PermissionRequestID& id,
65 const GURL& requesting_frame,
66 const GURL& embedder,
67 base::Callback<void(bool)> callback);
69 // Called when permission is granted without interactively asking
70 // the user. Can be overridden to introduce additional UI flow.
71 // Should ultimately ensure that NotifyPermissionSet is called.
72 // Called on the UI thread.
73 virtual void PermissionDecided(const PermissionRequestID& id,
74 const GURL& requesting_frame,
75 const GURL& embedder,
76 base::Callback<void(bool)> callback,
77 bool allowed);
79 // Create an PermissionQueueController. overriden in derived classes to
80 // provide additional UI flow. Called on the UI thread.
81 virtual PermissionQueueController* CreateQueueController();
83 private:
84 // Removes any pending InfoBar request.
85 void CancelPendingInfobarRequest(const PermissionRequestID& id);
87 // These must only be accessed from the UI thread.
88 Profile* const profile_;
89 bool shutting_down_;
90 scoped_ptr<PermissionQueueController> permission_queue_controller_;
92 DISALLOW_COPY_AND_ASSIGN(ChromeGeolocationPermissionContext);
95 #endif // CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_