Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
Mugdha Lakhani | 83baeab | 2020-03-20 13:08:23 | [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 | |
Mugdha Lakhani | b676216 | 2020-03-30 10:23:25 | [diff] [blame] | 5 | #ifndef COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ |
| 6 | #define COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ |
Mugdha Lakhani | 83baeab | 2020-03-20 13:08:23 | [diff] [blame] | 7 | |
Arthur Sonzogni | c571efb | 2024-01-26 20:26:18 | [diff] [blame] | 8 | #include <optional> |
Jan Wilken Dörrie | ad587c3 | 2021-03-11 14:09:27 | [diff] [blame] | 9 | #include <string> |
| 10 | |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 11 | #include "build/build_config.h" |
Carlos Caballero | b428320 | 2020-08-10 14:40:46 | [diff] [blame] | 12 | #include "components/content_settings/browser/page_specific_content_settings.h" |
Mugdha Lakhani | 83baeab | 2020-03-20 13:08:23 | [diff] [blame] | 13 | #include "components/content_settings/core/common/content_settings_types.h" |
sauski | 9fb8882 | 2021-07-16 18:44:01 | [diff] [blame] | 14 | #include "components/page_info/page_info.h" |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 15 | #include "components/permissions/permission_uma_util.h" |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 16 | #include "components/safe_browsing/buildflags.h" |
Colin Blundell | 51fe564 | 2021-06-25 11:58:37 | [diff] [blame] | 17 | #include "components/safe_browsing/core/browser/password_protection/metrics_util.h" |
Mugdha Lakhani | 65bd7e5 | 2020-03-31 19:26:16 | [diff] [blame] | 18 | #include "components/security_state/core/security_state.h" |
Illia Klimov | 2c6138b | 2023-08-14 09:39:25 | [diff] [blame] | 19 | #include "content/public/browser/permission_result.h" |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 20 | |
Illia Klimov | 15550f75 | 2022-08-11 19:33:10 | [diff] [blame] | 21 | namespace blink { |
| 22 | enum class PermissionType; |
| 23 | } |
| 24 | |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 25 | namespace permissions { |
Ken Buchanan | 76365d1 | 2021-04-20 18:46:19 | [diff] [blame] | 26 | class ObjectPermissionContextBase; |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 27 | class PermissionDecisionAutoBlocker; |
| 28 | } // namespace permissions |
| 29 | |
Hans Wennborg | 3e67bab | 2021-04-08 11:34:31 | [diff] [blame] | 30 | namespace safe_browsing { |
| 31 | class PasswordProtectionService; |
| 32 | } // namespace safe_browsing |
| 33 | |
| 34 | namespace ui { |
| 35 | class Event; |
| 36 | } // namespace ui |
| 37 | |
Illia Klimov | 15550f75 | 2022-08-11 19:33:10 | [diff] [blame] | 38 | namespace url { |
| 39 | class Origin; |
| 40 | } |
| 41 | |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 42 | class HostContentSettingsMap; |
| 43 | class StatefulSSLHostStateDelegate; |
| 44 | |
| 45 | // PageInfoDelegate allows an embedder to customize PageInfo logic. |
Mugdha Lakhani | 83baeab | 2020-03-20 13:08:23 | [diff] [blame] | 46 | class PageInfoDelegate { |
| 47 | public: |
| 48 | virtual ~PageInfoDelegate() = default; |
| 49 | |
Ken Buchanan | 76365d1 | 2021-04-20 18:46:19 | [diff] [blame] | 50 | // Return the |ObjectPermissionContextBase| corresponding to the content |
| 51 | // settings type, |type|. Returns a nullptr for content settings for which |
| 52 | // there's no ObjectPermissionContextBase. |
| 53 | virtual permissions::ObjectPermissionContextBase* GetChooserContext( |
Mugdha Lakhani | 1de9c49 | 2020-03-23 17:35:40 | [diff] [blame] | 54 | ContentSettingsType type) = 0; |
| 55 | |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 56 | #if BUILDFLAG(FULL_SAFE_BROWSING) |
| 57 | // Helper methods requiring access to PasswordProtectionService. |
| 58 | virtual safe_browsing::PasswordProtectionService* |
| 59 | GetPasswordProtectionService() const = 0; |
| 60 | virtual void OnUserActionOnPasswordUi( |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 61 | safe_browsing::WarningAction action) = 0; |
Jan Wilken Dörrie | fa241ba | 2021-03-11 17:57:01 | [diff] [blame] | 62 | virtual std::u16string GetWarningDetailText() = 0; |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 63 | #endif |
| 64 | // Get permission status for the permission associated with ContentSetting of |
| 65 | // type |type|. |
Illia Klimov | 2c6138b | 2023-08-14 09:39:25 | [diff] [blame] | 66 | virtual content::PermissionResult GetPermissionResult( |
Illia Klimov | 15550f75 | 2022-08-11 19:33:10 | [diff] [blame] | 67 | blink::PermissionType permission, |
Christian Dullweber | a475f4a | 2023-08-07 17:04:13 | [diff] [blame] | 68 | const url::Origin& origin, |
Arthur Sonzogni | c571efb | 2024-01-26 20:26:18 | [diff] [blame] | 69 | const std::optional<url::Origin>& requesting_origin) = 0; |
Xiaohan Wang | d9e3b1f0 | 2022-01-14 14:48:35 | [diff] [blame] | 70 | #if !BUILDFLAG(IS_ANDROID) |
Arthur Sonzogni | c571efb | 2024-01-26 20:26:18 | [diff] [blame] | 71 | // Returns std::nullopt if `site_url` is not recognised as a member of any |
Kene Okoye | 4f4f9b1 | 2024-08-14 18:36:37 | [diff] [blame] | 72 | // RWS or if RWS functionality is not allowed . |
| 73 | virtual std::optional<std::u16string> GetRwsOwner(const GURL& site_url) = 0; |
Fiona Macintosh | f945830 | 2025-03-20 12:51:10 | [diff] [blame] | 74 | virtual bool IsRwsManaged(const GURL& site_url) = 0; |
Zofia Salata | 08b4f90 | 2022-08-22 13:16:45 | [diff] [blame] | 75 | |
Colin Blundell | e70a6d8 | 2021-05-04 12:03:19 | [diff] [blame] | 76 | // Creates an infobars::ContentInfoBarManager and an InfoBarDelegate using it, |
| 77 | // if possible. Returns true if an InfoBarDelegate was created, false |
| 78 | // otherwise. |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 79 | virtual bool CreateInfoBarDelegate() = 0; |
| 80 | |
Zofia Salata | 47a06f1 | 2022-08-29 13:07:55 | [diff] [blame] | 81 | virtual std::unique_ptr<content_settings::CookieControlsController> |
| 82 | CreateCookieControlsController() = 0; |
Zelin Liu | 14035b5 | 2023-04-28 21:29:43 | [diff] [blame] | 83 | |
| 84 | virtual bool IsIsolatedWebApp() = 0; |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 85 | virtual void ShowSiteSettings(const GURL& site_url) = 0; |
Zofia Salata | ea40da6d | 2022-08-03 07:37:58 | [diff] [blame] | 86 | virtual void ShowCookiesSettings() = 0; |
Michelle Abreo | a74527a | 2025-05-15 19:57:46 | [diff] [blame] | 87 | virtual void ShowIncognitoSettings() = 0; |
Kene Okoye | 4f4f9b1 | 2024-08-14 18:36:37 | [diff] [blame] | 88 | virtual void ShowAllSitesSettingsFilteredByRwsOwner( |
Fiona Macintosh | 3823305 | 2024-10-08 08:43:42 | [diff] [blame] | 89 | const std::u16string& rws_owner) = 0; |
Andrey Davydov | 3c7ed199 | 2025-04-11 14:35:47 | [diff] [blame] | 90 | virtual void ShowSyncSettings() = 0; |
Olesia Marukhno | 3ed46b4 | 2021-03-23 15:26:39 | [diff] [blame] | 91 | virtual void OpenCookiesDialog() = 0; |
| 92 | virtual void OpenCertificateDialog(net::X509Certificate* certificate) = 0; |
| 93 | virtual void OpenConnectionHelpCenterPage(const ui::Event& event) = 0; |
| 94 | virtual void OpenSafetyTipHelpCenterPage() = 0; |
Daniel Rubery | ed44675 | 2024-10-24 16:22:34 | [diff] [blame] | 95 | virtual void OpenSafeBrowsingHelpCenterPage(const ui::Event& event) = 0; |
Olesia Marukhno | 3acaef2 | 2021-06-25 10:26:22 | [diff] [blame] | 96 | virtual void OpenContentSettingsExceptions( |
| 97 | ContentSettingsType content_settings_type) = 0; |
Filipa Senra | 8d423055 | 2024-02-21 15:42:56 | [diff] [blame] | 98 | virtual void OnPageInfoActionOccurred(page_info::PageInfoAction action) = 0; |
sauski | 9fb8882 | 2021-07-16 18:44:01 | [diff] [blame] | 99 | virtual void OnUIClosing() = 0; |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 100 | #endif |
Zelin Liu | 14035b5 | 2023-04-28 21:29:43 | [diff] [blame] | 101 | |
| 102 | virtual std::u16string GetSubjectName(const GURL& url) = 0; |
| 103 | |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 104 | virtual permissions::PermissionDecisionAutoBlocker* |
| 105 | GetPermissionDecisionAutoblocker() = 0; |
| 106 | |
| 107 | // Service for managing SSL error page bypasses. Used to revoke bypass |
| 108 | // decisions by users. |
| 109 | virtual StatefulSSLHostStateDelegate* GetStatefulSSLHostStateDelegate() = 0; |
| 110 | |
| 111 | // The |HostContentSettingsMap| is the service that provides and manages |
| 112 | // content settings (aka. site permissions). |
| 113 | virtual HostContentSettingsMap* GetContentSettings() = 0; |
| 114 | |
Justin Miron | ce1eb00a | 2020-08-20 15:57:38 | [diff] [blame] | 115 | // The subresource filter service determines whether ads should be blocked on |
| 116 | // the site and relevant permission prompts should be shown respectively. |
| 117 | virtual bool IsSubresourceFilterActivated(const GURL& site_url) = 0; |
| 118 | |
Tommy Steimel | d63e3ca5 | 2023-08-22 13:23:11 | [diff] [blame] | 119 | // True if the site has registered for auto picture-in-picture. |
| 120 | virtual bool HasAutoPictureInPictureBeenRegistered() = 0; |
| 121 | |
Mugdha Lakhani | 3c22480d4 | 2020-04-24 12:43:42 | [diff] [blame] | 122 | virtual std::unique_ptr< |
Carlos Caballero | b428320 | 2020-08-10 14:40:46 | [diff] [blame] | 123 | content_settings::PageSpecificContentSettings::Delegate> |
| 124 | GetPageSpecificContentSettingsDelegate() = 0; |
Alvin Lam | 3264839 | 2023-09-28 10:07:58 | [diff] [blame] | 125 | |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 126 | virtual bool IsContentDisplayedInVrHeadset() = 0; |
Mugdha Lakhani | 65bd7e5 | 2020-03-31 19:26:16 | [diff] [blame] | 127 | virtual security_state::SecurityLevel GetSecurityLevel() = 0; |
| 128 | virtual security_state::VisibleSecurityState GetVisibleSecurityState() = 0; |
Theodore Olsauskas-Warren | 131d53e | 2023-05-17 15:08:02 | [diff] [blame] | 129 | virtual void OnCookiesPageOpened() = 0; |
Xiaohan Wang | d9e3b1f0 | 2022-01-14 14:48:35 | [diff] [blame] | 130 | #if BUILDFLAG(IS_ANDROID) |
Mugdha Lakhani | 2c21fc66 | 2020-05-06 15:33:12 | [diff] [blame] | 131 | // Gets the name of the embedder. |
Jan Wilken Dörrie | fa241ba | 2021-03-11 17:57:01 | [diff] [blame] | 132 | virtual const std::u16string GetClientApplicationName() = 0; |
Mugdha Lakhani | 2c21fc66 | 2020-05-06 15:33:12 | [diff] [blame] | 133 | #endif |
Chris Thompson | d742cd9 | 2023-05-23 22:18:01 | [diff] [blame] | 134 | virtual bool IsHttpsFirstModeEnabled() = 0; |
Maggie Jennings | 3d9296f8 | 2024-11-11 18:29:29 | [diff] [blame] | 135 | virtual bool IsIncognitoProfile() = 0; |
Mugdha Lakhani | 83baeab | 2020-03-20 13:08:23 | [diff] [blame] | 136 | }; |
| 137 | |
Mugdha Lakhani | b676216 | 2020-03-30 10:23:25 | [diff] [blame] | 138 | #endif // COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ |