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

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: Add a source to the result of PermissionContextBase::GetPermissionStatus 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 // TODO(raymes): Add more reasons here and return them correctly.
35 enum class PermissionStatusSource {
36 // The status is the result of being blocked due to the user dismissing a
37 // permission prompt multiple times.
38 MULTIPLE_DISMISSALS,
39
40 // The status is the resultof being blocked because the permission is on the
41 // safe browsing blacklist.
42 SAFE_BROWSING_BLACKLIST,
43
44 // The reason for the status is not specified. Avoid returning this value. It
45 // only exists until code has been added to correctly return a source in all
46 // cases.
47 UNSPECIFIED
48 };
49
50 struct PermissionResult {
51 PermissionResult(ContentSetting content_setting,
52 PermissionStatusSource source);
53 ~PermissionResult();
54
55 ContentSetting content_setting;
56 PermissionStatusSource source;
57 };
58
33 // This base class contains common operations for granting permissions. 59 // This base class contains common operations for granting permissions.
34 // It offers the following functionality: 60 // It offers the following functionality:
35 // - Creates a permission request when needed. 61 // - Creates a permission request when needed.
36 // - If accepted/denied the permission is saved in content settings for 62 // - If accepted/denied the permission is saved in content settings for
37 // future uses (for the domain that requested it). 63 // future uses (for the domain that requested it).
38 // - If dismissed the permission is not saved but it's considered denied for 64 // - If dismissed the permission is not saved but it's considered denied for
39 // this one request 65 // this one request
40 // - In any case the BrowserPermissionCallback is executed once a decision 66 // - In any case the BrowserPermissionCallback is executed once a decision
41 // about the permission is made by the user. 67 // about the permission is made by the user.
42 // The bare minimum you need to create a new permission request is 68 // 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. 102 // should be called with the result.
77 virtual void RequestPermission(content::WebContents* web_contents, 103 virtual void RequestPermission(content::WebContents* web_contents,
78 const PermissionRequestID& id, 104 const PermissionRequestID& id,
79 const GURL& requesting_frame, 105 const GURL& requesting_frame,
80 bool user_gesture, 106 bool user_gesture,
81 const BrowserPermissionCallback& callback); 107 const BrowserPermissionCallback& callback);
82 108
83 // Returns whether the permission has been granted, denied etc. 109 // Returns whether the permission has been granted, denied etc.
84 // TODO(meredithl): Ensure that the result accurately reflects whether the 110 // TODO(meredithl): Ensure that the result accurately reflects whether the
85 // origin is blacklisted for this permission. 111 // origin is blacklisted for this permission.
86 ContentSetting GetPermissionStatus(const GURL& requesting_origin, 112 PermissionResult GetPermissionStatus(const GURL& requesting_origin,
87 const GURL& embedding_origin) const; 113 const GURL& embedding_origin) const;
88 114
89 // Resets the permission to its default value. 115 // Resets the permission to its default value.
90 virtual void ResetPermission(const GURL& requesting_origin, 116 virtual void ResetPermission(const GURL& requesting_origin,
91 const GURL& embedding_origin); 117 const GURL& embedding_origin);
92 118
93 // Withdraw an existing permission request, no op if the permission request 119 // Withdraw an existing permission request, no op if the permission request
94 // was already cancelled by some other means. 120 // was already cancelled by some other means.
95 virtual void CancelPermissionRequest(content::WebContents* web_contents, 121 virtual void CancelPermissionRequest(content::WebContents* web_contents,
96 const PermissionRequestID& id); 122 const PermissionRequestID& id);
97 123
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 #endif 211 #endif
186 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>> 212 std::unordered_map<std::string, std::unique_ptr<PermissionRequest>>
187 pending_requests_; 213 pending_requests_;
188 214
189 // Must be the last member, to ensure that it will be 215 // Must be the last member, to ensure that it will be
190 // destroyed first, which will invalidate weak pointers 216 // destroyed first, which will invalidate weak pointers
191 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 217 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
192 }; 218 };
193 219
194 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 220 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698