Upload upstream chromium 108.0.5359.1
[platform/framework/web/chromium-efl.git] / components / page_info / page_info_delegate.h
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_
6 #define COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_
7
8 #include <string>
9
10 #include "build/build_config.h"
11 #include "components/content_settings/browser/page_specific_content_settings.h"
12 #include "components/content_settings/core/common/content_settings_types.h"
13 #include "components/page_info/page_info.h"
14 #include "components/permissions/permission_result.h"
15 #include "components/permissions/permission_uma_util.h"
16 #include "components/safe_browsing/buildflags.h"
17 #include "components/safe_browsing/core/browser/password_protection/metrics_util.h"
18 #include "components/security_state/core/security_state.h"
19
20 namespace blink {
21 enum class PermissionType;
22 }
23
24 namespace permissions {
25 class ObjectPermissionContextBase;
26 class PermissionDecisionAutoBlocker;
27 }  // namespace permissions
28
29 namespace safe_browsing {
30 class PasswordProtectionService;
31 }  // namespace safe_browsing
32
33 namespace ui {
34 class Event;
35 }  // namespace ui
36
37 namespace url {
38 class Origin;
39 }
40
41 class HostContentSettingsMap;
42 class StatefulSSLHostStateDelegate;
43
44 // PageInfoDelegate allows an embedder to customize PageInfo logic.
45 class PageInfoDelegate {
46  public:
47   virtual ~PageInfoDelegate() = default;
48
49   // Return the |ObjectPermissionContextBase| corresponding to the content
50   // settings type, |type|. Returns a nullptr for content settings for which
51   // there's no ObjectPermissionContextBase.
52   virtual permissions::ObjectPermissionContextBase* GetChooserContext(
53       ContentSettingsType type) = 0;
54
55 #if BUILDFLAG(FULL_SAFE_BROWSING)
56   // Helper methods requiring access to PasswordProtectionService.
57   virtual safe_browsing::PasswordProtectionService*
58   GetPasswordProtectionService() const = 0;
59   virtual void OnUserActionOnPasswordUi(
60       safe_browsing::WarningAction action) = 0;
61   virtual std::u16string GetWarningDetailText() = 0;
62 #endif
63   // Get permission status for the permission associated with ContentSetting of
64   // type |type|.
65   virtual permissions::PermissionResult GetPermissionResult(
66       blink::PermissionType permission,
67       const url::Origin& origin) = 0;
68 #if !BUILDFLAG(IS_ANDROID)
69   // Returns absl::nullopt if `site_url` is not recognised as a member of any
70   // FPS or if FPS functionality is not allowed .
71   virtual absl::optional<std::u16string> GetFpsOwner(const GURL& site_url) = 0;
72   virtual bool IsFpsManaged() = 0;
73
74   // Creates an infobars::ContentInfoBarManager and an InfoBarDelegate using it,
75   // if possible. Returns true if an InfoBarDelegate was created, false
76   // otherwise.
77   virtual bool CreateInfoBarDelegate() = 0;
78
79   virtual std::unique_ptr<content_settings::CookieControlsController>
80   CreateCookieControlsController() = 0;
81   virtual std::u16string GetWebAppShortName() = 0;
82   virtual void ShowSiteSettings(const GURL& site_url) = 0;
83   virtual void ShowCookiesSettings() = 0;
84   virtual void ShowAllSitesSettingsFilteredByFpsOwner(
85       const std::u16string& fps_owner) = 0;
86   virtual void OpenCookiesDialog() = 0;
87   virtual void OpenCertificateDialog(net::X509Certificate* certificate) = 0;
88   virtual void OpenConnectionHelpCenterPage(const ui::Event& event) = 0;
89   virtual void OpenSafetyTipHelpCenterPage() = 0;
90   virtual void OpenContentSettingsExceptions(
91       ContentSettingsType content_settings_type) = 0;
92   virtual void OnPageInfoActionOccurred(PageInfo::PageInfoAction action) = 0;
93   virtual void OnUIClosing() = 0;
94 #endif
95   virtual permissions::PermissionDecisionAutoBlocker*
96   GetPermissionDecisionAutoblocker() = 0;
97
98   // Service for managing SSL error page bypasses. Used to revoke bypass
99   // decisions by users.
100   virtual StatefulSSLHostStateDelegate* GetStatefulSSLHostStateDelegate() = 0;
101
102   // The |HostContentSettingsMap| is the service that provides and manages
103   // content settings (aka. site permissions).
104   virtual HostContentSettingsMap* GetContentSettings() = 0;
105
106   // The subresource filter service determines whether ads should be blocked on
107   // the site and relevant permission prompts should be shown respectively.
108   virtual bool IsSubresourceFilterActivated(const GURL& site_url) = 0;
109
110   virtual std::unique_ptr<
111       content_settings::PageSpecificContentSettings::Delegate>
112   GetPageSpecificContentSettingsDelegate() = 0;
113   virtual bool IsContentDisplayedInVrHeadset() = 0;
114   virtual security_state::SecurityLevel GetSecurityLevel() = 0;
115   virtual security_state::VisibleSecurityState GetVisibleSecurityState() = 0;
116 #if BUILDFLAG(IS_ANDROID)
117   // Gets the name of the embedder.
118   virtual const std::u16string GetClientApplicationName() = 0;
119 #endif
120 };
121
122 #endif  // COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_