#include "chrome/browser/ui/passwords/settings/password_manager_porter.h"
#include <string>
#include <vector>
#include "base/auto_reset.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/browser/export/password_manager_exporter.h"
#include "components/password_manager/core/browser/import/csv_password_sequence.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/shell_dialogs/selected_file_info.h"
#if BUILDFLAG(IS_WIN)
#endif
namespace {
#if !BUILDFLAG(IS_ANDROID)
base::FilePath GetDefaultFilepathForPasswordFile(
const base::FilePath::StringType& default_extension) { … }
#endif
}
PasswordManagerPorter::PasswordManagerPorter(
Profile* profile,
password_manager::SavedPasswordsPresenter* presenter,
ExportProgressCallback on_export_progress_callback)
: … { … }
PasswordManagerPorter::~PasswordManagerPorter() { … }
bool PasswordManagerPorter::Export(
base::WeakPtr<content::WebContents> web_contents) { … }
void PasswordManagerPorter::CancelExport() { … }
password_manager::ExportProgressStatus
PasswordManagerPorter::GetExportProgressStatus() { … }
void PasswordManagerPorter::SetExporterForTesting(
std::unique_ptr<password_manager::PasswordManagerExporter> exporter) { … }
void PasswordManagerPorter::Import(
content::WebContents* web_contents,
password_manager::PasswordForm::Store to_store,
ImportResultsCallback results_callback) { … }
void PasswordManagerPorter::ContinueImport(
const std::vector<int>& selected_ids,
ImportResultsCallback results_callback) { … }
void PasswordManagerPorter::ResetImporter(bool delete_file) { … }
void PasswordManagerPorter::SetImporterForTesting(
std::unique_ptr<password_manager::PasswordImporter> importer) { … }
PasswordManagerPorter::ImportFileSelectListener::ImportFileSelectListener(
PasswordManagerPorter* owner)
: … { … }
PasswordManagerPorter::ImportFileSelectListener::~ImportFileSelectListener() =
default;
void PasswordManagerPorter::ImportFileSelectListener::FileSelected(
const ui::SelectedFileInfo& file,
int ) { … }
void PasswordManagerPorter::ImportFileSelectListener::FileSelectionCanceled() { … }
PasswordManagerPorter::ExportFileSelectListener::ExportFileSelectListener(
PasswordManagerPorter* owner)
: … { … }
PasswordManagerPorter::ExportFileSelectListener::~ExportFileSelectListener() =
default;
void PasswordManagerPorter::ExportFileSelectListener::FileSelected(
const ui::SelectedFileInfo& file,
int ) { … }
void PasswordManagerPorter::ExportFileSelectListener::FileSelectionCanceled() { … }
#if !BUILDFLAG(IS_ANDROID)
static ui::SelectFileDialog::FileTypeInfo FileTypeInfoForImportExport() { … }
#endif
void PasswordManagerPorter::PresentImportFileSelector(
content::WebContents* web_contents) { … }
void PasswordManagerPorter::PresentExportFileSelector(
content::WebContents* web_contents) { … }
void PasswordManagerPorter::ExportPasswordsToPath(const base::FilePath& path) { … }
void PasswordManagerPorter::ExportDone() { … }
void PasswordManagerPorter::ImportPasswordsFromPath(
const base::FilePath& path) { … }