| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ | |
| 7 | |
| 8 #include "base/strings/string16.h" | |
| 9 #include "content/public/browser/permission_type.h" | |
| 10 #include "url/gurl.h" | |
| 11 | |
| 12 namespace gfx { | |
| 13 enum class VectorIconId; | |
| 14 } | |
| 15 | |
| 16 // Used for UMA to record the types of permission prompts shown. | |
| 17 // This corresponds to the PermissionBubbleType enum in | |
| 18 // src/tools/metrics/histograms.xml. The usual rules of updating UMA values | |
| 19 // applies to this enum: | |
| 20 // - don't remove values | |
| 21 // - only ever add values at the end | |
| 22 // - keep the PermissionBubbleType enum in sync with this definition. | |
| 23 enum class PermissionBubbleType { | |
| 24 UNKNOWN, | |
| 25 MULTIPLE, | |
| 26 UNUSED_PERMISSION, | |
| 27 QUOTA, | |
| 28 DOWNLOAD, | |
| 29 MEDIA_STREAM, | |
| 30 REGISTER_PROTOCOL_HANDLER, | |
| 31 PERMISSION_GEOLOCATION, | |
| 32 PERMISSION_MIDI_SYSEX, | |
| 33 PERMISSION_NOTIFICATIONS, | |
| 34 PERMISSION_PROTECTED_MEDIA_IDENTIFIER, | |
| 35 PERMISSION_PUSH_MESSAGING, | |
| 36 // NUM must be the last value in the enum. | |
| 37 NUM | |
| 38 }; | |
| 39 | |
| 40 // Describes the interface a feature utilizing permission bubbles should | |
| 41 // implement. A class of this type is registered with the permission bubble | |
| 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 | |
| 44 // RequestFinished is called. | |
| 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 | |
| 47 // requests, or depending on the situation, not shown at all. | |
| 48 class PermissionBubbleRequest { | |
| 49 public: | |
| 50 virtual ~PermissionBubbleRequest() {} | |
| 51 | |
| 52 // Returns a vector icon id if the icon should be drawn as a vector | |
| 53 // resource. Otherwise, returns VECTOR_ICON_NONE. | |
| 54 virtual gfx::VectorIconId GetVectorIconId() const; | |
| 55 | |
| 56 // The icon to use next to the message text fragment in the permission bubble. | |
| 57 // Must be a valid icon of size 18x18. | |
| 58 virtual int GetIconId() const = 0; | |
| 59 | |
| 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 | |
| 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. | |
| 64 virtual base::string16 GetMessageTextFragment() const = 0; | |
| 65 | |
| 66 // Get the origin on whose behalf this permission request is being made. | |
| 67 virtual GURL GetOrigin() const = 0; | |
| 68 | |
| 69 // Called when the user has granted the requested permission. | |
| 70 virtual void PermissionGranted() = 0; | |
| 71 | |
| 72 // Called when the user has denied the requested permission. | |
| 73 virtual void PermissionDenied() = 0; | |
| 74 | |
| 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 | |
| 77 // be able to distinguish between an active refusal or an implicit refusal. | |
| 78 virtual void Cancelled() = 0; | |
| 79 | |
| 80 // The bubble 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 | |
| 82 // no further message from the permission bubble system. This method will | |
| 83 // eventually be called on every request which is not unregistered. | |
| 84 virtual void RequestFinished() = 0; | |
| 85 | |
| 86 // Used to record UMA metrics for bubbles. | |
| 87 virtual PermissionBubbleType GetPermissionBubbleType() const; | |
| 88 }; | |
| 89 | |
| 90 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ | |
| OLD | NEW |