blob: ce4611c37621e4689426785ebe693513144247c4 [file] [log] [blame]
[email protected]efad90f2014-01-17 00:45:541// 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
[email protected]e2ff17e2014-02-06 02:32:335#ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_
6#define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_
[email protected]efad90f2014-01-17 00:45:547
8#include "base/strings/string16.h"
[email protected]d23cdeee2014-03-10 06:39:539#include "url/gurl.h"
[email protected]efad90f2014-01-17 00:45:5410
estade292df4f82015-07-31 18:53:2511namespace gfx {
12enum class VectorIconId;
13}
14
[email protected]efad90f2014-01-17 00:45:5415// Describes the interface a feature utilizing permission bubbles should
16// implement. A class of this type is registered with the permission bubble
17// manager to receive updates about the result of the permissions request
18// from the bubble. It should live until it is unregistered or until
[email protected]634e5982014-04-18 19:20:4819// RequestFinished is called.
[email protected]efad90f2014-01-17 00:45:5420// Note that no particular guarantees are made about what exact UI surface
21// is presented to the user. The delegate may be coalesced with other bubble
22// requests, or depending on the situation, not shown at all.
[email protected]e2ff17e2014-02-06 02:32:3323class PermissionBubbleRequest {
[email protected]efad90f2014-01-17 00:45:5424 public:
[email protected]e2ff17e2014-02-06 02:32:3325 virtual ~PermissionBubbleRequest() {}
[email protected]efad90f2014-01-17 00:45:5426
estade0a679f82015-07-16 19:31:5627 // Returns a vector icon id if the icon should be drawn as a vector
28 // resource. Otherwise, returns VECTOR_ICON_NONE.
29 virtual gfx::VectorIconId GetVectorIconId() const;
30
[email protected]d23cdeee2014-03-10 06:39:5331 // The icon to use next to the message text fragment in the permission bubble.
felt9dd8cd72015-01-30 22:15:4532 // Must be a valid icon of size 18x18.
estadeceb84ab2015-09-03 00:52:1633 virtual int GetIconId() const = 0;
[email protected]d23cdeee2014-03-10 06:39:5334
[email protected]dd1ba692014-01-24 23:17:3735 // Returns the full prompt text for this permission. This is the only text
36 // that will be shown in the single-permission case and should be phrased
37 // positively as a complete sentence.
[email protected]efad90f2014-01-17 00:45:5438 virtual base::string16 GetMessageText() const = 0;
39
[email protected]dd1ba692014-01-24 23:17:3740 // Returns the shortened prompt text for this permission. Must be phrased
[email protected]d23cdeee2014-03-10 06:39:5341 // as a heading, e.g. "Location", or "Camera". The permission bubble may
42 // coalesce different requests, and if it does, this text will be displayed
43 // next to an image and indicate the user grants the permission.
[email protected]dd1ba692014-01-24 23:17:3744 virtual base::string16 GetMessageTextFragment() const = 0;
45
mlamourie8f2f0d2015-10-20 23:09:2746 // Get whether this request was accompanied by a user gesture. Gestured
47 // requests will have priority over non-gestured ones.
[email protected]d23cdeee2014-03-10 06:39:5348 virtual bool HasUserGesture() const = 0;
[email protected]efad90f2014-01-17 00:45:5449
johnmefe4e96d2016-01-27 16:14:4150 // Get the origin on whose behalf this permission request is being made.
51 virtual GURL GetOrigin() const = 0;
[email protected]dd1ba692014-01-24 23:17:3752
[email protected]efad90f2014-01-17 00:45:5453 // Called when the user has granted the requested permission.
54 virtual void PermissionGranted() = 0;
55
56 // Called when the user has denied the requested permission.
57 virtual void PermissionDenied() = 0;
58
59 // Called when the user has cancelled the permission request. This
60 // corresponds to a denial, but is segregated in case the context needs to
61 // be able to distinguish between an active refusal or an implicit refusal.
62 virtual void Cancelled() = 0;
63
[email protected]e2ff17e2014-02-06 02:32:3364 // The bubble this request was associated with was answered by the user.
65 // It is safe for the request to be deleted at this point -- it will receive
[email protected]efad90f2014-01-17 00:45:5466 // no further message from the permission bubble system. This method will
[email protected]e2ff17e2014-02-06 02:32:3367 // eventually be called on every request which is not unregistered.
[email protected]efad90f2014-01-17 00:45:5468 virtual void RequestFinished() = 0;
69};
70
[email protected]e2ff17e2014-02-06 02:32:3371#endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_REQUEST_H_