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 | |
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. | |
42 bool ShowMultipleAccounts() const; | |
43 | |
44 const std::vector<const autofill::PasswordForm*>& GetCurrentForms() const { | |
45 return passwords_data_.GetCurrentForms(); | |
46 } | |
47 | |
48 // Returns the username of the saved credentials in case when there is only | |
49 // one credential pair stored. | |
50 base::string16 GetUsernameForOneAccountCase(); | |
51 | |
52 // Updates the form with index |form_index| in case of multiple credentials or | |
53 // the only available form otherwise. | |
54 void UpdatePasswordInternal(int form_index); | |
vabr (Chromium)
2016/01/13 16:04:34
optional nit: What about renaming to, e.g., Update
| |
55 | |
56 // ConfirmInfoBarDelegate: | |
57 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | |
58 base::string16 GetButtonLabel(InfoBarButton button) const override; | |
59 bool Accept() override; | |
60 bool Cancel() override; | |
61 | |
62 private: | |
63 UpdatePasswordInfoBarDelegate( | |
64 content::WebContents* web_contents, | |
65 scoped_ptr<password_manager::PasswordFormManager> form_to_update, | |
66 bool is_smartlock_branding_enabled); | |
67 | |
68 ManagePasswordsState passwords_data_; | |
69 base::string16 branding_; | |
70 bool is_smartlock_branding_enabled_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(UpdatePasswordInfoBarDelegate); | |
73 }; | |
74 | |
75 #endif // CHROME_BROWSER_PASSWORD_MANAGER_UPDATE_PASSWORD_INFOBAR_DELEGATE_H_ | |
OLD | NEW |