#include "chrome/browser/safe_browsing/chrome_password_reuse_detection_manager_client.h"
#include <memory>
#include <string>
#include <vector>
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/password_manager/chrome_password_manager_client.h"
#include "chrome/browser/password_manager/password_reuse_manager_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/autofill/autofill_client_provider.h"
#include "chrome/browser/ui/autofill/autofill_client_provider_factory.h"
#include "components/password_manager/content/browser/password_manager_log_router_factory.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_sync_util.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/sync/base/data_type.h"
#include "components/sync/service/sync_service.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/browser/web_contents.h"
#include "extensions/buildflags/buildflags.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/events/keycodes/keyboard_codes.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "extensions/common/constants.h"
#endif
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/safe_browsing/extension_telemetry/extension_telemetry_service.h"
#include "chrome/browser/safe_browsing/extension_telemetry/extension_telemetry_service_factory.h"
#include "chrome/browser/safe_browsing/extension_telemetry/password_reuse_signal.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/crosapi/cpp/scoped_allow_sync_call.h"
#include "chromeos/crosapi/mojom/clipboard.mojom.h"
#include "chromeos/lacros/lacros_service.h"
#endif
namespace {
PasswordType;
PasswordReuseEvent;
void AddToWidgetInputEventObservers(
content::RenderWidgetHost* widget_host,
content::RenderWidgetHost::InputEventObserver* observer) { … }
#if !BUILDFLAG(IS_ANDROID)
std::vector<std::string> GetMatchingDomains(
const std::vector<password_manager::MatchingReusedCredential>&
matching_reused_credentials) { … }
#endif
}
void ChromePasswordReuseDetectionManagerClient::CreateForWebContents(
content::WebContents* contents) { … }
void ChromePasswordReuseDetectionManagerClient::
CreateForProfilePickerWebContents(content::WebContents* contents) { … }
ChromePasswordReuseDetectionManagerClient::
~ChromePasswordReuseDetectionManagerClient() { … }
void ChromePasswordReuseDetectionManagerClient::OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event_details) { … }
void ChromePasswordReuseDetectionManagerClient::InternalOnPrimaryAccountChanged(
password_manager::PasswordManagerClient* password_manager_client,
const signin::PrimaryAccountChangeEvent& event_details) { … }
#if BUILDFLAG(IS_ANDROID)
void ChromePasswordReuseDetectionManagerClient::OnPasswordSelected(
const std::u16string& text) {
password_reuse_detection_manager_.OnPaste(text);
}
void ChromePasswordReuseDetectionManagerClient::OnImeTextCommittedEvent(
const std::u16string& text_str) {
password_reuse_detection_manager_.OnKeyPressedCommitted(text_str);
}
void ChromePasswordReuseDetectionManagerClient::OnImeSetComposingTextEvent(
const std::u16string& text_str) {
last_composing_text_ = text_str;
password_reuse_detection_manager_.OnKeyPressedUncommitted(
last_composing_text_);
}
void ChromePasswordReuseDetectionManagerClient::
OnImeFinishComposingTextEvent() {
password_reuse_detection_manager_.OnKeyPressedCommitted(last_composing_text_);
last_composing_text_.clear();
}
#endif
autofill::LogManager*
ChromePasswordReuseDetectionManagerClient::GetLogManager() { … }
password_manager::PasswordReuseManager*
ChromePasswordReuseDetectionManagerClient::GetPasswordReuseManager() const { … }
const GURL& ChromePasswordReuseDetectionManagerClient::GetLastCommittedURL()
const { … }
safe_browsing::PasswordProtectionService*
ChromePasswordReuseDetectionManagerClient::GetPasswordProtectionService()
const { … }
void ChromePasswordReuseDetectionManagerClient::
MaybeLogPasswordReuseDetectedEvent() { … }
bool ChromePasswordReuseDetectionManagerClient::IsHistorySyncAccountEmail(
const std::string& username) { … }
bool ChromePasswordReuseDetectionManagerClient::
IsPasswordFieldDetectedOnPage() { … }
void ChromePasswordReuseDetectionManagerClient::CheckProtectedPasswordEntry(
PasswordType password_type,
const std::string& username,
const std::vector<password_manager::MatchingReusedCredential>&
matching_reused_credentials,
bool password_field_exists,
uint64_t reused_password_hash,
const std::string& domain) { … }
ChromePasswordReuseDetectionManagerClient::
ChromePasswordReuseDetectionManagerClient(
content::WebContents* web_contents,
signin::IdentityManager* identity_manager)
: … { … }
void ChromePasswordReuseDetectionManagerClient::WebContentsDestroyed() { … }
void ChromePasswordReuseDetectionManagerClient::PrimaryPageChanged(
content::Page& page) { … }
void ChromePasswordReuseDetectionManagerClient::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) { … }
void ChromePasswordReuseDetectionManagerClient::OnPaste() { … }
void ChromePasswordReuseDetectionManagerClient::OnInputEvent(
const blink::WebInputEvent& event) { … }
WEB_CONTENTS_USER_DATA_KEY_IMPL(ChromePasswordReuseDetectionManagerClient);