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

Side by Side Diff: chrome/browser/permissions/permission_context_base.h

Issue 2723983004: Add PermissionManager::GetPermissionStatusForFrame function (Closed)
Patch Set: Add PermissionManager::GetPermissionStatusForFrame function Created 3 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/permissions/permission_request.h" 14 #include "chrome/browser/permissions/permission_request.h"
15 #include "chrome/browser/permissions/permission_result.h" 15 #include "chrome/browser/permissions/permission_result.h"
16 #include "components/content_settings/core/common/content_settings.h" 16 #include "components/content_settings/core/common/content_settings.h"
17 #include "components/content_settings/core/common/content_settings_types.h" 17 #include "components/content_settings/core/common/content_settings_types.h"
18 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
19 19
20 #if defined(OS_ANDROID) 20 #if defined(OS_ANDROID)
21 class PermissionQueueController; 21 class PermissionQueueController;
22 #endif 22 #endif
23 class GURL; 23 class GURL;
24 class PermissionRequestID; 24 class PermissionRequestID;
25 class Profile; 25 class Profile;
26 26
27 namespace content { 27 namespace content {
28 class RenderFrameHost;
28 class WebContents; 29 class WebContents;
29 } 30 }
30 31
31 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; 32 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>;
32 33
33 // This base class contains common operations for granting permissions. 34 // This base class contains common operations for granting permissions.
34 // It offers the following functionality: 35 // It offers the following functionality:
35 // - Creates a permission request when needed. 36 // - Creates a permission request when needed.
36 // - If accepted/denied the permission is saved in content settings for 37 // - If accepted/denied the permission is saved in content settings for
37 // future uses (for the domain that requested it). 38 // future uses (for the domain that requested it).
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // The renderer is requesting permission to push messages. 74 // The renderer is requesting permission to push messages.
74 // When the answer to a permission request has been determined, |callback| 75 // When the answer to a permission request has been determined, |callback|
75 // should be called with the result. 76 // should be called with the result.
76 virtual void RequestPermission(content::WebContents* web_contents, 77 virtual void RequestPermission(content::WebContents* web_contents,
77 const PermissionRequestID& id, 78 const PermissionRequestID& id,
78 const GURL& requesting_frame, 79 const GURL& requesting_frame,
79 bool user_gesture, 80 bool user_gesture,
80 const BrowserPermissionCallback& callback); 81 const BrowserPermissionCallback& callback);
81 82
82 // Returns whether the permission has been granted, denied etc. 83 // Returns whether the permission has been granted, denied etc.
84 // |render_frame_host| may be nullptr if the call is coming from a context
85 // other than a specific frame.
83 // TODO(meredithl): Ensure that the result accurately reflects whether the 86 // TODO(meredithl): Ensure that the result accurately reflects whether the
84 // origin is blacklisted for this permission. 87 // origin is blacklisted for this permission.
85 PermissionResult GetPermissionStatus(const GURL& requesting_origin, 88 PermissionResult GetPermissionStatus(
86 const GURL& embedding_origin) const; 89 content::RenderFrameHost* render_frame_host,
90 const GURL& requesting_origin,
91 const GURL& embedding_origin) const;
87 92
88 // Resets the permission to its default value. 93 // Resets the permission to its default value.
89 virtual void ResetPermission(const GURL& requesting_origin, 94 virtual void ResetPermission(const GURL& requesting_origin,
90 const GURL& embedding_origin); 95 const GURL& embedding_origin);
91 96
92 // Withdraw an existing permission request, no op if the permission request 97 // Withdraw an existing permission request, no op if the permission request
93 // was already cancelled by some other means. 98 // was already cancelled by some other means.
94 virtual void CancelPermissionRequest(content::WebContents* web_contents, 99 virtual void CancelPermissionRequest(content::WebContents* web_contents,
95 const PermissionRequestID& id); 100 const PermissionRequestID& id);
96 101
97 // Whether the kill switch has been enabled for this permission. 102 // Whether the kill switch has been enabled for this permission.
98 // public for permissions that do not use RequestPermission, like 103 // public for permissions that do not use RequestPermission, like
99 // camera and microphone, and for testing. 104 // camera and microphone, and for testing.
100 bool IsPermissionKillSwitchOn() const; 105 bool IsPermissionKillSwitchOn() const;
101 106
102 protected: 107 protected:
103 virtual ContentSetting GetPermissionStatusInternal( 108 virtual ContentSetting GetPermissionStatusInternal(
109 content::RenderFrameHost* render_frame_host,
104 const GURL& requesting_origin, 110 const GURL& requesting_origin,
105 const GURL& embedding_origin) const; 111 const GURL& embedding_origin) const;
106 112
107 // Decide whether the permission should be granted. 113 // Decide whether the permission should be granted.
108 // Calls PermissionDecided if permission can be decided non-interactively, 114 // Calls PermissionDecided if permission can be decided non-interactively,
109 // or NotifyPermissionSet if permission decided by presenting an infobar. 115 // or NotifyPermissionSet if permission decided by presenting an infobar.
110 virtual void DecidePermission(content::WebContents* web_contents, 116 virtual void DecidePermission(content::WebContents* web_contents,
111 const PermissionRequestID& id, 117 const PermissionRequestID& id,
112 const GURL& requesting_origin, 118 const GURL& requesting_origin,
113 const GURL& embedding_origin, 119 const GURL& embedding_origin,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 #endif 193 #endif
188 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>> 194 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>>
189 pending_requests_; 195 pending_requests_;
190 196
191 // Must be the last member, to ensure that it will be 197 // Must be the last member, to ensure that it will be
192 // destroyed first, which will invalidate weak pointers 198 // destroyed first, which will invalidate weak pointers
193 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 199 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
194 }; 200 };
195 201
196 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 202 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698