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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller.h

Issue 1445383003: Introduce PasswordsModelDelegate as an abstraction between ManagePasswordsBubbleModel and ManagePas… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Mac Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "base/timer/elapsed_timer.h" 11 #include "base/timer/elapsed_timer.h"
12 #include "chrome/browser/ui/passwords/manage_passwords_state.h" 12 #include "chrome/browser/ui/passwords/manage_passwords_state.h"
13 #include "chrome/browser/ui/passwords/passwords_model_delegate.h"
13 #include "components/autofill/core/common/password_form.h" 14 #include "components/autofill/core/common/password_form.h"
14 #include "components/password_manager/core/browser/password_store.h" 15 #include "components/password_manager/core/browser/password_store.h"
15 #include "components/password_manager/core/common/password_manager_ui.h"
16 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
17 #include "content/public/browser/web_contents_user_data.h" 17 #include "content/public/browser/web_contents_user_data.h"
18 18
19 namespace content { 19 namespace content {
20 class WebContents; 20 class WebContents;
21 } 21 }
22 22
23 namespace password_manager { 23 namespace password_manager {
24 enum class CredentialType; 24 enum class CredentialType;
25 struct CredentialInfo; 25 struct CredentialInfo;
26 class PasswordFormManager; 26 class PasswordFormManager;
27 } 27 }
28 28
29 class ManagePasswordsIconView; 29 class ManagePasswordsIconView;
30 30
31 // Per-tab class to control the Omnibox password icon and bubble. 31 // Per-tab class to control the Omnibox password icon and bubble.
32 class ManagePasswordsUIController 32 class ManagePasswordsUIController
33 : public content::WebContentsObserver, 33 : public content::WebContentsObserver,
34 public content::WebContentsUserData<ManagePasswordsUIController>, 34 public content::WebContentsUserData<ManagePasswordsUIController>,
35 public password_manager::PasswordStore::Observer { 35 public password_manager::PasswordStore::Observer,
36 public PasswordsModelDelegate {
36 public: 37 public:
37 ~ManagePasswordsUIController() override; 38 ~ManagePasswordsUIController() override;
38 39
39 // Called when the user submits a form containing login information, so we 40 // Called when the user submits a form containing login information, so we
40 // can handle later requests to save or blacklist that login information. 41 // can handle later requests to save or blacklist that login information.
41 // This stores the provided object and triggers the UI to prompt the user 42 // This stores the provided object and triggers the UI to prompt the user
42 // about whether they would like to save the password. 43 // about whether they would like to save the password.
43 void OnPasswordSubmitted( 44 void OnPasswordSubmitted(
44 scoped_ptr<password_manager::PasswordFormManager> form_manager); 45 scoped_ptr<password_manager::PasswordFormManager> form_manager);
45 46
(...skipping 26 matching lines...) Expand all
72 // password credentials for the current site which are stored in 73 // password credentials for the current site which are stored in
73 // |password_form_map|. This stores a copy of |password_form_map| and shows 74 // |password_form_map|. This stores a copy of |password_form_map| and shows
74 // the manage password icon. 75 // the manage password icon.
75 void OnPasswordAutofilled(const autofill::PasswordFormMap& password_form_map, 76 void OnPasswordAutofilled(const autofill::PasswordFormMap& password_form_map,
76 const GURL& origin); 77 const GURL& origin);
77 78
78 // PasswordStore::Observer implementation. 79 // PasswordStore::Observer implementation.
79 void OnLoginsChanged( 80 void OnLoginsChanged(
80 const password_manager::PasswordStoreChangeList& changes) override; 81 const password_manager::PasswordStoreChangeList& changes) override;
81 82
82 // Called from the model when the user chooses to save a password; passes the
83 // action to the |form_manager|. The controller must be in a pending state,
84 // and will be in MANAGE_STATE after this method executes.
85 virtual void SavePassword();
86
87 // Called from the model when the user chooses to update a password; passes
88 // the action to the |form_manager|. The controller must be in a pending
89 // state, and will be in MANAGE_STATE after this method executes.
90 virtual void UpdatePassword(const autofill::PasswordForm& password_form);
91
92 // Called from the model when the user chooses a credential.
93 // The controller MUST be in a pending credentials state.
94 virtual void ChooseCredential(
95 const autofill::PasswordForm& form,
96 password_manager::CredentialType credential_type);
97
98 // Called from the model when the user chooses to never save passwords; passes
99 // the action off to the FormManager. The controller must be in a pending
100 // state, and will state in this state.
101 virtual void NeverSavePassword();
102
103 // Open a new tab, pointing to the password manager settings page.
104 virtual void NavigateToPasswordManagerSettingsPage();
105
106 // Two different ways to open a new tab pointing to passwords.google.com.
107 // TODO(crbug.com/548259) eliminate one of them.
108 virtual void NavigateToExternalPasswordManager();
109 virtual void NavigateToSmartLockPage();
110
111 // Open a new tab, pointing to the Smart Lock help article.
112 virtual void NavigateToSmartLockHelpPage();
113
114 virtual const autofill::PasswordForm& PendingPassword() const;
115
116 #if !defined(OS_ANDROID) 83 #if !defined(OS_ANDROID)
117 // Set the state of the Omnibox icon, and possibly show the associated bubble 84 // Set the state of the Omnibox icon, and possibly show the associated bubble
118 // without user interaction. 85 // without user interaction.
119 virtual void UpdateIconAndBubbleState(ManagePasswordsIconView* icon); 86 virtual void UpdateIconAndBubbleState(ManagePasswordsIconView* icon);
120 #endif 87 #endif
121 88
122 // Called from the model when the bubble is displayed.
123 void OnBubbleShown();
124
125 // Called from the model when the bubble is hidden.
126 void OnBubbleHidden();
127
128 // Called when the user chose not to update password.
129 void OnNopeUpdateClicked();
130
131 // Called when the user didn't interact with Update UI.
132 void OnNoInteractionOnUpdate();
133
134 virtual password_manager::ui::State state() const;
135
136 // True if a password is sitting around, waiting for a user to decide whether
137 // or not to save it.
138 bool PasswordPendingUserDecision() const {
139 return state() == password_manager::ui::PENDING_PASSWORD_STATE;
140 }
141
142 const GURL& origin() const { return passwords_data_.origin(); }
143
144 bool IsAutomaticallyOpeningBubble() const { return should_pop_up_bubble_; } 89 bool IsAutomaticallyOpeningBubble() const { return should_pop_up_bubble_; }
145 90
146 // Current local forms. 91 // PasswordsModelDelegate:
147 const std::vector<const autofill::PasswordForm*>& GetCurrentForms() const { 92 const GURL& GetOrigin() const override;
148 return passwords_data_.GetCurrentForms(); 93 password_manager::ui::State GetState() const override;
149 } 94 const autofill::PasswordForm& GetPendingPassword() const override;
150 95 bool IsPasswordOverridden() const override;
151 // Current federated forms. 96 const std::vector<const autofill::PasswordForm*>& GetCurrentForms()
152 const std::vector<const autofill::PasswordForm*>& GetFederatedForms() const { 97 const override;
153 return passwords_data_.federated_credentials_forms(); 98 const std::vector<const autofill::PasswordForm*>& GetFederatedForms()
154 } 99 const override;
155 100 void OnBubbleShown() override;
156 // True if the password for previously stored account was overridden, i.e. in 101 void OnBubbleHidden() override;
157 // newly submitted form the password is different from stored one. 102 void OnNoInteractionOnUpdate() override;
158 bool PasswordOverridden() const; 103 void OnNopeUpdateClicked() override;
104 void NeverSavePassword() override;
105 void SavePassword() override;
106 void UpdatePassword(const autofill::PasswordForm& password_form) override;
107 void ChooseCredential(
108 const autofill::PasswordForm& form,
109 password_manager::CredentialType credential_type) override;
110 // Two different ways to open a new tab pointing to passwords.google.com.
111 // TODO(crbug.com/548259) eliminate one of them.
112 void NavigateToExternalPasswordManager() override;
113 void NavigateToSmartLockPage() override;
114 void NavigateToSmartLockHelpPage() override;
115 void NavigateToPasswordManagerSettingsPage() override;
159 116
160 protected: 117 protected:
161 explicit ManagePasswordsUIController( 118 explicit ManagePasswordsUIController(
162 content::WebContents* web_contents); 119 content::WebContents* web_contents);
163 120
164 // The pieces of saving and blacklisting passwords that interact with 121 // The pieces of saving and blacklisting passwords that interact with
165 // FormManager, split off into internal functions for testing/mocking. 122 // FormManager, split off into internal functions for testing/mocking.
166 virtual void SavePasswordInternal(); 123 virtual void SavePasswordInternal();
167 virtual void UpdatePasswordInternal( 124 virtual void UpdatePasswordInternal(
168 const autofill::PasswordForm& password_form); 125 const autofill::PasswordForm& password_form);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 scoped_ptr<base::ElapsedTimer> timer_; 167 scoped_ptr<base::ElapsedTimer> timer_;
211 168
212 // Contains true if the bubble is to be popped up in the next call to 169 // Contains true if the bubble is to be popped up in the next call to
213 // UpdateBubbleAndIconVisibility(). 170 // UpdateBubbleAndIconVisibility().
214 bool should_pop_up_bubble_; 171 bool should_pop_up_bubble_;
215 172
216 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController); 173 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController);
217 }; 174 };
218 175
219 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ 176 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698