| OLD | NEW |
| 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 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // This is public so permissions that don't yet inherit from | 72 // This is public so permissions that don't yet inherit from |
| 73 // PermissionContextBase can use it. | 73 // PermissionContextBase can use it. |
| 74 static const char kPermissionsKillSwitchBlockedValue[]; | 74 static const char kPermissionsKillSwitchBlockedValue[]; |
| 75 | 75 |
| 76 // The renderer is requesting permission to push messages. | 76 // The renderer is requesting permission to push messages. |
| 77 // When the answer to a permission request has been determined, |callback| | 77 // When the answer to a permission request has been determined, |callback| |
| 78 // should be called with the result. | 78 // should be called with the result. |
| 79 virtual void RequestPermission(content::WebContents* web_contents, | 79 virtual void RequestPermission(content::WebContents* web_contents, |
| 80 const PermissionRequestID& id, | 80 const PermissionRequestID& id, |
| 81 const GURL& requesting_frame, | 81 const GURL& requesting_frame, |
| 82 bool user_gesture, |
| 82 const BrowserPermissionCallback& callback); | 83 const BrowserPermissionCallback& callback); |
| 83 | 84 |
| 84 // Returns whether the permission has been granted, denied... | 85 // Returns whether the permission has been granted, denied... |
| 85 virtual ContentSetting GetPermissionStatus( | 86 virtual ContentSetting GetPermissionStatus( |
| 86 const GURL& requesting_origin, | 87 const GURL& requesting_origin, |
| 87 const GURL& embedding_origin) const; | 88 const GURL& embedding_origin) const; |
| 88 | 89 |
| 89 // Resets the permission to its default value. | 90 // Resets the permission to its default value. |
| 90 virtual void ResetPermission(const GURL& requesting_origin, | 91 virtual void ResetPermission(const GURL& requesting_origin, |
| 91 const GURL& embedding_origin); | 92 const GURL& embedding_origin); |
| 92 | 93 |
| 93 // Withdraw an existing permission request, no op if the permission request | 94 // Withdraw an existing permission request, no op if the permission request |
| 94 // was already cancelled by some other means. | 95 // was already cancelled by some other means. |
| 95 virtual void CancelPermissionRequest(content::WebContents* web_contents, | 96 virtual void CancelPermissionRequest(content::WebContents* web_contents, |
| 96 const PermissionRequestID& id); | 97 const PermissionRequestID& id); |
| 97 | 98 |
| 98 // Whether the kill switch has been enabled for this permission. | 99 // Whether the kill switch has been enabled for this permission. |
| 99 // public for permissions that do not use RequestPermission, like | 100 // public for permissions that do not use RequestPermission, like |
| 100 // camera and microphone, and for testing. | 101 // camera and microphone, and for testing. |
| 101 bool IsPermissionKillSwitchOn() const; | 102 bool IsPermissionKillSwitchOn() const; |
| 102 | 103 |
| 103 protected: | 104 protected: |
| 104 // Decide whether the permission should be granted. | 105 // Decide whether the permission should be granted. |
| 105 // Calls PermissionDecided if permission can be decided non-interactively, | 106 // Calls PermissionDecided if permission can be decided non-interactively, |
| 106 // or NotifyPermissionSet if permission decided by presenting an infobar. | 107 // or NotifyPermissionSet if permission decided by presenting an infobar. |
| 107 virtual void DecidePermission(content::WebContents* web_contents, | 108 virtual void DecidePermission(content::WebContents* web_contents, |
| 108 const PermissionRequestID& id, | 109 const PermissionRequestID& id, |
| 109 const GURL& requesting_origin, | 110 const GURL& requesting_origin, |
| 110 const GURL& embedding_origin, | 111 const GURL& embedding_origin, |
| 112 bool user_gesture, |
| 111 const BrowserPermissionCallback& callback); | 113 const BrowserPermissionCallback& callback); |
| 112 | 114 |
| 113 // Called when permission is granted without interactively asking the user. | 115 // Called when permission is granted without interactively asking the user. |
| 114 void PermissionDecided(const PermissionRequestID& id, | 116 void PermissionDecided(const PermissionRequestID& id, |
| 115 const GURL& requesting_origin, | 117 const GURL& requesting_origin, |
| 116 const GURL& embedding_origin, | 118 const GURL& embedding_origin, |
| 117 const BrowserPermissionCallback& callback, | 119 const BrowserPermissionCallback& callback, |
| 118 bool persist, | 120 bool persist, |
| 119 ContentSetting content_setting); | 121 ContentSetting content_setting); |
| 120 | 122 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 #endif | 168 #endif |
| 167 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionBubbleRequest>> | 169 base::ScopedPtrHashMap<std::string, std::unique_ptr<PermissionBubbleRequest>> |
| 168 pending_bubbles_; | 170 pending_bubbles_; |
| 169 | 171 |
| 170 // Must be the last member, to ensure that it will be | 172 // Must be the last member, to ensure that it will be |
| 171 // destroyed first, which will invalidate weak pointers | 173 // destroyed first, which will invalidate weak pointers |
| 172 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 174 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
| 173 }; | 175 }; |
| 174 | 176 |
| 175 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ | 177 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ |
| OLD | NEW |