#include "chrome/browser/password_manager/password_manager_test_base.h"
#include <map>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "chrome/browser/password_manager/account_password_store_factory.h"
#include "chrome/browser/password_manager/chrome_password_manager_client.h"
#include "chrome/browser/password_manager/passwords_navigation_observer.h"
#include "chrome/browser/password_manager/profile_password_store_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/autofill/chrome_autofill_client.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/tabs/tab_enums.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/content/browser/content_autofill_client.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/password_manager/core/browser/password_manager_test_utils.h"
#include "components/password_manager/core/browser/password_store/password_store_results_observer.h"
#include "components/password_manager/core/browser/password_store/test_password_store.h"
#include "components/sync/test/test_sync_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_test_utils.h"
#include "net/cert/cert_verify_result.h"
#include "net/dns/mock_host_resolver.h"
#include "net/http/transport_security_state.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/common/switches.h"
namespace {
std::unique_ptr<KeyedService> BuildTestSyncService(
content::BrowserContext* context) { … }
class CustomManagePasswordsUIController : public ManagePasswordsUIController { … };
CustomManagePasswordsUIController::CustomManagePasswordsUIController(
content::WebContents* web_contents)
: … { … }
void CustomManagePasswordsUIController::WaitForState(
password_manager::ui::State target_state) { … }
void CustomManagePasswordsUIController::WaitForFallbackForSaving() { … }
bool CustomManagePasswordsUIController::WaitForFallbackForSaving(
const base::TimeDelta timeout = base::TimeDelta::Max()) { … }
void CustomManagePasswordsUIController::OnPasswordSubmitted(
std::unique_ptr<password_manager::PasswordFormManagerForUI> form_manager) { … }
void CustomManagePasswordsUIController::OnUpdatePasswordSubmitted(
std::unique_ptr<password_manager::PasswordFormManagerForUI> form_manager) { … }
void CustomManagePasswordsUIController::OnShowManualFallbackForSaving(
std::unique_ptr<password_manager::PasswordFormManagerForUI> form_manager,
bool has_generated_password,
bool is_update) { … }
void CustomManagePasswordsUIController::OnHideManualFallbackForSaving() { … }
bool CustomManagePasswordsUIController::OnChooseCredentials(
std::vector<std::unique_ptr<password_manager::PasswordForm>>
local_credentials,
const url::Origin& origin,
ManagePasswordsState::CredentialsCallback callback) { … }
void CustomManagePasswordsUIController::OnPasswordAutofilled(
base::span<const password_manager::PasswordForm> password_forms,
const url::Origin& origin,
base::span<const password_manager::PasswordForm> federated_matches) { … }
void CustomManagePasswordsUIController::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
void CustomManagePasswordsUIController::NotifyUnsyncedCredentialsWillBeDeleted(
std::vector<password_manager::PasswordForm> unsynced_credentials) { … }
bool CustomManagePasswordsUIController::IsTargetStateObserved(
const password_manager::ui::State target_state,
const password_manager::ui::State current_state) const { … }
void CustomManagePasswordsUIController::ProcessStateExpectations(
const password_manager::ui::State current_state) { … }
void CustomManagePasswordsUIController::QuitRunLoop() { … }
enum ReturnCodes { … };
}
BubbleObserver::BubbleObserver(content::WebContents* web_contents)
: … { … }
bool BubbleObserver::IsSavePromptAvailable() const { … }
bool BubbleObserver::IsUpdatePromptAvailable() const { … }
bool BubbleObserver::IsDefaultStoreChangedPromptAvailable() const { … }
bool BubbleObserver::IsSavePromptShownAutomatically() const { … }
bool BubbleObserver::IsUpdatePromptShownAutomatically() const { … }
bool BubbleObserver::IsDefaultStoreChangedPromptShownAutomatically() const { … }
void BubbleObserver::Hide() const { … }
void BubbleObserver::AcceptSavePrompt() const { … }
void BubbleObserver::AcceptUpdatePrompt() const { … }
void BubbleObserver::AcknowledgeDefaultStoreChange() const { … }
void BubbleObserver::WaitForAccountChooser() const { … }
void BubbleObserver::WaitForInactiveState() const { … }
void BubbleObserver::WaitForManagementState() const { … }
void BubbleObserver::WaitForAutomaticSavePrompt() const { … }
void BubbleObserver::WaitForAutomaticUpdatePrompt() const { … }
bool BubbleObserver::WaitForFallbackForSaving(
const base::TimeDelta timeout) const { … }
void BubbleObserver::WaitForSaveUnsyncedCredentialsPrompt() const { … }
PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase()
: … { … }
PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() = default;
void PasswordManagerBrowserTestBase::SetUp() { … }
void PasswordManagerBrowserTestBase::SetUpOnMainThread() { … }
void PasswordManagerBrowserTestBase::ClearWebContentsPtr() { … }
void PasswordManagerBrowserTestBase::TearDownOnMainThread() { … }
void PasswordManagerBrowserTestBase::SetUpCommandLine(
base::CommandLine* command_line) { … }
content::WebContents* PasswordManagerBrowserTestBase::GetNewTab(
Browser* browser) { … }
void PasswordManagerBrowserTestBase::WaitForPasswordStore(Browser* browser) { … }
content::WebContents* PasswordManagerBrowserTestBase::WebContents() const { … }
content::RenderFrameHost* PasswordManagerBrowserTestBase::RenderFrameHost()
const { … }
void PasswordManagerBrowserTestBase::NavigateToFile(const std::string& path) { … }
void PasswordManagerBrowserTestBase::WaitForElementValue(
const std::string& element_id,
const std::string& expected_value) { … }
void PasswordManagerBrowserTestBase::WaitForElementValue(
const std::string& iframe_id,
const std::string& element_id,
const std::string& expected_value) { … }
void PasswordManagerBrowserTestBase::WaitForElementValue(
const std::string& form_id,
size_t elements_index,
const std::string& expected_value) { … }
void PasswordManagerBrowserTestBase::WaitForJsElementValue(
const std::string& element_selector,
const std::string& expected_value) { … }
void PasswordManagerBrowserTestBase::WaitForPasswordStore() { … }
void PasswordManagerBrowserTestBase::CheckElementValue(
const std::string& element_id,
const std::string& expected_value) { … }
void PasswordManagerBrowserTestBase::CheckElementValue(
const std::string& iframe_id,
const std::string& element_id,
const std::string& expected_value) { … }
void PasswordManagerBrowserTestBase::SetUpInProcessBrowserTestFixture() { … }
void PasswordManagerBrowserTestBase::AddHSTSHost(const std::string& host) { … }
void PasswordManagerBrowserTestBase::CheckThatCredentialsStored(
const std::string& username,
const std::string& password) { … }