page_info_delegate.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Copyright 2020 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. #ifndef COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_
  5. #define COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_
  6. #include <string>
  7. #include "build/build_config.h"
  8. #include "components/content_settings/browser/page_specific_content_settings.h"
  9. #include "components/content_settings/core/common/content_settings_types.h"
  10. #include "components/page_info/page_info.h"
  11. #include "components/permissions/permission_result.h"
  12. #include "components/permissions/permission_uma_util.h"
  13. #include "components/safe_browsing/buildflags.h"
  14. #include "components/safe_browsing/core/browser/password_protection/metrics_util.h"
  15. #include "components/security_state/core/security_state.h"
  16. namespace blink {
  17. enum class PermissionType;
  18. }
  19. namespace permissions {
  20. class ObjectPermissionContextBase;
  21. class PermissionDecisionAutoBlocker;
  22. } // namespace permissions
  23. namespace safe_browsing {
  24. class PasswordProtectionService;
  25. } // namespace safe_browsing
  26. namespace ui {
  27. class Event;
  28. } // namespace ui
  29. namespace url {
  30. class Origin;
  31. }
  32. class HostContentSettingsMap;
  33. class StatefulSSLHostStateDelegate;
  34. // PageInfoDelegate allows an embedder to customize PageInfo logic.
  35. class PageInfoDelegate {
  36. public:
  37. virtual ~PageInfoDelegate() = default;
  38. // Return the |ObjectPermissionContextBase| corresponding to the content
  39. // settings type, |type|. Returns a nullptr for content settings for which
  40. // there's no ObjectPermissionContextBase.
  41. virtual permissions::ObjectPermissionContextBase* GetChooserContext(
  42. ContentSettingsType type) = 0;
  43. #if BUILDFLAG(FULL_SAFE_BROWSING)
  44. // Helper methods requiring access to PasswordProtectionService.
  45. virtual safe_browsing::PasswordProtectionService*
  46. GetPasswordProtectionService() const = 0;
  47. virtual void OnUserActionOnPasswordUi(
  48. safe_browsing::WarningAction action) = 0;
  49. virtual std::u16string GetWarningDetailText() = 0;
  50. #endif
  51. // Get permission status for the permission associated with ContentSetting of
  52. // type |type|.
  53. virtual permissions::PermissionResult GetPermissionResult(
  54. blink::PermissionType permission,
  55. const url::Origin& origin) = 0;
  56. #if !BUILDFLAG(IS_ANDROID)
  57. // Creates an infobars::ContentInfoBarManager and an InfoBarDelegate using it,
  58. // if possible. Returns true if an InfoBarDelegate was created, false
  59. // otherwise.
  60. virtual bool CreateInfoBarDelegate() = 0;
  61. virtual void ShowSiteSettings(const GURL& site_url) = 0;
  62. virtual void ShowCookiesSettings() = 0;
  63. virtual void ShowAllSitesSettings() = 0;
  64. virtual void OpenCookiesDialog() = 0;
  65. virtual void OpenCertificateDialog(net::X509Certificate* certificate) = 0;
  66. virtual void OpenConnectionHelpCenterPage(const ui::Event& event) = 0;
  67. virtual void OpenSafetyTipHelpCenterPage() = 0;
  68. virtual void OpenContentSettingsExceptions(
  69. ContentSettingsType content_settings_type) = 0;
  70. virtual void OnPageInfoActionOccurred(PageInfo::PageInfoAction action) = 0;
  71. virtual void OnUIClosing() = 0;
  72. #endif
  73. virtual permissions::PermissionDecisionAutoBlocker*
  74. GetPermissionDecisionAutoblocker() = 0;
  75. // Service for managing SSL error page bypasses. Used to revoke bypass
  76. // decisions by users.
  77. virtual StatefulSSLHostStateDelegate* GetStatefulSSLHostStateDelegate() = 0;
  78. // The |HostContentSettingsMap| is the service that provides and manages
  79. // content settings (aka. site permissions).
  80. virtual HostContentSettingsMap* GetContentSettings() = 0;
  81. // The subresource filter service determines whether ads should be blocked on
  82. // the site and relevant permission prompts should be shown respectively.
  83. virtual bool IsSubresourceFilterActivated(const GURL& site_url) = 0;
  84. virtual std::unique_ptr<
  85. content_settings::PageSpecificContentSettings::Delegate>
  86. GetPageSpecificContentSettingsDelegate() = 0;
  87. virtual bool IsContentDisplayedInVrHeadset() = 0;
  88. virtual security_state::SecurityLevel GetSecurityLevel() = 0;
  89. virtual security_state::VisibleSecurityState GetVisibleSecurityState() = 0;
  90. #if BUILDFLAG(IS_ANDROID)
  91. // Gets the name of the embedder.
  92. virtual const std::u16string GetClientApplicationName() = 0;
  93. #endif
  94. };
  95. #endif // COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_