blob: 4e5f62b0aac3f0cb8a0823e61866cafbe5b1118d [file] [log] [blame]
Balazs Engedye9934acb2019-12-04 22:15:071// Copyright 2019 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
Clark DuVall5ca4ae12020-02-19 22:25:275#ifndef COMPONENTS_PERMISSIONS_NOTIFICATION_PERMISSION_UI_SELECTOR_H_
6#define COMPONENTS_PERMISSIONS_NOTIFICATION_PERMISSION_UI_SELECTOR_H_
Balazs Engedye9934acb2019-12-04 22:15:077
Clark DuVall484c2562020-01-23 22:05:098#include "components/permissions/permission_request.h"
Balazs Engedye9934acb2019-12-04 22:15:079
Clark DuVall5ca4ae12020-02-19 22:25:2710namespace permissions {
11
Balazs Engedye9934acb2019-12-04 22:15:0712// The interface for implementations that decide if the quiet prompt UI should
13// be used to display a notification permission |request|.
14//
15// Implementations of interface are expected to have long-lived instances that
16// can support multiple requests, but only one at a time.
17class NotificationPermissionUiSelector {
18 public:
19 enum class UiToUse {
20 kNormalUi,
21 kQuietUi,
22 };
23
24 enum class QuietUiReason {
25 kEnabledInPrefs,
26 kTriggeredByCrowdDeny,
27 };
28
29 using DecisionMadeCallback =
30 base::OnceCallback<void(UiToUse, base::Optional<QuietUiReason>)>;
31
32 virtual ~NotificationPermissionUiSelector() {}
33
34 // Determines the UI to use for the given |request|, and invokes |callback|
Darwin Huang1620c5f2020-01-30 20:34:0635 // when done, either synchronously or asynchronously. The |callback| is
Balazs Engedye9934acb2019-12-04 22:15:0736 // guaranteed never to be invoked after |this| goes out of scope. Only one
37 // request is supported at a time.
Clark DuVall5ca4ae12020-02-19 22:25:2738 virtual void SelectUiToUse(PermissionRequest* request,
Balazs Engedye9934acb2019-12-04 22:15:0739 DecisionMadeCallback callback) = 0;
40
41 // Cancel the pending request, if any. After this, the |callback| is
42 // guaranteed not to be invoked anymore, and another call to SelectUiToUse()
43 // can be issued.
44 virtual void Cancel() {}
45};
46
Clark DuVall5ca4ae12020-02-19 22:25:2747} // namespace permissions
48
49#endif // COMPONENTS_PERMISSIONS_NOTIFICATION_PERMISSION_UI_SELECTOR_H_