chromium/components/safe_browsing/content/browser/password_protection/password_protection_request_content.cc

// Copyright 2021 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/safe_browsing/content/browser/password_protection/password_protection_request_content.h"

#include "base/functional/callback.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "components/safe_browsing/content/browser/client_side_detection_feature_cache.h"
#include "components/safe_browsing/content/browser/password_protection/password_protection_commit_deferring_condition.h"
#include "components/safe_browsing/content/browser/password_protection/password_protection_service.h"
#include "components/safe_browsing/content/browser/web_ui/safe_browsing_ui.h"
#include "components/safe_browsing/core/browser/password_protection/request_canceler.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "url/gurl.h"

#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
#include "components/safe_browsing/content/common/visual_utils.h"
#include "components/zoom/zoom_controller.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/base/proto_wrapper.h"
#endif  // BUILDFLAG(SAFE_BROWSING_AVAILABLE)

#if BUILDFLAG(IS_ANDROID)
#include "ui/android/view_android.h"
#endif

namespace safe_browsing {

namespace {

#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
// The maximum time to wait for DOM features to be collected, in milliseconds.
const int kDomFeatureTimeoutMs =;

void ExtractVisualFeaturesAndReplyOnUIThread(
    const SkBitmap& bitmap,
    base::OnceCallback<void(std::unique_ptr<VisualFeatures>)>
        ui_thread_callback) {}
#endif  // BUILDFLAG(SAFE_BROWSING_AVAILABLE)

void LogCSDCacheContainsImages(bool contains_images) {}

void LogCSDCacheContainsDebuggingMetadata(
    LoginReputationClientRequest::DebuggingMetadata* debugging_metadata) {}

}  // namespace

// static
scoped_refptr<PasswordProtectionRequest>
PasswordProtectionRequestContent::CreateForTesting(
    content::WebContents* web_contents,
    const GURL& main_frame_url,
    const GURL& password_form_action,
    const GURL& password_form_frame_url,
    const std::string& mime_type,
    const std::string& username,
    PasswordType password_type,
    const std::vector<password_manager::MatchingReusedCredential>&
        matching_reused_credentials,
    LoginReputationClientRequest::TriggerType type,
    bool password_field_exists,
    PasswordProtectionServiceBase* pps,
    int request_timeout_in_ms) {}

PasswordProtectionRequestContent::PasswordProtectionRequestContent(
    content::WebContents* web_contents,
    const GURL& main_frame_url,
    const GURL& password_form_action,
    const GURL& password_form_frame_url,
    const std::string& mime_type,
    const std::string& username,
    PasswordType password_type,
    const std::vector<password_manager::MatchingReusedCredential>&
        matching_reused_credentials,
    LoginReputationClientRequest::TriggerType type,
    bool password_field_exists,
    PasswordProtectionServiceBase* pps,
    int request_timeout_in_ms)
    :{}

PasswordProtectionRequestContent::~PasswordProtectionRequestContent() = default;

void PasswordProtectionRequestContent::Cancel(bool timed_out) {}

void PasswordProtectionRequestContent::ResumeDeferredNavigations() {}

base::WeakPtr<PasswordProtectionRequest>
PasswordProtectionRequestContent::AsWeakPtr() {}

void PasswordProtectionRequestContent::MaybeLogPasswordReuseLookupEvent(
    RequestOutcome outcome,
    const LoginReputationClientResponse* response) {}

void PasswordProtectionRequestContent::MaybeAddPingToWebUI(
    const std::string& oauth_token) {}

void PasswordProtectionRequestContent::MaybeAddResponseToWebUI(
    const LoginReputationClientResponse& response) {}

#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
bool PasswordProtectionRequestContent::IsClientSideDetectionEnabled() {}

bool PasswordProtectionRequestContent::IsVisualFeaturesEnabled() {}

void PasswordProtectionRequestContent::GetDomFeatures() {}

void PasswordProtectionRequestContent::OnGetDomFeatures(
    mojom::PhishingDetectorResult result,
    std::optional<mojo_base::ProtoWrapper> verdict) {}

void PasswordProtectionRequestContent::ExtractClientPhishingRequestFeatures(
    ClientPhishingRequest verdict) {}

void PasswordProtectionRequestContent::OnGetDomFeatureTimeout() {}

bool PasswordProtectionRequestContent::ShouldCollectVisualFeatures() {}

void PasswordProtectionRequestContent::MaybeCollectVisualFeatures() {}

void PasswordProtectionRequestContent::CollectVisualFeatures() {}

void PasswordProtectionRequestContent::OnScreenshotTaken(
    const SkBitmap& screenshot) {}

void PasswordProtectionRequestContent::OnVisualFeatureCollectionDone(
    std::unique_ptr<VisualFeatures> visual_features) {}
#endif  // BUILDFLAG(SAFE_BROWSING_AVAILABLE)

#if BUILDFLAG(IS_ANDROID)
void PasswordProtectionRequestContent::SetReferringAppInfo() {
  PasswordProtectionService* service =
      static_cast<PasswordProtectionService*>(password_protection_service());
  LoginReputationClientRequest::ReferringAppInfo referring_app_info =
      service->GetReferringAppInfo(web_contents_);
  UMA_HISTOGRAM_ENUMERATION(
      "PasswordProtection.RequestReferringAppSource",
      referring_app_info.referring_app_source(),
      LoginReputationClientRequest::ReferringAppInfo::ReferringAppSource_MAX +
          1);
  *request_proto_->mutable_referring_app_info() = std::move(referring_app_info);
}
#endif  // BUILDFLAG(IS_ANDROID)

}  // namespace safe_browsing