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