Chromium Code Reviews| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 // It is mandatory to override IsRestrictedToSecureOrigin. | 49 // It is mandatory to override IsRestrictedToSecureOrigin. |
| 50 // See midi_permission_context.h/cc or push_permission_context.cc/h for some | 50 // See midi_permission_context.h/cc or push_permission_context.cc/h for some |
| 51 // examples. | 51 // examples. |
| 52 | 52 |
| 53 class PermissionContextBase : public KeyedService { | 53 class PermissionContextBase : public KeyedService { |
| 54 public: | 54 public: |
| 55 PermissionContextBase(Profile* profile, | 55 PermissionContextBase(Profile* profile, |
| 56 const ContentSettingsType permission_type); | 56 const ContentSettingsType permission_type); |
| 57 ~PermissionContextBase() override; | 57 ~PermissionContextBase() override; |
| 58 | 58 |
| 59 // A field trial used to enable thw global API kill switch. | |
|
raymes
2015/10/13 01:30:18
nit: thw->the
kcarattini
2015/10/13 03:06:22
Done.
| |
| 60 static const char kApiKillSwitchFieldStudy[]; | |
| 61 | |
| 62 // The field trial param to enable an API kill switch. | |
| 63 static const char kApiKillSwitchFieldParamEnabledValue[]; | |
|
raymes
2015/10/13 01:30:18
nit: you've referred to the kill switch in two dif
kcarattini
2015/10/13 03:06:22
I made them both "global. I want to distinguish th
| |
| 64 | |
| 59 // The renderer is requesting permission to push messages. | 65 // The renderer is requesting permission to push messages. |
| 60 // When the answer to a permission request has been determined, |callback| | 66 // When the answer to a permission request has been determined, |callback| |
| 61 // should be called with the result. | 67 // should be called with the result. |
| 62 virtual void RequestPermission(content::WebContents* web_contents, | 68 virtual void RequestPermission(content::WebContents* web_contents, |
| 63 const PermissionRequestID& id, | 69 const PermissionRequestID& id, |
| 64 const GURL& requesting_frame, | 70 const GURL& requesting_frame, |
| 65 bool user_gesture, | 71 bool user_gesture, |
| 66 const BrowserPermissionCallback& callback); | 72 const BrowserPermissionCallback& callback); |
| 67 | 73 |
| 68 // Returns whether the permission has been granted, denied... | 74 // Returns whether the permission has been granted, denied... |
| 69 virtual ContentSetting GetPermissionStatus( | 75 virtual ContentSetting GetPermissionStatus( |
| 70 const GURL& requesting_origin, | 76 const GURL& requesting_origin, |
| 71 const GURL& embedding_origin) const; | 77 const GURL& embedding_origin) const; |
| 72 | 78 |
| 73 // Resets the permission to its default value. | 79 // Resets the permission to its default value. |
| 74 virtual void ResetPermission(const GURL& requesting_origin, | 80 virtual void ResetPermission(const GURL& requesting_origin, |
| 75 const GURL& embedding_origin); | 81 const GURL& embedding_origin); |
| 76 | 82 |
| 77 // Withdraw an existing permission request, no op if the permission request | 83 // Withdraw an existing permission request, no op if the permission request |
| 78 // was already cancelled by some other means. | 84 // was already cancelled by some other means. |
| 79 virtual void CancelPermissionRequest(content::WebContents* web_contents, | 85 virtual void CancelPermissionRequest(content::WebContents* web_contents, |
| 80 const PermissionRequestID& id); | 86 const PermissionRequestID& id); |
| 81 | 87 |
| 88 // Whether the kill switch has been enabled for this API. | |
| 89 virtual bool IsApiKillSwitchOn() const; | |
| 90 | |
| 82 protected: | 91 protected: |
| 83 // Decide whether the permission should be granted. | 92 // Decide whether the permission should be granted. |
| 84 // Calls PermissionDecided if permission can be decided non-interactively, | 93 // Calls PermissionDecided if permission can be decided non-interactively, |
| 85 // or NotifyPermissionSet if permission decided by presenting an infobar. | 94 // or NotifyPermissionSet if permission decided by presenting an infobar. |
| 86 virtual void DecidePermission(content::WebContents* web_contents, | 95 virtual void DecidePermission(content::WebContents* web_contents, |
| 87 const PermissionRequestID& id, | 96 const PermissionRequestID& id, |
| 88 const GURL& requesting_origin, | 97 const GURL& requesting_origin, |
| 89 const GURL& embedding_origin, | 98 const GURL& embedding_origin, |
| 90 bool user_gesture, | 99 bool user_gesture, |
| 91 const BrowserPermissionCallback& callback); | 100 const BrowserPermissionCallback& callback); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 145 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
| 137 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>> | 146 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>> |
| 138 pending_bubbles_; | 147 pending_bubbles_; |
| 139 | 148 |
| 140 // Must be the last member, to ensure that it will be | 149 // Must be the last member, to ensure that it will be |
| 141 // destroyed first, which will invalidate weak pointers | 150 // destroyed first, which will invalidate weak pointers |
| 142 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 151 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
| 143 }; | 152 }; |
| 144 | 153 |
| 145 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ | 154 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ |
| OLD | NEW |