Commit 9e3a30b8 authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Make PasswordManagerPresenter forget about PasswordManagerPorter

This CL moves the ownership of PasswordManagerPorter up from
PasswordManagerPresenter to the owner of the presenter. It also makes
PasswordManagerPresenter forget about the porter and lets
PasswordsPrivateDelegateImpl call the PasswordManagerPorter
methods directly, bypassing PasswordManagerPresenter.

This removes the confusing dependency cycle between
PasswordManagerPorter and PasswordManagerPresenter.

Bug: 700003
Change-Id: I9ab4f45adc7dba3be083fa0a94ec3daceaa14eef
Reviewed-on: https://chromium-review.googlesource.com/739384Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarChristos Froussios <cfroussios@chromium.org>
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512407}
parent 677f64d7
......@@ -29,7 +29,10 @@ namespace extensions {
PasswordsPrivateDelegateImpl::PasswordsPrivateDelegateImpl(Profile* profile)
: profile_(profile),
password_manager_presenter_(new PasswordManagerPresenter(this)),
password_manager_presenter_(
std::make_unique<PasswordManagerPresenter>(this)),
password_manager_porter_(std::make_unique<PasswordManagerPorter>(
password_manager_presenter_.get())),
current_entries_initialized_(false),
current_exceptions_initialized_(false),
is_initialized_(false),
......@@ -210,12 +213,14 @@ void PasswordsPrivateDelegateImpl::SetPasswordExceptionList(
void PasswordsPrivateDelegateImpl::ImportPasswords(
content::WebContents* web_contents) {
password_manager_presenter_->ImportPasswords(web_contents);
password_manager_porter_->set_web_contents(web_contents);
password_manager_porter_->Load();
}
void PasswordsPrivateDelegateImpl::ExportPasswords(
content::WebContents* web_contents) {
password_manager_presenter_->ExportPasswords(web_contents);
password_manager_porter_->set_web_contents(web_contents);
password_manager_porter_->Store();
}
#if !defined(OS_ANDROID)
......@@ -227,6 +232,7 @@ gfx::NativeWindow PasswordsPrivateDelegateImpl::GetNativeWindow() const {
void PasswordsPrivateDelegateImpl::Shutdown() {
password_manager_presenter_.reset();
password_manager_porter_.reset();
}
void PasswordsPrivateDelegateImpl::ExecuteFunction(
......
......@@ -16,6 +16,7 @@
#include "base/observer_list.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/passwords_private/passwords_private_delegate.h"
#include "chrome/browser/ui/passwords/password_manager_porter.h"
#include "chrome/browser/ui/passwords/password_manager_presenter.h"
#include "chrome/browser/ui/passwords/password_ui_view.h"
#include "chrome/common/extensions/api/passwords_private.h"
......@@ -91,6 +92,9 @@ class PasswordsPrivateDelegateImpl : public PasswordsPrivateDelegate,
// Used to communicate with the password store.
std::unique_ptr<PasswordManagerPresenter> password_manager_presenter_;
// Used to control the export and import flows.
std::unique_ptr<PasswordManagerPorter> password_manager_porter_;
// The current list of entries/exceptions. Cached here so that when new
// observers are added, this delegate can send the current lists without
// having to request them from |password_manager_presenter_| again.
......
......@@ -216,7 +216,6 @@ PasswordManagerPresenter::PasswordManagerPresenter(
: populater_(this),
exception_populater_(this),
password_view_(password_view),
password_manager_porter_(this),
password_access_authenticator_(
base::BindRepeating(&PasswordManagerPresenter::OsReauthCall,
base::Unretained(this))) {
......@@ -410,18 +409,6 @@ void PasswordManagerPresenter::SortEntriesAndHideDuplicates(
}
}
void PasswordManagerPresenter::ImportPasswords(
content::WebContents* web_contents) {
password_manager_porter_.set_web_contents(web_contents);
password_manager_porter_.Load();
}
void PasswordManagerPresenter::ExportPasswords(
content::WebContents* web_contents) {
password_manager_porter_.set_web_contents(web_contents);
password_manager_porter_.Store();
}
void PasswordManagerPresenter::AddLogin(const autofill::PasswordForm& form) {
PasswordStore* store = GetPasswordStore();
if (!store)
......
......@@ -14,7 +14,6 @@
#include "base/macros.h"
#include "chrome/browser/ui/passwords/password_access_authenticator.h"
#include "chrome/browser/ui/passwords/password_manager_porter.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
#include "components/password_manager/core/browser/ui/credential_provider_interface.h"
......@@ -79,14 +78,6 @@ class PasswordManagerPresenter
// |index| The index of the entry.
void RequestShowPassword(size_t index);
// Trigger the password import procedure, allowing the user to load passwords
// from a file.
void ImportPasswords(content::WebContents* web_contents);
// Trigger the password export procedure, allowing the user to save all their
// passwords to a file.
void ExportPasswords(content::WebContents* web_contents);
// Wrapper around |PasswordStore::AddLogin| that adds the corresponding undo
// action to |undo_manager_|.
void AddLogin(const autofill::PasswordForm& form);
......@@ -180,8 +171,6 @@ class PasswordManagerPresenter
// UI view that owns this presenter.
PasswordUIView* password_view_;
PasswordManagerPorter password_manager_porter_;
PasswordAccessAuthenticator password_access_authenticator_;
DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment