Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_H_ | |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "chrome/browser/password_manager/password_manager_infobar_delegate.h" | |
| 13 #include "chrome/browser/ui/passwords/manage_passwords_state.h" | |
| 14 #include "components/password_manager/core/browser/password_form_manager.h" | |
| 15 | |
| 16 namespace content { | |
| 17 class WebContents; | |
| 18 } | |
| 19 | |
| 20 // If PasswordManager encounters the login which is already known or user fills | |
| 21 // the password change form, then user is prompted with an infobar asking if | |
| 22 // already saved credentials should be updated or not. | |
| 23 // In case several credentials are stored for the web site, user can choose | |
| 24 // which one should be updated. | |
| 25 class UpdatePasswordInfoBarDelegate : public PasswordManagerInfoBarDelegate { | |
| 26 public: | |
| 27 static void Create( | |
| 28 content::WebContents* web_contents, | |
| 29 scoped_ptr<password_manager::PasswordFormManager> form_to_update); | |
| 30 | |
| 31 ~UpdatePasswordInfoBarDelegate() override; | |
| 32 | |
| 33 base::string16 branding() const { return branding_; } | |
| 34 | |
|
Peter Kasting
2016/02/03 00:56:27
Nit: Blank line unnecessary
melandory
2016/02/12 19:19:37
Done.
| |
| 35 bool is_smartlock_branding_enabled() const { | |
| 36 return is_smartlock_branding_enabled_; | |
| 37 } | |
| 38 | |
| 39 // Returns true if infobar for the multi credentials case should be shown, e.g | |
| 40 // user changing a password on a password change form and has several | |
| 41 // credentials save for the web site. | |
|
Peter Kasting
2016/02/03 00:56:27
Nit: Maybe "Returns true if an infobar should be s
melandory
2016/02/12 19:19:37
We show infobar even in case of one credentials. T
Peter Kasting
2016/02/13 01:44:52
This comment doesn't communicate that clearly at a
| |
| 42 bool ShowMultipleAccounts() const; | |
| 43 | |
| 44 const std::vector<const autofill::PasswordForm*>& GetCurrentForms() const { | |
|
Peter Kasting
2016/02/03 00:56:27
Do not inline CamelCase functions. This should be
melandory
2016/02/12 19:19:37
Done.
| |
| 45 return passwords_data_.GetCurrentForms(); | |
| 46 } | |
| 47 | |
| 48 // Returns the username of the saved credentials in case when there is only | |
|
Peter Kasting
2016/02/03 00:56:27
Nit: in -> in the
melandory
2016/02/12 19:19:37
Done.
| |
| 49 // one credential pair stored. | |
| 50 base::string16 GetUsernameForOneAccountCase(); | |
| 51 | |
| 52 // ConfirmInfoBarDelegate: | |
| 53 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | |
| 54 base::string16 GetButtonLabel(InfoBarButton button) const override; | |
| 55 bool Accept() override; | |
| 56 bool Cancel() override; | |
|
Peter Kasting
2016/02/03 00:56:27
Nit: Do these really need to be public? Make them
melandory
2016/02/12 19:19:36
Done.
| |
| 57 | |
| 58 private: | |
| 59 UpdatePasswordInfoBarDelegate( | |
| 60 content::WebContents* web_contents, | |
| 61 scoped_ptr<password_manager::PasswordFormManager> form_to_update, | |
| 62 bool is_smartlock_branding_enabled); | |
| 63 | |
| 64 // Updates either pending credentials of form with |form_index| in case | |
| 65 // multiple choice available. | |
|
Peter Kasting
2016/02/03 00:56:27
This comment makes no sense to me.
I don't think
melandory
2016/02/12 19:19:37
Done.
| |
| 66 void UpdatePassword(int form_index); | |
| 67 | |
| 68 // Updates the pending credentials. | |
| 69 void UpdatePasswordWithPending(); | |
| 70 | |
| 71 // Updates the form with index |form_index| in case of multiple credentials. | |
|
Peter Kasting
2016/02/03 00:56:27
Nit: in -> in the
melandory
2016/02/12 19:19:37
Done.
| |
| 72 void UpdatePasswordWithCurrentForm(int form_index); | |
| 73 | |
| 74 ManagePasswordsState passwords_data_; | |
| 75 base::string16 branding_; | |
| 76 bool is_smartlock_branding_enabled_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(UpdatePasswordInfoBarDelegate); | |
| 79 }; | |
| 80 | |
| 81 #endif // CHROME_BROWSER_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_H_ | |
| OLD | NEW |