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 | |
Jan Wilken Dörrie | ad587c3 | 2021-03-11 14:09:27 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 10 | #include "build/build_config.h" |
Carlos Caballero | b428320 | 2020-08-10 14:40:46 | [diff] [blame] | 11 | #include "components/content_settings/browser/page_specific_content_settings.h" |
Mugdha Lakhani | 83baeab | 2020-03-20 13:08:23 | [diff] [blame] | 12 | #include "components/content_settings/core/common/content_settings_types.h" |
sauski | 9fb8882 | 2021-07-16 18:44:01 | [diff] [blame] | 13 | #include "components/page_info/page_info.h" |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 14 | #include "components/permissions/permission_result.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" |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 19 | |
Illia Klimov | 15550f75 | 2022-08-11 19:33:10 | [diff] [blame] | 20 | namespace blink { |
| 21 | enum class PermissionType; |
| 22 | } |
| 23 | |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 24 | namespace permissions { |
Ken Buchanan | 76365d1 | 2021-04-20 18:46:19 | [diff] [blame] | 25 | class ObjectPermissionContextBase; |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 26 | class PermissionDecisionAutoBlocker; |
| 27 | } // namespace permissions |
| 28 | |
Hans Wennborg | 3e67bab | 2021-04-08 11:34:31 | [diff] [blame] | 29 | namespace safe_browsing { |
| 30 | class PasswordProtectionService; |
| 31 | } // namespace safe_browsing |
| 32 | |
| 33 | namespace ui { |
| 34 | class Event; |
| 35 | } // namespace ui |
| 36 | |
Illia Klimov | 15550f75 | 2022-08-11 19:33:10 | [diff] [blame] | 37 | namespace url { |
| 38 | class Origin; |
| 39 | } |
| 40 | |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 41 | class HostContentSettingsMap; |
| 42 | class StatefulSSLHostStateDelegate; |
| 43 | |
| 44 | // PageInfoDelegate allows an embedder to customize PageInfo logic. |
Mugdha Lakhani | 83baeab | 2020-03-20 13:08:23 | [diff] [blame] | 45 | class PageInfoDelegate { |
| 46 | public: |
| 47 | virtual ~PageInfoDelegate() = default; |
| 48 | |
Ken Buchanan | 76365d1 | 2021-04-20 18:46:19 | [diff] [blame] | 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( |
Mugdha Lakhani | 1de9c49 | 2020-03-23 17:35:40 | [diff] [blame] | 53 | ContentSettingsType type) = 0; |
| 54 | |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 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( |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 60 | safe_browsing::WarningAction action) = 0; |
Jan Wilken Dörrie | fa241ba | 2021-03-11 17:57:01 | [diff] [blame] | 61 | virtual std::u16string GetWarningDetailText() = 0; |
Mugdha Lakhani | 09e02f62 | 2020-03-21 19:48:03 | [diff] [blame] | 62 | #endif |
| 63 | // Get permission status for the permission associated with ContentSetting of |
| 64 | // type |type|. |
Illia Klimov | 15550f75 | 2022-08-11 19:33:10 | [diff] [blame] | 65 | virtual permissions::PermissionResult GetPermissionResult( |
| 66 | blink::PermissionType permission, |
| 67 | const url::Origin& origin) = 0; |
Xiaohan Wang | d9e3b1f0 | 2022-01-14 14:48:35 | [diff] [blame] | 68 | #if !BUILDFLAG(IS_ANDROID) |
Zofia Salata | 08b4f90 | 2022-08-22 13:16:45 | [diff] [blame] | 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; |
Zofia Salata | a741975 | 2022-09-23 12:35:22 | [diff] [blame] | 72 | virtual bool IsFpsManaged() = 0; |
Zofia Salata | 08b4f90 | 2022-08-22 13:16:45 | [diff] [blame] | 73 | |
Colin Blundell | e70a6d8 | 2021-05-04 12:03:19 | [diff] [blame] | 74 | // Creates an infobars::ContentInfoBarManager and an InfoBarDelegate using it, |
| 75 | // if possible. Returns true if an InfoBarDelegate was created, false |
| 76 | // otherwise. |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 77 | virtual bool CreateInfoBarDelegate() = 0; |
| 78 | |
Zofia Salata | 47a06f1 | 2022-08-29 13:07:55 | [diff] [blame] | 79 | virtual std::unique_ptr<content_settings::CookieControlsController> |
| 80 | CreateCookieControlsController() = 0; |
Zelin Liu | 14035b5 | 2023-04-28 21:29:43 | [diff] [blame^] | 81 | |
| 82 | virtual bool IsIsolatedWebApp() = 0; |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 83 | virtual void ShowSiteSettings(const GURL& site_url) = 0; |
Zofia Salata | ea40da6d | 2022-08-03 07:37:58 | [diff] [blame] | 84 | virtual void ShowCookiesSettings() = 0; |
Zofia Salata | 9b3ff0a | 2022-09-05 09:30:47 | [diff] [blame] | 85 | virtual void ShowAllSitesSettingsFilteredByFpsOwner( |
| 86 | const std::u16string& fps_owner) = 0; |
Olesia Marukhno | 3ed46b4 | 2021-03-23 15:26:39 | [diff] [blame] | 87 | virtual void OpenCookiesDialog() = 0; |
| 88 | virtual void OpenCertificateDialog(net::X509Certificate* certificate) = 0; |
| 89 | virtual void OpenConnectionHelpCenterPage(const ui::Event& event) = 0; |
| 90 | virtual void OpenSafetyTipHelpCenterPage() = 0; |
Olesia Marukhno | 3acaef2 | 2021-06-25 10:26:22 | [diff] [blame] | 91 | virtual void OpenContentSettingsExceptions( |
| 92 | ContentSettingsType content_settings_type) = 0; |
sauski | 9fb8882 | 2021-07-16 18:44:01 | [diff] [blame] | 93 | virtual void OnPageInfoActionOccurred(PageInfo::PageInfoAction action) = 0; |
| 94 | virtual void OnUIClosing() = 0; |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 95 | #endif |
Zelin Liu | 14035b5 | 2023-04-28 21:29:43 | [diff] [blame^] | 96 | |
| 97 | virtual std::u16string GetSubjectName(const GURL& url) = 0; |
| 98 | |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 99 | virtual permissions::PermissionDecisionAutoBlocker* |
| 100 | GetPermissionDecisionAutoblocker() = 0; |
| 101 | |
| 102 | // Service for managing SSL error page bypasses. Used to revoke bypass |
| 103 | // decisions by users. |
| 104 | virtual StatefulSSLHostStateDelegate* GetStatefulSSLHostStateDelegate() = 0; |
| 105 | |
| 106 | // The |HostContentSettingsMap| is the service that provides and manages |
| 107 | // content settings (aka. site permissions). |
| 108 | virtual HostContentSettingsMap* GetContentSettings() = 0; |
| 109 | |
Justin Miron | ce1eb00a | 2020-08-20 15:57:38 | [diff] [blame] | 110 | // The subresource filter service determines whether ads should be blocked on |
| 111 | // the site and relevant permission prompts should be shown respectively. |
| 112 | virtual bool IsSubresourceFilterActivated(const GURL& site_url) = 0; |
| 113 | |
Mugdha Lakhani | 3c22480d4 | 2020-04-24 12:43:42 | [diff] [blame] | 114 | virtual std::unique_ptr< |
Carlos Caballero | b428320 | 2020-08-10 14:40:46 | [diff] [blame] | 115 | content_settings::PageSpecificContentSettings::Delegate> |
| 116 | GetPageSpecificContentSettingsDelegate() = 0; |
Mugdha Lakhani | 00b27a0 | 2020-03-24 13:41:31 | [diff] [blame] | 117 | virtual bool IsContentDisplayedInVrHeadset() = 0; |
Mugdha Lakhani | 65bd7e5 | 2020-03-31 19:26:16 | [diff] [blame] | 118 | virtual security_state::SecurityLevel GetSecurityLevel() = 0; |
| 119 | virtual security_state::VisibleSecurityState GetVisibleSecurityState() = 0; |
Xiaohan Wang | d9e3b1f0 | 2022-01-14 14:48:35 | [diff] [blame] | 120 | #if BUILDFLAG(IS_ANDROID) |
Mugdha Lakhani | 2c21fc66 | 2020-05-06 15:33:12 | [diff] [blame] | 121 | // Gets the name of the embedder. |
Jan Wilken Dörrie | fa241ba | 2021-03-11 17:57:01 | [diff] [blame] | 122 | virtual const std::u16string GetClientApplicationName() = 0; |
Mugdha Lakhani | 2c21fc66 | 2020-05-06 15:33:12 | [diff] [blame] | 123 | #endif |
Mugdha Lakhani | 83baeab | 2020-03-20 13:08:23 | [diff] [blame] | 124 | }; |
| 125 | |
Mugdha Lakhani | b676216 | 2020-03-30 10:23:25 | [diff] [blame] | 126 | #endif // COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ |