| 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_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ | 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ |
| 7 | 7 |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 10 | 10 |
| 11 // Describes the interface a feature utilizing permission bubbles should | 11 // Describes the interface a feature utilizing permission bubbles should |
| 12 // implement. A class of this type is registered with the permission bubble | 12 // implement. A class of this type is registered with the permission bubble |
| 13 // manager to receive updates about the result of the permissions request | 13 // manager to receive updates about the result of the permissions request |
| 14 // from the bubble. It should live until it is unregistered or until | 14 // from the bubble. It should live until it is unregistered or until |
| 15 // RequestFinished is called. | 15 // RequestFinished is called. |
| 16 // Note that no particular guarantees are made about what exact UI surface | 16 // Note that no particular guarantees are made about what exact UI surface |
| 17 // is presented to the user. The delegate may be coalesced with other bubble | 17 // is presented to the user. The delegate may be coalesced with other bubble |
| 18 // requests, or depending on the situation, not shown at all. | 18 // requests, or depending on the situation, not shown at all. |
| 19 class PermissionBubbleRequest { | 19 class PermissionBubbleRequest { |
| 20 public: | 20 public: |
| 21 enum Type { kQuota, kDownload, kGeolocation, kMedia, kOther }; |
| 21 virtual ~PermissionBubbleRequest() {} | 22 virtual ~PermissionBubbleRequest() {} |
| 22 | 23 |
| 24 virtual PermissionBubbleRequest::Type GetType() const = 0; |
| 25 |
| 23 // The icon to use next to the message text fragment in the permission bubble. | 26 // The icon to use next to the message text fragment in the permission bubble. |
| 24 // Must be a valid icon of size 16x16. (TODO(gbillock): tbd size) | 27 // Must be a valid icon of size 16x16. (TODO(gbillock): tbd size) |
| 25 virtual int GetIconID() const = 0; | 28 virtual int GetIconID() const = 0; |
| 26 | 29 |
| 27 // Returns the full prompt text for this permission. This is the only text | 30 // Returns the full prompt text for this permission. This is the only text |
| 28 // that will be shown in the single-permission case and should be phrased | 31 // that will be shown in the single-permission case and should be phrased |
| 29 // positively as a complete sentence. | 32 // positively as a complete sentence. |
| 30 virtual base::string16 GetMessageText() const = 0; | 33 virtual base::string16 GetMessageText() const = 0; |
| 31 | 34 |
| 32 // Returns the shortened prompt text for this permission. Must be phrased | 35 // Returns the shortened prompt text for this permission. Must be phrased |
| 33 // as a heading, e.g. "Location", or "Camera". The permission bubble may | 36 // as a heading, e.g. "Location", or "Camera". The permission bubble may |
| 34 // coalesce different requests, and if it does, this text will be displayed | 37 // coalesce different requests, and if it does, this text will be displayed |
| 35 // next to an image and indicate the user grants the permission. | 38 // next to an image and indicate the user grants the permission. |
| 36 virtual base::string16 GetMessageTextFragment() const = 0; | 39 virtual base::string16 GetMessageTextFragment() const = 0; |
| 37 | 40 |
| 38 // Get whether this request was accompanied by a user gesture. User gestured | 41 // Get whether this request was accompanied by a user gesture. User gestured |
| 39 // permissions requests will not be suppressed. | 42 // permissions requests will not be suppressed. |
| 40 virtual bool HasUserGesture() const = 0; | 43 virtual bool HasUserGesture() const = 0; |
| 41 | 44 |
| 42 // Get the hostname on whose behalf this permission request is being made. | 45 // Get the hostname on whose behalf this permission request is being made. |
| 43 virtual GURL GetRequestingHostname() const = 0; | 46 virtual GURL GetRequestingHostname() const = 0; |
| 44 | 47 |
| 45 // Called when the user has granted the requested permission. | 48 // Called when the user has granted the requested permission. |
| 46 virtual void PermissionGranted() = 0; | 49 virtual void PermissionGranted() = 0; |
| 47 | 50 |
| 51 // Called when the user has granted the requested permission with a choice |
| 52 void PermissionGranted(int choice) { PermissionGranted(); } |
| 53 |
| 48 // Called when the user has denied the requested permission. | 54 // Called when the user has denied the requested permission. |
| 49 virtual void PermissionDenied() = 0; | 55 virtual void PermissionDenied() = 0; |
| 50 | 56 |
| 51 // Called when the user has cancelled the permission request. This | 57 // Called when the user has cancelled the permission request. This |
| 52 // corresponds to a denial, but is segregated in case the context needs to | 58 // corresponds to a denial, but is segregated in case the context needs to |
| 53 // be able to distinguish between an active refusal or an implicit refusal. | 59 // be able to distinguish between an active refusal or an implicit refusal. |
| 54 virtual void Cancelled() = 0; | 60 virtual void Cancelled() = 0; |
| 55 | 61 |
| 56 // The bubble this request was associated with was answered by the user. | 62 // The bubble this request was associated with was answered by the user. |
| 57 // It is safe for the request to be deleted at this point -- it will receive | 63 // It is safe for the request to be deleted at this point -- it will receive |
| 58 // no further message from the permission bubble system. This method will | 64 // no further message from the permission bubble system. This method will |
| 59 // eventually be called on every request which is not unregistered. | 65 // eventually be called on every request which is not unregistered. |
| 60 virtual void RequestFinished() = 0; | 66 virtual void RequestFinished() = 0; |
| 61 }; | 67 }; |
| 62 | 68 |
| 63 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ | 69 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_ |
| OLD | NEW |