| 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_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_H_ |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_H_ |
| 7 | 7 |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "content/public/browser/permission_type.h" | 9 #include "content/public/browser/permission_type.h" |
| 10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| 11 | 11 |
| 12 namespace gfx { | 12 namespace gfx { |
| 13 enum class VectorIconId; | 13 enum class VectorIconId; |
| 14 } | 14 } |
| 15 | 15 |
| 16 // Used for UMA to record the types of permission prompts shown. | 16 // Used for UMA to record the types of permission prompts shown. |
| 17 // This corresponds to the PermissionBubbleType enum in | 17 // This corresponds to the PermissionRequestType enum in |
| 18 // src/tools/metrics/histograms.xml. The usual rules of updating UMA values | 18 // src/tools/metrics/histograms.xml. The usual rules of updating UMA values |
| 19 // applies to this enum: | 19 // applies to this enum: |
| 20 // - don't remove values | 20 // - don't remove values |
| 21 // - only ever add values at the end | 21 // - only ever add values at the end |
| 22 // - keep the PermissionBubbleType enum in sync with this definition. | 22 // - keep the PermissionRequestType enum in sync with this definition. |
| 23 enum class PermissionBubbleType { | 23 enum class PermissionRequestType { |
| 24 UNKNOWN, | 24 UNKNOWN, |
| 25 MULTIPLE, | 25 MULTIPLE, |
| 26 UNUSED_PERMISSION, | 26 UNUSED_PERMISSION, |
| 27 QUOTA, | 27 QUOTA, |
| 28 DOWNLOAD, | 28 DOWNLOAD, |
| 29 MEDIA_STREAM, | 29 MEDIA_STREAM, |
| 30 REGISTER_PROTOCOL_HANDLER, | 30 REGISTER_PROTOCOL_HANDLER, |
| 31 PERMISSION_GEOLOCATION, | 31 PERMISSION_GEOLOCATION, |
| 32 PERMISSION_MIDI_SYSEX, | 32 PERMISSION_MIDI_SYSEX, |
| 33 PERMISSION_NOTIFICATIONS, | 33 PERMISSION_NOTIFICATIONS, |
| 34 PERMISSION_PROTECTED_MEDIA_IDENTIFIER, | 34 PERMISSION_PROTECTED_MEDIA_IDENTIFIER, |
| 35 PERMISSION_PUSH_MESSAGING, | 35 PERMISSION_PUSH_MESSAGING, |
| 36 // NUM must be the last value in the enum. | 36 // NUM must be the last value in the enum. |
| 37 NUM | 37 NUM |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Describes the interface a feature utilizing permission bubbles should | 40 // Describes the interface a feature making permission requests should |
| 41 // implement. A class of this type is registered with the permission bubble | 41 // implement. A class of this type is registered with the permission request |
| 42 // manager to receive updates about the result of the permissions request | 42 // manager to receive updates about the result of the permissions request |
| 43 // from the bubble. It should live until it is unregistered or until | 43 // from the bubble or infobar. It should live until it is unregistered or until |
| 44 // RequestFinished is called. | 44 // RequestFinished is called. |
| 45 // Note that no particular guarantees are made about what exact UI surface | 45 // Note that no particular guarantees are made about what exact UI surface |
| 46 // is presented to the user. The delegate may be coalesced with other bubble | 46 // is presented to the user. The delegate may be coalesced with other bubble |
| 47 // requests, or depending on the situation, not shown at all. | 47 // requests, or depending on the situation, not shown at all. |
| 48 class PermissionBubbleRequest { | 48 class PermissionRequest { |
| 49 public: | 49 public: |
| 50 virtual ~PermissionBubbleRequest() {} | 50 virtual ~PermissionRequest() {} |
| 51 | 51 |
| 52 // Returns a vector icon id if the icon should be drawn as a vector | 52 // Returns a vector icon id if the icon should be drawn as a vector |
| 53 // resource. Otherwise, returns VECTOR_ICON_NONE. | 53 // resource. Otherwise, returns VECTOR_ICON_NONE. |
| 54 virtual gfx::VectorIconId GetVectorIconId() const; | 54 virtual gfx::VectorIconId GetVectorIconId() const; |
| 55 | 55 |
| 56 // The icon to use next to the message text fragment in the permission bubble. | 56 // The icon to use next to the message text fragment in the permission bubble. |
| 57 // Must be a valid icon of size 18x18. | 57 // Must be a valid icon of size 18x18. |
| 58 virtual int GetIconId() const = 0; | 58 virtual int GetIconId() const = 0; |
| 59 | 59 |
| 60 // Returns the shortened prompt text for this permission. Must be phrased | 60 // Returns the shortened prompt text for this permission. Must be phrased |
| 61 // as a heading, e.g. "Location", or "Camera". The permission bubble may | 61 // as a heading, e.g. "Location", or "Camera". The permission bubble may |
| 62 // coalesce different requests, and if it does, this text will be displayed | 62 // coalesce different requests, and if it does, this text will be displayed |
| 63 // next to an image and indicate the user grants the permission. | 63 // next to an image and indicate the user grants the permission. |
| 64 virtual base::string16 GetMessageTextFragment() const = 0; | 64 virtual base::string16 GetMessageTextFragment() const = 0; |
| 65 | 65 |
| 66 // Get the origin on whose behalf this permission request is being made. | 66 // Get the origin on whose behalf this permission request is being made. |
| 67 virtual GURL GetOrigin() const = 0; | 67 virtual GURL GetOrigin() const = 0; |
| 68 | 68 |
| 69 // Called when the user has granted the requested permission. | 69 // Called when the user has granted the requested permission. |
| 70 virtual void PermissionGranted() = 0; | 70 virtual void PermissionGranted() = 0; |
| 71 | 71 |
| 72 // Called when the user has denied the requested permission. | 72 // Called when the user has denied the requested permission. |
| 73 virtual void PermissionDenied() = 0; | 73 virtual void PermissionDenied() = 0; |
| 74 | 74 |
| 75 // Called when the user has cancelled the permission request. This | 75 // Called when the user has cancelled the permission request. This |
| 76 // corresponds to a denial, but is segregated in case the context needs to | 76 // corresponds to a denial, but is segregated in case the context needs to |
| 77 // be able to distinguish between an active refusal or an implicit refusal. | 77 // be able to distinguish between an active refusal or an implicit refusal. |
| 78 virtual void Cancelled() = 0; | 78 virtual void Cancelled() = 0; |
| 79 | 79 |
| 80 // The bubble this request was associated with was answered by the user. | 80 // The UI this request was associated with was answered by the user. |
| 81 // It is safe for the request to be deleted at this point -- it will receive | 81 // It is safe for the request to be deleted at this point -- it will receive |
| 82 // no further message from the permission bubble system. This method will | 82 // no further message from the permission request system. This method will |
| 83 // eventually be called on every request which is not unregistered. | 83 // eventually be called on every request which is not unregistered. |
| 84 virtual void RequestFinished() = 0; | 84 virtual void RequestFinished() = 0; |
| 85 | 85 |
| 86 // Used to record UMA metrics for bubbles. | 86 // Used to record UMA metrics for permission requests. |
| 87 virtual PermissionBubbleType GetPermissionBubbleType() const; | 87 virtual PermissionRequestType GetPermissionRequestType() const; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ | 90 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_H_ |
| OLD | NEW |