Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Side by Side Diff: chrome/browser/geolocation/chrome_geolocation_permission_context.h

Issue 330143002: Simplify geolocation permission request in the Content API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_
6 #define CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/content_settings/permission_queue_controller.h"
14 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_exten sions.h"
15 #include "content/public/browser/geolocation_permission_context.h"
16
17 namespace content {
18 class WebContents;
19 }
20
21 class GeolocationPermissionRequest;
22 class PermissionRequestID;
23 class Profile;
24
25 // Chrome specific implementation of GeolocationPermissionContext; manages
26 // Geolocation permissions flow, and delegates UI handling via
27 // PermissionQueueController.
28 class ChromeGeolocationPermissionContext
29 : public content::GeolocationPermissionContext {
30 public:
31 explicit ChromeGeolocationPermissionContext(Profile* profile);
32
33 // GeolocationPermissionContext:
34 virtual void RequestGeolocationPermission(
35 content::WebContents* web_contents,
36 int bridge_id,
37 const GURL& requesting_frame,
38 bool user_gesture,
39 base::Callback<void(bool)> callback) OVERRIDE;
40 virtual void CancelGeolocationPermissionRequest(
41 content::WebContents* web_contents,
42 int bridge_id,
43 const GURL& requesting_frame) OVERRIDE;
44
45 // Called on the UI thread when the profile is about to be destroyed.
46 void ShutdownOnUIThread();
47
48 // Notifies whether or not the corresponding bridge is allowed to use
49 // geolocation via
50 // GeolocationPermissionContext::SetGeolocationPermissionResponse().
51 // Called on the UI thread.
52 void NotifyPermissionSet(const PermissionRequestID& id,
53 const GURL& requesting_frame,
54 base::Callback<void(bool)> callback,
55 bool allowed);
56
57 protected:
58 virtual ~ChromeGeolocationPermissionContext();
59
60 Profile* profile() const { return profile_; }
61
62 // Return an instance of the infobar queue controller, creating it
63 // if necessary.
64 PermissionQueueController* QueueController();
65
66 // ChromeGeolocationPermissionContext implementation:
67 // Decide whether the geolocation permission should be granted.
68 // Calls PermissionDecided if permission can be decided non-interactively,
69 // or NotifyPermissionSet if permission decided by presenting an
70 // infobar to the user. Called on the UI thread.
71 virtual void DecidePermission(content::WebContents* web_contents,
72 const PermissionRequestID& id,
73 const GURL& requesting_frame,
74 bool user_gesture,
75 const GURL& embedder,
76 const std::string& accept_button_label,
77 base::Callback<void(bool)> callback);
78
79 // Called when permission is granted without interactively asking
80 // the user. Can be overridden to introduce additional UI flow.
81 // Should ultimately ensure that NotifyPermissionSet is called.
82 // Called on the UI thread.
83 virtual void PermissionDecided(const PermissionRequestID& id,
84 const GURL& requesting_frame,
85 const GURL& embedder,
86 base::Callback<void(bool)> callback,
87 bool allowed);
88
89 // Create an PermissionQueueController. overriden in derived classes to
90 // provide additional UI flow. Called on the UI thread.
91 virtual PermissionQueueController* CreateQueueController();
92
93 private:
94 friend class GeolocationPermissionRequest;
95
96 // Removes any pending InfoBar request.
97 void CancelPendingInfobarRequest(const PermissionRequestID& id);
98
99 // Creates and show an info bar.
100 void CreateInfoBarRequest(const PermissionRequestID& id,
101 const GURL& requesting_frame,
102 const GURL& embedder,
103 const std::string accept_button_label,
104 base::Callback<void(bool)> callback);
105
106 // Notify the context that a particular request object is no longer needed.
107 void RequestFinished(GeolocationPermissionRequest* request);
108
109 // These must only be accessed from the UI thread.
110 Profile* const profile_;
111 bool shutting_down_;
112 scoped_ptr<PermissionQueueController> permission_queue_controller_;
113 ChromeGeolocationPermissionContextExtensions extensions_context_;
114
115 base::ScopedPtrHashMap<std::string, GeolocationPermissionRequest>
116 pending_requests_;
117
118 DISALLOW_COPY_AND_ASSIGN(ChromeGeolocationPermissionContext);
119 };
120
121 #endif // CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/geolocation/chrome_geolocation_permission_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698