Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Unified Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller.h

Issue 1009953002: Integrate ManagePasswordsState into ManagePasswordsUIController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..1a012fc60c298e88a548ee741d6298b421758927 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
vabr (Chromium) 2015/03/17 09:25:58 nit: One more all-lowercase "passwordform" still l
vasilii 2015/03/17 10:49:48 Done.
// submitted, or when a navigation occurs to update the visibility of the
// manage passwords icon and bubble.
virtual void UpdateBubbleAndIconVisibility();
@@ -156,14 +157,6 @@ class ManagePasswordsUIController
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 +166,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_;
vabr (Chromium) 2015/03/17 09:25:57 optional nit: Personally I would prefer the name t
vasilii 2015/03/17 10:49:48 But then there is a confusion with state() which u
vabr (Chromium) 2015/03/17 11:55:13 Fair enough. Then we should probably rename Manage
// 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);
};

Powered by Google App Engine
This is Rietveld 408576698