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 5 #ifndef COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ 6 #define COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ 7 8 #include "base/strings/string16.h" 9 #include "build/build_config.h" 10 #include "components/content_settings/core/common/content_settings_types.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/content/password_protection/metrics_util.h" 15 #include "components/security_state/core/security_state.h" 16 17 namespace safe_browsing { 18 class PasswordProtectionService; 19 } // namespace safe_browsing 20 21 namespace permissions { 22 class PermissionDecisionAutoBlocker; 23 } // namespace permissions 24 25 namespace permissions { 26 class ChooserContextBase; 27 } 28 29 class HostContentSettingsMap; 30 class StatefulSSLHostStateDelegate; 31 32 // PageInfoDelegate allows an embedder to customize PageInfo logic. 33 class PageInfoDelegate { 34 public: 35 virtual ~PageInfoDelegate() = default; 36 37 // Return the |ChooserContextBase| corresponding to the content settings 38 // type, |type|. Returns a nullptr for content settings for which there's no 39 // ChooserContextBase. 40 virtual permissions::ChooserContextBase* GetChooserContext( 41 ContentSettingsType type) = 0; 42 43 // Whether the content setting of type |type| has changed via Page Info UI. 44 virtual bool HasContentSettingChangedViaPageInfo( 45 ContentSettingsType type) = 0; 46 47 // Notifies the delegate that the content setting of type |type| has changed 48 // via Page Info UI. 49 virtual void ContentSettingChangedViaPageInfo(ContentSettingsType type) = 0; 50 51 // Get counts of allowed and blocked cookies. 52 virtual int GetFirstPartyAllowedCookiesCount(const GURL& site_url) = 0; 53 virtual int GetFirstPartyBlockedCookiesCount(const GURL& site_url) = 0; 54 virtual int GetThirdPartyAllowedCookiesCount(const GURL& site_url) = 0; 55 virtual int GetThirdPartyBlockedCookiesCount(const GURL& site_url) = 0; 56 57 #if BUILDFLAG(FULL_SAFE_BROWSING) 58 // Helper methods requiring access to PasswordProtectionService. 59 virtual safe_browsing::PasswordProtectionService* 60 GetPasswordProtectionService() const = 0; 61 virtual void OnUserActionOnPasswordUi( 62 content::WebContents* web_contents, 63 safe_browsing::WarningAction action) = 0; 64 virtual base::string16 GetWarningDetailText() = 0; 65 #endif 66 // Get permission status for the permission associated with ContentSetting of 67 // type |type|. 68 virtual permissions::PermissionResult GetPermissionStatus( 69 ContentSettingsType type, 70 const GURL& site_url) = 0; 71 #if !defined(OS_ANDROID) 72 // Creates an InfoBarService and an InfoBarDelegate using it, if possible. 73 // Returns true if an InfoBarDelegate was created, false otherwise. 74 virtual bool CreateInfoBarDelegate() = 0; 75 76 virtual void ShowSiteSettings(const GURL& site_url) = 0; 77 #endif 78 virtual permissions::PermissionDecisionAutoBlocker* 79 GetPermissionDecisionAutoblocker() = 0; 80 81 // Service for managing SSL error page bypasses. Used to revoke bypass 82 // decisions by users. 83 virtual StatefulSSLHostStateDelegate* GetStatefulSSLHostStateDelegate() = 0; 84 85 // The |HostContentSettingsMap| is the service that provides and manages 86 // content settings (aka. site permissions). 87 virtual HostContentSettingsMap* GetContentSettings() = 0; 88 89 virtual bool IsContentDisplayedInVrHeadset() = 0; 90 virtual security_state::SecurityLevel GetSecurityLevel() = 0; 91 virtual security_state::VisibleSecurityState GetVisibleSecurityState() = 0; 92 }; 93 94 #endif // COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ 95