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

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

Issue 1388343003: Adds a field trial to control Web API kill switches. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review Comments Created 5 years, 2 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 "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
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 the global permissions kill switch.
60 static const char kPermissionsKillSwitchFieldStudy[];
Bernhard Bauer 2015/10/21 10:29:03 Explain that this is public for testing?
mlamouri (slow - plz ping) 2015/10/21 11:26:06 Maybe this could move to permission_util?
kcarattini 2015/10/26 00:30:59 Added comment about testing. See my comment about
61
62 // The field trial param to enable the global permissions kill switch.
63 static const char kPermissionsKillSwitchBlockedValue[];
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 permission.
89 // public for permissions that do not use RequestPermission, like
90 // camera and microphone, and for testing.
Bernhard Bauer 2015/10/21 10:29:03 It's a bit weird to put this into PermissionContex
mlamouri (slow - plz ping) 2015/10/21 11:26:06 I wouldn't mind having this moved to permission_ut
kcarattini 2015/10/21 11:42:47 Camera and Mic do use PermissionContextBase, they
kcarattini 2015/10/26 00:30:59 I can see the reasoning for putting this in Permis
91 bool IsPermissionKillSwitchOn() const;
92
82 protected: 93 protected:
83 // Decide whether the permission should be granted. 94 // Decide whether the permission should be granted.
84 // Calls PermissionDecided if permission can be decided non-interactively, 95 // Calls PermissionDecided if permission can be decided non-interactively,
85 // or NotifyPermissionSet if permission decided by presenting an infobar. 96 // or NotifyPermissionSet if permission decided by presenting an infobar.
86 virtual void DecidePermission(content::WebContents* web_contents, 97 virtual void DecidePermission(content::WebContents* web_contents,
87 const PermissionRequestID& id, 98 const PermissionRequestID& id,
88 const GURL& requesting_origin, 99 const GURL& requesting_origin,
89 const GURL& embedding_origin, 100 const GURL& embedding_origin,
90 bool user_gesture, 101 bool user_gesture,
91 const BrowserPermissionCallback& callback); 102 const BrowserPermissionCallback& callback);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 scoped_ptr<PermissionQueueController> permission_queue_controller_; 147 scoped_ptr<PermissionQueueController> permission_queue_controller_;
137 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>> 148 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>>
138 pending_bubbles_; 149 pending_bubbles_;
139 150
140 // Must be the last member, to ensure that it will be 151 // Must be the last member, to ensure that it will be
141 // destroyed first, which will invalidate weak pointers 152 // destroyed first, which will invalidate weak pointers
142 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 153 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
143 }; 154 };
144 155
145 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_ 156 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698