Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Francois Beaufort | 51f9ee3 | 2019-11-05 06:48:16 | [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 | |
Michael van Ouwerkerk | c71455e | 2021-03-30 10:34:37 | [diff] [blame] | 5 | #ifndef COMPONENTS_PERMISSIONS_CONTEXTS_NFC_PERMISSION_CONTEXT_H_ |
| 6 | #define COMPONENTS_PERMISSIONS_CONTEXTS_NFC_PERMISSION_CONTEXT_H_ |
Francois Beaufort | 51f9ee3 | 2019-11-05 06:48:16 | [diff] [blame] | 7 | |
Michael van Ouwerkerk | 9783ec61 | 2021-03-29 11:51:51 | [diff] [blame] | 8 | #include "build/build_config.h" |
Clark DuVall | a11361ad3 | 2020-02-20 22:14:27 | [diff] [blame] | 9 | #include "components/permissions/permission_context_base.h" |
Francois Beaufort | 51f9ee3 | 2019-11-05 06:48:16 | [diff] [blame] | 10 | |
Michael van Ouwerkerk | c71455e | 2021-03-30 10:34:37 | [diff] [blame] | 11 | namespace permissions { |
| 12 | |
| 13 | class NfcPermissionContext : public PermissionContextBase { |
Francois Beaufort | 51f9ee3 | 2019-11-05 06:48:16 | [diff] [blame] | 14 | public: |
Michael van Ouwerkerk | 9783ec61 | 2021-03-29 11:51:51 | [diff] [blame] | 15 | // The delegate allows embedders to modify the permission context logic. |
| 16 | class Delegate { |
| 17 | public: |
| 18 | virtual ~Delegate() = default; |
| 19 | |
Xiaohan Wang | e81358230 | 2022-01-14 14:50:46 | [diff] [blame] | 20 | #if BUILDFLAG(IS_ANDROID) |
Michael van Ouwerkerk | 9783ec61 | 2021-03-29 11:51:51 | [diff] [blame] | 21 | // Returns whether or not this |web_contents| is interactable. |
| 22 | virtual bool IsInteractable(content::WebContents* web_contents) = 0; |
| 23 | #endif |
| 24 | }; |
| 25 | |
| 26 | NfcPermissionContext(content::BrowserContext* browser_context, |
| 27 | std::unique_ptr<Delegate> delegate); |
Francois Beaufort | 51f9ee3 | 2019-11-05 06:48:16 | [diff] [blame] | 28 | |
| 29 | NfcPermissionContext(const NfcPermissionContext&) = delete; |
| 30 | NfcPermissionContext& operator=(const NfcPermissionContext&) = delete; |
| 31 | |
| 32 | ~NfcPermissionContext() override; |
| 33 | |
Michael van Ouwerkerk | 9783ec61 | 2021-03-29 11:51:51 | [diff] [blame] | 34 | protected: |
| 35 | std::unique_ptr<Delegate> delegate_; |
| 36 | |
Francois Beaufort | 51f9ee3 | 2019-11-05 06:48:16 | [diff] [blame] | 37 | private: |
| 38 | // PermissionContextBase: |
Xiaohan Wang | e81358230 | 2022-01-14 14:50:46 | [diff] [blame] | 39 | #if !BUILDFLAG(IS_ANDROID) |
Francois Beaufort | 51f9ee3 | 2019-11-05 06:48:16 | [diff] [blame] | 40 | ContentSetting GetPermissionStatusInternal( |
| 41 | content::RenderFrameHost* render_frame_host, |
| 42 | const GURL& requesting_origin, |
| 43 | const GURL& embedding_origin) const override; |
Francois Beaufort | dbb86fd | 2019-11-22 14:29:09 | [diff] [blame] | 44 | #endif |
Florian Jacky | 7f3e3ca1b | 2025-05-05 16:19:20 | [diff] [blame] | 45 | void DecidePermission(std::unique_ptr<PermissionRequestData> request_data, |
Michael van Ouwerkerk | c71455e | 2021-03-30 10:34:37 | [diff] [blame] | 46 | BrowserPermissionCallback callback) override; |
| 47 | void UpdateTabContext(const PermissionRequestID& id, |
Francois Beaufort | 51f9ee3 | 2019-11-05 06:48:16 | [diff] [blame] | 48 | const GURL& requesting_frame, |
| 49 | bool allowed) override; |
Francois Beaufort | 51f9ee3 | 2019-11-05 06:48:16 | [diff] [blame] | 50 | }; |
| 51 | |
Michael van Ouwerkerk | c71455e | 2021-03-30 10:34:37 | [diff] [blame] | 52 | } // namespace permissions |
| 53 | |
| 54 | #endif // COMPONENTS_PERMISSIONS_CONTEXTS_NFC_PERMISSION_CONTEXT_H_ |