Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
[email protected] | efad90f | 2014-01-17 00:45:54 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Clark DuVall | 484c256 | 2020-01-23 22:05:09 | [diff] [blame] | 5 | #ifndef COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_H_ |
| 6 | #define COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_H_ |
[email protected] | efad90f | 2014-01-17 00:45:54 | [diff] [blame] | 7 | |
Jan Wilken Dörrie | ad587c3 | 2021-03-11 14:09:27 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Avi Drissman | 12be031 | 2023-01-11 09:16:09 | [diff] [blame] | 10 | #include "base/functional/callback.h" |
Thomas Nguyen | 9f1ff730 | 2023-03-30 12:23:35 | [diff] [blame] | 11 | #include "base/memory/weak_ptr.h" |
Clark DuVall | 484c256 | 2020-01-23 22:05:09 | [diff] [blame] | 12 | #include "build/build_config.h" |
Bret Sepulveda | 5327d8b5 | 2021-07-21 17:44:23 | [diff] [blame] | 13 | #include "components/content_settings/core/common/content_settings.h" |
lshang | ada00c1 | 2016-10-17 04:51:10 | [diff] [blame] | 14 | #include "components/content_settings/core/common/content_settings_types.h" |
Andy Paicu | 0a6d4b50 | 2023-08-29 15:13:09 | [diff] [blame] | 15 | #include "components/permissions/permission_request_data.h" |
Andy Paicu | 4a88f42 | 2020-11-12 18:21:39 | [diff] [blame] | 16 | #include "components/permissions/permission_request_enums.h" |
Illia Klimov | fabd8b5 | 2021-10-21 07:15:40 | [diff] [blame] | 17 | #include "components/permissions/request_type.h" |
Illia Klimov | e406ecc1 | 2022-11-22 15:53:29 | [diff] [blame] | 18 | #include "content/public/browser/global_routing_id.h" |
Anton Bikineev | 1156b5f | 2021-05-15 22:35:36 | [diff] [blame] | 19 | #include "third_party/abseil-cpp/absl/types/optional.h" |
[email protected] | d23cdeee | 2014-03-10 06:39:53 | [diff] [blame] | 20 | #include "url/gurl.h" |
[email protected] | efad90f | 2014-01-17 00:45:54 | [diff] [blame] | 21 | |
Clark DuVall | 484c256 | 2020-01-23 22:05:09 | [diff] [blame] | 22 | namespace permissions { |
Bret Sepulveda | 362cce4 | 2021-01-13 18:47:54 | [diff] [blame] | 23 | enum class RequestType; |
Clark DuVall | 484c256 | 2020-01-23 22:05:09 | [diff] [blame] | 24 | |
tsergeant | 58defcfb | 2016-07-19 23:47:28 | [diff] [blame] | 25 | // Describes the interface a feature making permission requests should |
| 26 | // implement. A class of this type is registered with the permission request |
[email protected] | efad90f | 2014-01-17 00:45:54 | [diff] [blame] | 27 | // manager to receive updates about the result of the permissions request |
tsergeant | 58defcfb | 2016-07-19 23:47:28 | [diff] [blame] | 28 | // from the bubble or infobar. It should live until it is unregistered or until |
[email protected] | 634e598 | 2014-04-18 19:20:48 | [diff] [blame] | 29 | // RequestFinished is called. |
[email protected] | efad90f | 2014-01-17 00:45:54 | [diff] [blame] | 30 | // Note that no particular guarantees are made about what exact UI surface |
| 31 | // is presented to the user. The delegate may be coalesced with other bubble |
| 32 | // requests, or depending on the situation, not shown at all. |
tsergeant | 58defcfb | 2016-07-19 23:47:28 | [diff] [blame] | 33 | class PermissionRequest { |
[email protected] | efad90f | 2014-01-17 00:45:54 | [diff] [blame] | 34 | public: |
Bret Sepulveda | 5327d8b5 | 2021-07-21 17:44:23 | [diff] [blame] | 35 | // If `result` is CONTENT_SETTING_ALLOW, the permission was granted by the |
| 36 | // user. If it's CONTENT_SETTING_BLOCK, the permission was blocked by the |
| 37 | // user. If it's CONTENT_SETTING_DEFAULT, the permission was ignored or |
| 38 | // dismissed without an explicit decision. No other ContentSetting value will |
| 39 | // be passed into this callback. |
| 40 | // If `is_one_time` is true, the decision will last until all tabs of |
| 41 | // `requesting_origin_` are closed or navigated away from. |
| 42 | using PermissionDecidedCallback = |
Illia Klimov | e406ecc1 | 2022-11-22 15:53:29 | [diff] [blame] | 43 | base::RepeatingCallback<void(ContentSetting /*result*/, |
| 44 | bool /*is_one_time*/, |
| 45 | bool /*is_final_decision*/)>; |
[email protected] | efad90f | 2014-01-17 00:45:54 | [diff] [blame] | 46 | |
Bret Sepulveda | 5327d8b5 | 2021-07-21 17:44:23 | [diff] [blame] | 47 | // `permission_decided_callback` is called when the permission request is |
| 48 | // resolved by the user (see comment on PermissionDecidedCallback above). |
| 49 | // `delete_callback` is called when the permission request is no longer needed |
|
|