| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_ANDROID
_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_ANDROID
_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_ANDROID
_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_ANDROID
_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "chrome/browser/password_manager/password_manager_infobar_delegate_andr
oid.h" | 12 #include "chrome/browser/password_manager/password_manager_infobar_delegate_andr
oid.h" |
| 14 #include "chrome/browser/ui/passwords/manage_passwords_state.h" | 13 #include "chrome/browser/ui/passwords/manage_passwords_state.h" |
| 15 #include "components/password_manager/core/browser/password_form_manager.h" | 14 #include "components/password_manager/core/browser/password_form_manager.h" |
| 16 | 15 |
| 17 namespace content { | 16 namespace content { |
| 18 class WebContents; | 17 class WebContents; |
| 19 } | 18 } |
| 20 | 19 |
| 21 // An infobar delegate which asks the user if the password should be updated for | 20 // An infobar delegate which asks the user if the password should be updated for |
| 22 // a set of saved credentials for a site. If several such sets are present, the | 21 // a set of saved credentials for a site. If several such sets are present, the |
| 23 // user can choose which one to update. PasswordManager displays this infobar | 22 // user can choose which one to update. PasswordManager displays this infobar |
| 24 // when the user signs into the site with a new password for a known username | 23 // when the user signs into the site with a new password for a known username |
| 25 // or fills in a password change form. | 24 // or fills in a password change form. |
| 26 class UpdatePasswordInfoBarDelegate : public PasswordManagerInfoBarDelegate { | 25 class UpdatePasswordInfoBarDelegate : public PasswordManagerInfoBarDelegate { |
| 27 public: | 26 public: |
| 28 static void Create( | 27 static void Create( |
| 29 content::WebContents* web_contents, | 28 content::WebContents* web_contents, |
| 30 scoped_refptr<password_manager::PasswordFormManager> form_to_update); | 29 std::unique_ptr<password_manager::PasswordFormManager> form_to_update); |
| 31 | 30 |
| 32 ~UpdatePasswordInfoBarDelegate() override; | 31 ~UpdatePasswordInfoBarDelegate() override; |
| 33 | 32 |
| 34 base::string16 GetBranding() const; | 33 base::string16 GetBranding() const; |
| 35 bool is_smartlock_branding_enabled() const { | 34 bool is_smartlock_branding_enabled() const { |
| 36 return is_smartlock_branding_enabled_; | 35 return is_smartlock_branding_enabled_; |
| 37 } | 36 } |
| 38 | 37 |
| 39 // Returns whether the user has multiple saved credentials, of which the | 38 // Returns whether the user has multiple saved credentials, of which the |
| 40 // infobar affects just one. In this case the infobar should clarify which | 39 // infobar affects just one. In this case the infobar should clarify which |
| 41 // credential is being affected. | 40 // credential is being affected. |
| 42 bool ShowMultipleAccounts() const; | 41 bool ShowMultipleAccounts() const; |
| 43 | 42 |
| 44 const std::vector<std::unique_ptr<autofill::PasswordForm>>& | 43 const std::vector<std::unique_ptr<autofill::PasswordForm>>& |
| 45 GetCurrentForms() const; | 44 GetCurrentForms() const; |
| 46 | 45 |
| 47 // Returns the username of the saved credentials in the case when there is | 46 // Returns the username of the saved credentials in the case when there is |
| 48 // only one credential pair stored. | 47 // only one credential pair stored. |
| 49 base::string16 get_username_for_single_account() { | 48 base::string16 get_username_for_single_account() { |
| 50 return passwords_state_.form_manager() | 49 return passwords_state_.form_manager() |
| 51 ->pending_credentials() | 50 ->pending_credentials() |
| 52 .username_value; | 51 .username_value; |
| 53 } | 52 } |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 UpdatePasswordInfoBarDelegate( | 55 UpdatePasswordInfoBarDelegate( |
| 57 content::WebContents* web_contents, | 56 content::WebContents* web_contents, |
| 58 scoped_refptr<password_manager::PasswordFormManager> form_to_update, | 57 std::unique_ptr<password_manager::PasswordFormManager> form_to_update, |
| 59 bool is_smartlock_branding_enabled); | 58 bool is_smartlock_branding_enabled); |
| 60 | 59 |
| 61 // ConfirmInfoBarDelegate: | 60 // ConfirmInfoBarDelegate: |
| 62 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 61 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 63 int GetButtons() const override; | 62 int GetButtons() const override; |
| 64 base::string16 GetButtonLabel(InfoBarButton button) const override; | 63 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 65 bool Accept() override; | 64 bool Accept() override; |
| 66 | 65 |
| 67 ManagePasswordsState passwords_state_; | 66 ManagePasswordsState passwords_state_; |
| 68 base::string16 branding_; | 67 base::string16 branding_; |
| 69 bool is_smartlock_branding_enabled_; | 68 bool is_smartlock_branding_enabled_; |
| 70 | 69 |
| 71 DISALLOW_COPY_AND_ASSIGN(UpdatePasswordInfoBarDelegate); | 70 DISALLOW_COPY_AND_ASSIGN(UpdatePasswordInfoBarDelegate); |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 #endif // CHROME_BROWSER_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_ANDR
OID_H_ | 73 #endif // CHROME_BROWSER_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_ANDR
OID_H_ |
| OLD | NEW |