blob: 8c52b53d9154e910da17f850eaa6faf7fd71202e [file] [log] [blame]
Francois Beaufort51f9ee32019-11-05 06:48:161// 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
Michael van Ouwerkerkc71455e2021-03-30 10:34:375#ifndef COMPONENTS_PERMISSIONS_CONTEXTS_NFC_PERMISSION_CONTEXT_H_
6#define COMPONENTS_PERMISSIONS_CONTEXTS_NFC_PERMISSION_CONTEXT_H_
Francois Beaufort51f9ee32019-11-05 06:48:167
Michael van Ouwerkerk9783ec612021-03-29 11:51:518#include "build/build_config.h"
Clark DuValla11361ad32020-02-20 22:14:279#include "components/permissions/permission_context_base.h"
Francois Beaufort51f9ee32019-11-05 06:48:1610
Michael van Ouwerkerkc71455e2021-03-30 10:34:3711namespace permissions {
12
13class NfcPermissionContext : public PermissionContextBase {
Francois Beaufort51f9ee32019-11-05 06:48:1614 public:
Michael van Ouwerkerk9783ec612021-03-29 11:51:5115 // The delegate allows embedders to modify the permission context logic.
16 class Delegate {
17 public:
18 virtual ~Delegate() = default;
19
Xiaohan Wange813582302022-01-14 14:50:4620#if BUILDFLAG(IS_ANDROID)
Michael van Ouwerkerk9783ec612021-03-29 11:51:5121 // 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 Beaufort51f9ee32019-11-05 06:48:1628
29 NfcPermissionContext(const NfcPermissionContext&) = delete;
30 NfcPermissionContext& operator=(const NfcPermissionContext&) = delete;
31
32 ~NfcPermissionContext() override;
33
Michael van Ouwerkerk9783ec612021-03-29 11:51:5134 protected:
35 std::unique_ptr<Delegate> delegate_;
36
Francois Beaufort51f9ee32019-11-05 06:48:1637 private:
38 // PermissionContextBase:
Xiaohan Wange813582302022-01-14 14:50:4639#if !BUILDFLAG(IS_ANDROID)
Francois Beaufort51f9ee32019-11-05 06:48:1640 ContentSetting GetPermissionStatusInternal(
41 content::RenderFrameHost* render_frame_host,
42 const GURL& requesting_origin,
43 const GURL& embedding_origin) const override;
Francois Beaufortdbb86fd2019-11-22 14:29:0944#endif
Michael van Ouwerkerkc71455e2021-03-30 10:34:3745 void DecidePermission(content::WebContents* web_contents,
46 const PermissionRequestID& id,
47 const GURL& requesting_origin,
48 const GURL& embedding_origin,
49 bool user_gesture,
50 BrowserPermissionCallback callback) override;
51 void UpdateTabContext(const PermissionRequestID& id,
Francois Beaufort51f9ee32019-11-05 06:48:1652 const GURL& requesting_frame,
53 bool allowed) override;
54 bool IsRestrictedToSecureOrigins() const override;
55};
56
Michael van Ouwerkerkc71455e2021-03-30 10:34:3757} // namespace permissions
58
59#endif // COMPONENTS_PERMISSIONS_CONTEXTS_NFC_PERMISSION_CONTEXT_H_