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

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

Issue 2686463002: Add a source to the result of PermissionContextBase::GetPermissionStatus (Closed)
Patch Set: Created 3 years, 10 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
(...skipping 12 matching lines...) Expand all
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 WebContents; 28 class WebContents;
29 } 29 }
30 30
31 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; 31 using BrowserPermissionCallback = base::Callback<void(ContentSetting)>;
32 32
33 // Identifies the source or reason for a permission status being returned.
34 enum class PermissionStatusSource {
kcarattini 2017/02/07 22:53:33 Should we have a USER_DECISION value as well?
raymes 2017/02/08 04:08:40 Yes eventually. I didn't want to add it right now
35 // The status is the result of being blocked because the requesting origin is
36 // not https.
37 INSECURE_ORIGIN,
38
39 // The status is the result of being blocked by the permissions kill switch.
40 KILL_SWITCH,
41
42 // The status is the result of being blocked due to the user dismissing a
43 // permission prompt multiple times.
44 MULTIPLE_DISMISSALS,
45
46 // The status is the resultof being blocked because the permission is on the
47 // safe browsing blacklist.
48 SAFE_BROWSING_BLACKLIST,
49
50 // The reason for the status is not specified. Avoid returning this value. It
51 // only exists until code has been added to correctly return a source in all
52 // cases.
53 UNSPECIFIED
54 };
55
56 struct PermissionResult {
57 PermissionResult(ContentSetting content_setting,
58 PermissionStatusSource source);
59 ~PermissionResult();
60
61 ContentSetting content_setting;
62 PermissionStatusSource source;
63 };
64
33 // This base class contains common operations for granting permissions. 65 // This base class contains common operations for granting permissions.
34 // It offers the following functionality: 66 // It offers the following functionality:
35 // - Creates a permission request when needed. 67 // - Creates a permission request when needed.
36 // - If accepted/denied the permission is saved in content settings for 68 // - If accepted/denied the permission is saved in content settings for
37 // future uses (for the domain that requested it). 69 // future uses (for the domain that requested it).
38 // - If dismissed the permission is not saved but it's considered denied for 70 // - If dismissed the permission is not saved but it's considered denied for
39 // this one request 71 // this one request
40 // - In any case the BrowserPermissionCallback is executed once a decision 72 // - In any case the BrowserPermissionCallback is executed once a decision
41 // about the permission is made by the user. 73 // about the permission is made by the user.
42 // The bare minimum you need to create a new permission request is 74 // The bare minimum you need to create a new permission request is
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // should be called with the result. 108 // should be called with the result.
77 virtual void RequestPermission(content::WebContents* web_contents, 109 virtual void RequestPermission(content::WebContents* web_contents,
78 const PermissionRequestID& id, 110 const PermissionRequestID& id,
79 const GURL& requesting_frame, 111 const GURL& requesting_frame,
80 bool user_gesture, 112 bool user_gesture,
81 const BrowserPermissionCallback& callback); 113 const BrowserPermissionCallback& callback);
82 114
83 // Returns whether the permission has been granted, denied etc. 115 // Returns whether the permission has been granted, denied etc.
84 // TODO(meredithl): Ensure that the result accurately reflects whether the 116 // TODO(meredithl): Ensure that the result accurately reflects whether the
85 // origin is blacklisted for this permission. 117 // origin is blacklisted for this permission.
86 ContentSetting GetPermissionStatus(const GURL& requesting_origin, 118 PermissionResult GetPermissionStatus(const GURL& requesting_origin,
87 const GURL& embedding_origin) const; 119 const GURL& embedding_origin) const;
88 120
89 // Resets the permission to its default value. 121 // Resets the permission to its default value.
90 virtual void ResetPermission(const GURL& requesting_origin, 122 virtual void ResetPermission(const GURL& requesting_origin,
91 const GURL& embedding_origin); 123 const GURL& embedding_origin);
92 124
93 // Withdraw an existing permission request, no op if the permission request 125 // Withdraw an existing permission request, no op if the permission request
94 // was already cancelled by some other means. 126 // was already cancelled by some other means.
95 virtual void CancelPermissionRequest(content::WebContents* web_contents, 127 virtual void CancelPermissionRequest(content::WebContents* web_contents,
96 const PermissionRequestID& id); 128 const PermissionRequestID& id);
97 129
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 #endif 217 #endif
186 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>> 218 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>>
187 pending_requests_; 219 pending_requests_;
188 220
189 // Must be the last member, to ensure that it will be 221 // Must be the last member, to ensure that it will be
190 // destroyed first, which will invalidate weak pointers 222 // destroyed first, which will invalidate weak pointers
191 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 223 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
192 }; 224 };
193 225
194 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 226 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698