chromium/components/page_info/page_info.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/page_info/page_info.h"

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/feature_list.h"
#include "base/i18n/time_formatting.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/browsing_data/content/browsing_data_helper.h"
#include "components/content_settings/browser/ui/cookie_controls_controller.h"
#include "components/content_settings/core/browser/content_settings_registry.h"
#include "components/content_settings/core/browser/content_settings_uma_util.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_constraints.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/content_settings/core/common/features.h"
#include "components/page_info/page_info_delegate.h"
#include "components/page_info/page_info_ui.h"
#include "components/permissions/constants.h"
#include "components/permissions/features.h"
#include "components/permissions/object_permission_context_base.h"
#include "components/permissions/origin_keyed_permission_action_service.h"
#include "components/permissions/permission_decision_auto_blocker.h"
#include "components/permissions/permission_manager.h"
#include "components/permissions/permission_recovery_success_rate_tracker.h"
#include "components/permissions/permission_request_manager.h"
#include "components/permissions/permission_uma_util.h"
#include "components/permissions/permission_util.h"
#include "components/permissions/permissions_client.h"
#include "components/permissions/request_type.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "components/security_interstitials/content/stateful_ssl_host_state_delegate.h"
#include "components/ssl_errors/error_info.h"
#include "components/strings/grit/components_strings.h"
#include "components/subresource_filter/core/browser/subresource_filter_features.h"
#include "components/url_formatter/elide_url.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/common/content_features.h"
#include "content/public/common/url_constants.h"
#include "net/base/schemeful_site.h"
#include "net/cert/cert_status_flags.h"
#include "net/cert/x509_certificate.h"
#include "net/ssl/ssl_cipher_suite_names.h"
#include "net/ssl/ssl_connection_status_flags.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/boringssl/src/include/openssl/ssl.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/origin.h"

#if BUILDFLAG(IS_ANDROID)
#include "components/browser_ui/util/android/url_constants.h"
#include "components/resources/android/theme_resources.h"
#include "components/strings/grit/components_branded_strings.h"
#else
#include "third_party/blink/public/common/features.h"
#endif  // BUILDFLAG(IS_ANDROID)

#if BUILDFLAG(FULL_SAFE_BROWSING)
#include "components/safe_browsing/content/browser/password_protection/password_protection_service.h"
#include "components/safe_browsing/core/browser/password_protection/metrics_util.h"
#endif  // BUILDFLAG(FULL_SAFE_BROWSING)

ASCIIToUTF16;
UTF16ToUTF8;
UTF8ToUTF16;
BrowserThread;
LoginReputationClientResponse;
RequestOutcome;

namespace {

// The list of content settings types to display on the Page Info UI. THE
// ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To
// propose changing it, email [email protected].
ContentSettingsType kPermissionType[] =;

// The list of setting types which request permission for a pair of requesting
// origin and top-level-origin that need to display entries in the Website
// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
// email [email protected].
ContentSettingsType kTwoPatternPermissions[] =;

// If the |visible_security_state| indicates that mixed content or certificate
// errors were present, update |connection_status| and |connection_details|.
void ReportAnyInsecureContent(
    const security_state::VisibleSecurityState& visible_security_state,
    PageInfo::SiteConnectionStatus* connection_status,
    std::u16string* connection_details) {}

// The list of chooser types that need to display entries in the Website
// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
// email [email protected].
const PageInfo::ChooserUIInfo kChooserUIInfo[] =;

void LogTimeOpenHistogram(const std::string& name, base::TimeTicks start_time) {}

// Time open histogram prefixes.
const char kPageInfoTimePrefix[] =;
const char kPageInfoTimeActionPrefix[] =;
const char kPageInfoTimeNoActionPrefix[] =;
const base::TimeDelta kRecordPageInfoPermissionChangeWindow =;
}  // namespace

PermissionInfo;
PermissionInfo::PermissionInfo() = default;
PermissionInfo::PermissionInfo(const PermissionInfo& other) = default;
PermissionInfo& PermissionInfo::operator=(const PermissionInfo& other) =
    default;
PermissionInfo::~PermissionInfo() = default;

PageInfo::PageInfo(std::unique_ptr<PageInfoDelegate> delegate,
                   content::WebContents* web_contents,
                   const GURL& url)
    :{}

PageInfo::~PageInfo() {}

void PageInfo::OnStatusChanged(
    bool controls_visible,
    bool protections_on,
    CookieControlsEnforcement enforcement,
    CookieBlocking3pcdStatus blocking_status,
    base::Time expiration,
    std::vector<content_settings::TrackingProtectionFeature> features) {}

void PageInfo::OnThirdPartyToggleClicked(bool block_third_party_cookies) {}

// static
bool PageInfo::IsPermissionFactoryDefault(const PermissionInfo& info,
                                          bool is_incognito) {}

// static
bool PageInfo::IsFileOrInternalPage(const GURL& url) {}

void PageInfo::InitializeUiState(PageInfoUI* ui, base::OnceClosure done) {}

void PageInfo::UpdateSecurityState() {}

void PageInfo::RecordPageInfoAction(page_info::PageInfoAction action) {}

void PageInfo::UpdatePermissions() {}

void PageInfo::OnSitePermissionChanged(
    ContentSettingsType type,
    ContentSetting setting,
    std::optional<url::Origin> requesting_origin,
    bool is_one_time) {}

void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
                                         const base::Value& object) {}

void PageInfo::OnUIClosing(bool* reload_prompt) {}

void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {}

void PageInfo::OnPermissionUsageChange() {}

void PageInfo::OpenSiteSettingsView() {}

void PageInfo::OpenCookiesSettingsView() {}

void PageInfo::OpenAllSitesViewFilteredToRws() {}

void PageInfo::OpenCookiesDialog() {}

void PageInfo::OpenCertificateDialog(net::X509Certificate* certificate) {}

void PageInfo::OpenSafetyTipHelpCenterPage() {}

void PageInfo::OpenConnectionHelpCenterPage(const ui::Event& event) {}

void PageInfo::OpenContentSettingsExceptions(
    ContentSettingsType content_settings_type) {}

void PageInfo::OnChangePasswordButtonPressed() {}

void PageInfo::OnAllowlistPasswordReuseButtonPressed() {}

void PageInfo::OnCookiesPageOpened() {}

permissions::ObjectPermissionContextBase* PageInfo::GetChooserContextFromUIInfo(
    const ChooserUIInfo& ui_info) const {}

std::u16string PageInfo::GetSubjectNameForDisplay() const {}

void PageInfo::ComputeUIInputs(const GURL& url) {}

void PageInfo::PopulatePermissionInfo(PermissionInfo& permission_info,
                                      HostContentSettingsMap* content_settings,
                                      const content_settings::SettingInfo& info,
                                      ContentSetting setting) const {}

// Determines whether to show permission |type| in the Page Info UI. Only
// applies to permissions listed in |kPermissionType|.
bool PageInfo::ShouldShowPermission(
    const PageInfo::PermissionInfo& info) const {}

void PageInfo::PresentSitePermissions() {}

std::set<net::SchemefulSite> PageInfo::GetTwoSitePermissionRequesters(
    ContentSettingsType type) {}

void PageInfo::PresentSiteDataInternal(base::OnceClosure done) {}

void PageInfo::PresentSiteData(base::OnceClosure done) {}

void PageInfo::PresentSiteIdentity() {}

void PageInfo::PresentPageFeatureInfo() {}

void PageInfo::PresentAdPersonalizationData() {}

#if BUILDFLAG(FULL_SAFE_BROWSING)
void PageInfo::RecordPasswordReuseEvent() {}
#endif

HostContentSettingsMap* PageInfo::GetContentSettings() const {}

std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() {}

void PageInfo::SetSiteNameForTesting(const std::u16string& site_name) {}

void PageInfo::GetSafeBrowsingStatusByMaliciousContentStatus(
    security_state::MaliciousContentStatus malicious_content_status,
    PageInfo::SafeBrowsingStatus* status,
    std::u16string* details) {}

content_settings::PageSpecificContentSettings*
PageInfo::GetPageSpecificContentSettings() const {}

bool PageInfo::HasContentSettingChangedViaPageInfo(
    ContentSettingsType type) const {}

void PageInfo::ContentSettingChangedViaPageInfo(ContentSettingsType type) {}

int PageInfo::GetSitesWithAllowedCookiesAccessCount() {}

int PageInfo::GetThirdPartySitesWithBlockedCookiesAccessCount(
    const GURL& site_url) {}

bool PageInfo::IsIsolatedWebApp() const {}