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_REQUEST_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_H_ |
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_H_ |
7 | 7 |
8 #include "base/macros.h" | |
8 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
9 #include "content/public/browser/permission_type.h" | 10 #include "content/public/browser/permission_type.h" |
10 #include "url/gurl.h" | 11 #include "url/gurl.h" |
11 | 12 |
12 namespace gfx { | 13 namespace gfx { |
13 enum class VectorIconId; | 14 enum class VectorIconId; |
14 } | 15 } |
15 | 16 |
16 // Used for UMA to record the types of permission prompts shown. | 17 // Used for UMA to record the types of permission prompts shown. |
17 // This corresponds to the PermissionRequestType enum in | 18 // This corresponds to the PermissionRequestType enum in |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 // Describes the interface a feature making permission requests should | 52 // Describes the interface a feature making permission requests should |
52 // implement. A class of this type is registered with the permission request | 53 // implement. A class of this type is registered with the permission request |
53 // manager to receive updates about the result of the permissions request | 54 // manager to receive updates about the result of the permissions request |
54 // from the bubble or infobar. It should live until it is unregistered or until | 55 // from the bubble or infobar. It should live until it is unregistered or until |
55 // RequestFinished is called. | 56 // RequestFinished is called. |
56 // Note that no particular guarantees are made about what exact UI surface | 57 // Note that no particular guarantees are made about what exact UI surface |
57 // is presented to the user. The delegate may be coalesced with other bubble | 58 // is presented to the user. The delegate may be coalesced with other bubble |
58 // requests, or depending on the situation, not shown at all. | 59 // requests, or depending on the situation, not shown at all. |
59 class PermissionRequest { | 60 class PermissionRequest { |
60 public: | 61 public: |
62 PermissionRequest(); | |
61 virtual ~PermissionRequest() {} | 63 virtual ~PermissionRequest() {} |
62 | 64 |
63 // Returns a vector icon id if the icon should be drawn as a vector | 65 // Returns a vector icon id if the icon should be drawn as a vector |
64 // resource. Otherwise, returns VECTOR_ICON_NONE. | 66 // resource. Otherwise, returns VECTOR_ICON_NONE. |
65 virtual gfx::VectorIconId GetVectorIconId() const; | 67 virtual gfx::VectorIconId GetVectorIconId() const; |
66 | 68 |
67 // The icon to use next to the message text fragment in the permission bubble. | 69 // The icon to use next to the message text fragment in the permission bubble. |
68 // Must be a valid icon of size 18x18. | 70 // Must be a valid icon of size 18x18. |
69 virtual int GetIconId() const = 0; | 71 virtual int GetIconId() const = 0; |
70 | 72 |
(...skipping 16 matching lines...) Expand all Loading... | |
87 // corresponds to a denial, but is segregated in case the context needs to | 89 // corresponds to a denial, but is segregated in case the context needs to |
88 // be able to distinguish between an active refusal or an implicit refusal. | 90 // be able to distinguish between an active refusal or an implicit refusal. |
89 virtual void Cancelled() = 0; | 91 virtual void Cancelled() = 0; |
90 | 92 |
91 // The UI this request was associated with was answered by the user. | 93 // The UI this request was associated with was answered by the user. |
92 // It is safe for the request to be deleted at this point -- it will receive | 94 // It is safe for the request to be deleted at this point -- it will receive |
93 // no further message from the permission request system. This method will | 95 // no further message from the permission request system. This method will |
94 // eventually be called on every request which is not unregistered. | 96 // eventually be called on every request which is not unregistered. |
95 virtual void RequestFinished() = 0; | 97 virtual void RequestFinished() = 0; |
96 | 98 |
99 // True if a persistence toggle should be shown in the UI for this request. | |
100 virtual bool ShouldShowPersistenceToggle() const; | |
101 | |
97 // Used to record UMA metrics for permission requests. | 102 // Used to record UMA metrics for permission requests. |
98 virtual PermissionRequestType GetPermissionRequestType() const; | 103 virtual PermissionRequestType GetPermissionRequestType() const; |
99 | 104 |
100 // Used to record UMA for whether requests are associated with a user gesture. | 105 // Used to record UMA for whether requests are associated with a user gesture. |
101 // To keep things simple this metric is only recorded for the most popular | 106 // To keep things simple this metric is only recorded for the most popular |
102 // request types. | 107 // request types. |
103 virtual PermissionRequestGestureType GetGestureType() const; | 108 virtual PermissionRequestGestureType GetGestureType() const; |
109 | |
110 void set_persist(bool persist) { persist_ = persist; } | |
111 | |
112 protected: | |
113 bool persist() const { return persist_; } | |
114 | |
115 private: | |
116 // Whether or not the response for this prompt should be persisted. | |
117 bool persist_; | |
Sergey Ulanov
2016/08/19 17:11:53
PermissionRequest is an interface and style guide
dominickn
2016/08/20 01:19:24
PermissionRequest doesn't actually satisfy the con
| |
118 | |
119 DISALLOW_COPY_AND_ASSIGN(PermissionRequest); | |
104 }; | 120 }; |
105 | 121 |
106 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_H_ | 122 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_H_ |
OLD | NEW |