| Index: chrome/browser/ui/passwords/manage_passwords_ui_controller.h
|
| diff --git a/chrome/browser/ui/passwords/manage_passwords_ui_controller.h b/chrome/browser/ui/passwords/manage_passwords_ui_controller.h
|
| index 8aa6241c1885d77d4aa8499f571f8131713f0feb..525fc1670d9eaddbffb2b03388efe3e4a7e7eaa5 100644
|
| --- a/chrome/browser/ui/passwords/manage_passwords_ui_controller.h
|
| +++ b/chrome/browser/ui/passwords/manage_passwords_ui_controller.h
|
| @@ -7,6 +7,7 @@
|
|
|
| #include "base/memory/scoped_vector.h"
|
| #include "base/timer/elapsed_timer.h"
|
| +#include "chrome/browser/ui/passwords/manage_passwords_state.h"
|
| #include "components/autofill/core/common/password_form.h"
|
| #include "components/password_manager/core/browser/password_store.h"
|
| #include "components/password_manager/core/common/password_manager_ui.h"
|
| @@ -35,8 +36,8 @@ class ManagePasswordsUIController
|
|
|
| // Called when the user submits a form containing login information, so we
|
| // can handle later requests to save or blacklist that login information.
|
| - // This stores the provided object in form_manager_ and triggers the UI to
|
| - // prompt the user about whether they would like to save the password.
|
| + // This stores the provided object and triggers the UI to prompt the user
|
| + // about whether they would like to save the password.
|
| void OnPasswordSubmitted(
|
| scoped_ptr<password_manager::PasswordFormManager> form_manager);
|
|
|
| @@ -110,28 +111,28 @@ class ManagePasswordsUIController
|
| // Called from the model when the bubble is hidden.
|
| void OnBubbleHidden();
|
|
|
| - password_manager::ui::State state() const { return state_; }
|
| -
|
| - ScopedVector<autofill::PasswordForm>& federated_credentials_forms() {
|
| - return federated_credentials_forms_;
|
| - }
|
| -
|
| - ScopedVector<autofill::PasswordForm>& local_credentials_forms() {
|
| - return local_credentials_forms_;
|
| - }
|
| + password_manager::ui::State state() const { return passwords_data_.state(); }
|
|
|
| // True if a password is sitting around, waiting for a user to decide whether
|
| // or not to save it.
|
| - bool PasswordPendingUserDecision() const;
|
| -
|
| - const autofill::ConstPasswordFormMap& best_matches() const {
|
| - return password_form_map_;
|
| + bool PasswordPendingUserDecision() const {
|
| + return state() == password_manager::ui::PENDING_PASSWORD_STATE;
|
| }
|
|
|
| - const GURL& origin() const { return origin_; }
|
| + const GURL& origin() const { return passwords_data_.origin(); }
|
|
|
| bool IsAutomaticallyOpeningBubble() const { return should_pop_up_bubble_; }
|
|
|
| + // Current local forms.
|
| + const std::vector<const autofill::PasswordForm*>& GetCurrentForms() const {
|
| + return passwords_data_.GetCurrentForms();
|
| + }
|
| +
|
| + // Current federated forms.
|
| + const std::vector<const autofill::PasswordForm*>& GetFederatedForms() const {
|
| + return passwords_data_.federated_credentials_forms();
|
| + }
|
| +
|
| protected:
|
| explicit ManagePasswordsUIController(
|
| content::WebContents* web_contents);
|
| @@ -141,7 +142,7 @@ class ManagePasswordsUIController
|
| virtual void SavePasswordInternal();
|
| virtual void NeverSavePasswordInternal();
|
|
|
| - // Called when a passwordform is autofilled, when a new passwordform is
|
| + // Called when a PasswordForm is autofilled, when a new PasswordForm is
|
| // submitted, or when a navigation occurs to update the visibility of the
|
| // manage passwords icon and bubble.
|
| virtual void UpdateBubbleAndIconVisibility();
|
| @@ -150,20 +151,17 @@ class ManagePasswordsUIController
|
| // or base::TimeDelta::Max() if |timer_| was not initialized.
|
| virtual base::TimeDelta Elapsed() const;
|
|
|
| + // Overwrites the client for |passwords_data_|.
|
| + void set_client(password_manager::PasswordManagerClient* client) {
|
| + passwords_data_.set_client(client);
|
| + }
|
| +
|
| // content::WebContentsObserver:
|
| void DidNavigateMainFrame(
|
| const content::LoadCommittedDetails& details,
|
| const content::FrameNavigateParams& params) override;
|
| void WasHidden() override;
|
|
|
| - // Sets |state_|. Protected so we can manipulate the value in tests.
|
| - void SetState(password_manager::ui::State state);
|
| -
|
| - // All previously stored credentials for a specific site.
|
| - // Protected, not private, so we can mess with the value in
|
| - // ManagePasswordsUIControllerMock.
|
| - autofill::ConstPasswordFormMap password_form_map_;
|
| -
|
| private:
|
| friend class content::WebContentsUserData<ManagePasswordsUIController>;
|
|
|
| @@ -173,57 +171,22 @@ class ManagePasswordsUIController
|
| // content::WebContentsObserver:
|
| void WebContentsDestroyed() override;
|
|
|
| - // Saves the parameters and clean the previous forms.
|
| - void SaveForms(ScopedVector<autofill::PasswordForm> local_forms,
|
| - ScopedVector<autofill::PasswordForm> federated_forms);
|
| -
|
| // Shows infobar which allows user to choose credentials. Placing this
|
| // code to separate method allows mocking.
|
| virtual void UpdateAndroidAccountChooserInfoBarVisibility();
|
|
|
| - // The current state of the password manager UI.
|
| - password_manager::ui::State state_;
|
| + // The wrapper around current state and data.
|
| + ManagePasswordsState passwords_data_;
|
|
|
| // Used to measure the amount of time on a page; if it's less than some
|
| // reasonable limit, then don't close the bubble upon navigation. We create
|
| // (and destroy) the timer in DidNavigateMainFrame.
|
| scoped_ptr<base::ElapsedTimer> timer_;
|
|
|
| - // TODO(vasilii): remove these data variables, use ManagePasswordsState.
|
| -
|
| - // Set by OnPasswordSubmitted() when the user submits a form containing login
|
| - // information. If the user responds to a subsequent "Do you want to save
|
| - // this password?" prompt, we ask this object to save or blacklist the
|
| - // associated login information in Chrome's password store.
|
| - scoped_ptr<password_manager::PasswordFormManager> form_manager_;
|
| -
|
| - // We create copies of PasswordForm objects that come in with unclear lifetime
|
| - // and store them in this vector as well as in |password_form_map_| to ensure
|
| - // that we destroy them correctly. If |new_password_forms_| gets cleared then
|
| - // |password_form_map_| is to be cleared too.
|
| - ScopedVector<autofill::PasswordForm> new_password_forms_;
|
| -
|
| - // Federated credentials. Stores federated credentials which will be shown
|
| - // when Credential Management API was used.
|
| - ScopedVector<autofill::PasswordForm> federated_credentials_forms_;
|
| -
|
| - // Local credentials. Stores local credentials which will be shown
|
| - // when Credential Management API was used.
|
| - ScopedVector<autofill::PasswordForm> local_credentials_forms_;
|
| -
|
| - // A callback to be invoked when user selects a credential.
|
| - base::Callback<void(const password_manager::CredentialInfo&)>
|
| - credentials_callback_;
|
| -
|
| // Contains true if the bubble is to be popped up in the next call to
|
| // UpdateBubbleAndIconVisibility().
|
| bool should_pop_up_bubble_;
|
|
|
| - // The origin of the form we're currently dealing with; we'll use this to
|
| - // determine which PasswordStore changes we should care about when updating
|
| - // |password_form_map_|.
|
| - GURL origin_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController);
|
| };
|
|
|
|
|