| 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 "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/containers/scoped_ptr_hash_map.h" | 9 #include "base/containers/scoped_ptr_hash_map.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // It is mandatory to override IsRestrictedToSecureOrigin. | 51 // It is mandatory to override IsRestrictedToSecureOrigin. |
| 52 // See midi_permission_context.h/cc or push_permission_context.cc/h for some | 52 // See midi_permission_context.h/cc or push_permission_context.cc/h for some |
| 53 // examples. | 53 // examples. |
| 54 | 54 |
| 55 class PermissionContextBase : public KeyedService { | 55 class PermissionContextBase : public KeyedService { |
| 56 public: | 56 public: |
| 57 PermissionContextBase(Profile* profile, | 57 PermissionContextBase(Profile* profile, |
| 58 const ContentSettingsType permission_type); | 58 const ContentSettingsType permission_type); |
| 59 ~PermissionContextBase() override; | 59 ~PermissionContextBase() override; |
| 60 | 60 |
| 61 // A field trial used to enable the global permissions kill switch. |
| 62 // This is public for testing purposes. |
| 63 static const char kPermissionsKillSwitchFieldStudy[]; |
| 64 |
| 65 // The field trial param to enable the global permissions kill switch. |
| 66 // This is public for testing purposes. |
| 67 static const char kPermissionsKillSwitchBlockedValue[]; |
| 68 |
| 61 // The renderer is requesting permission to push messages. | 69 // The renderer is requesting permission to push messages. |
| 62 // When the answer to a permission request has been determined, |callback| | 70 // When the answer to a permission request has been determined, |callback| |
| 63 // should be called with the result. | 71 // should be called with the result. |
| 64 virtual void RequestPermission(content::WebContents* web_contents, | 72 virtual void RequestPermission(content::WebContents* web_contents, |
| 65 const PermissionRequestID& id, | 73 const PermissionRequestID& id, |
| 66 const GURL& requesting_frame, | 74 const GURL& requesting_frame, |
| 67 bool user_gesture, | 75 bool user_gesture, |
| 68 const BrowserPermissionCallback& callback); | 76 const BrowserPermissionCallback& callback); |
| 69 | 77 |
| 70 // Returns whether the permission has been granted, denied... | 78 // Returns whether the permission has been granted, denied... |
| 71 virtual ContentSetting GetPermissionStatus( | 79 virtual ContentSetting GetPermissionStatus( |
| 72 const GURL& requesting_origin, | 80 const GURL& requesting_origin, |
| 73 const GURL& embedding_origin) const; | 81 const GURL& embedding_origin) const; |
| 74 | 82 |
| 75 // Resets the permission to its default value. | 83 // Resets the permission to its default value. |
| 76 virtual void ResetPermission(const GURL& requesting_origin, | 84 virtual void ResetPermission(const GURL& requesting_origin, |
| 77 const GURL& embedding_origin); | 85 const GURL& embedding_origin); |
| 78 | 86 |
| 79 // Withdraw an existing permission request, no op if the permission request | 87 // Withdraw an existing permission request, no op if the permission request |
| 80 // was already cancelled by some other means. | 88 // was already cancelled by some other means. |
| 81 virtual void CancelPermissionRequest(content::WebContents* web_contents, | 89 virtual void CancelPermissionRequest(content::WebContents* web_contents, |
| 82 const PermissionRequestID& id); | 90 const PermissionRequestID& id); |
| 83 | 91 |
| 92 // Whether the kill switch has been enabled for this permission. |
| 93 // public for permissions that do not use RequestPermission, like |
| 94 // camera and microphone, and for testing. |
| 95 bool IsPermissionKillSwitchOn() const; |
| 96 |
| 84 protected: | 97 protected: |
| 85 // Decide whether the permission should be granted. | 98 // Decide whether the permission should be granted. |
| 86 // Calls PermissionDecided if permission can be decided non-interactively, | 99 // Calls PermissionDecided if permission can be decided non-interactively, |
| 87 // or NotifyPermissionSet if permission decided by presenting an infobar. | 100 // or NotifyPermissionSet if permission decided by presenting an infobar. |
| 88 virtual void DecidePermission(content::WebContents* web_contents, | 101 virtual void DecidePermission(content::WebContents* web_contents, |
| 89 const PermissionRequestID& id, | 102 const PermissionRequestID& id, |
| 90 const GURL& requesting_origin, | 103 const GURL& requesting_origin, |
| 91 const GURL& embedding_origin, | 104 const GURL& embedding_origin, |
| 92 bool user_gesture, | 105 bool user_gesture, |
| 93 const BrowserPermissionCallback& callback); | 106 const BrowserPermissionCallback& callback); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 #endif | 155 #endif |
| 143 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>> | 156 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>> |
| 144 pending_bubbles_; | 157 pending_bubbles_; |
| 145 | 158 |
| 146 // Must be the last member, to ensure that it will be | 159 // Must be the last member, to ensure that it will be |
| 147 // destroyed first, which will invalidate weak pointers | 160 // destroyed first, which will invalidate weak pointers |
| 148 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 161 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
| 149 }; | 162 }; |
| 150 | 163 |
| 151 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ | 164 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ |
| OLD | NEW |