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 #include "chrome/browser/password_manager/update_password_infobar_delegate_andro id.h" | 5 #include "chrome/browser/password_manager/update_password_infobar_delegate_andro id.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 10 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 passwords_state_.set_client( | 75 passwords_state_.set_client( |
76 ChromePasswordManagerClient::FromWebContents(web_contents)); | 76 ChromePasswordManagerClient::FromWebContents(web_contents)); |
77 passwords_state_.OnUpdatePassword(std::move(form_to_update)); | 77 passwords_state_.OnUpdatePassword(std::move(form_to_update)); |
78 } | 78 } |
79 | 79 |
80 infobars::InfoBarDelegate::InfoBarIdentifier | 80 infobars::InfoBarDelegate::InfoBarIdentifier |
81 UpdatePasswordInfoBarDelegate::GetIdentifier() const { | 81 UpdatePasswordInfoBarDelegate::GetIdentifier() const { |
82 return UPDATE_PASSWORD_INFOBAR_DELEGATE; | 82 return UPDATE_PASSWORD_INFOBAR_DELEGATE; |
83 } | 83 } |
84 | 84 |
85 int UpdatePasswordInfoBarDelegate::GetButtons() const { | |
86 return BUTTON_OK; | |
87 } | |
88 | |
85 base::string16 UpdatePasswordInfoBarDelegate::GetButtonLabel( | 89 base::string16 UpdatePasswordInfoBarDelegate::GetButtonLabel( |
86 InfoBarButton button) const { | 90 InfoBarButton button) const { |
87 return l10n_util::GetStringUTF16((button == BUTTON_OK) | 91 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON); |
88 ? IDS_PASSWORD_MANAGER_UPDATE_BUTTON | |
89 : IDS_PASSWORD_MANAGER_CANCEL_BUTTON); | |
90 } | 92 } |
91 | 93 |
92 bool UpdatePasswordInfoBarDelegate::Accept() { | 94 bool UpdatePasswordInfoBarDelegate::Accept() { |
93 UpdatePasswordInfoBar* update_password_infobar = | 95 UpdatePasswordInfoBar* update_password_infobar = |
94 static_cast<UpdatePasswordInfoBar*>(infobar()); | 96 static_cast<UpdatePasswordInfoBar*>(infobar()); |
95 password_manager::PasswordFormManager* form_manager = | 97 password_manager::PasswordFormManager* form_manager = |
96 passwords_state_.form_manager(); | 98 passwords_state_.form_manager(); |
97 if (ShowMultipleAccounts()) { | 99 if (ShowMultipleAccounts()) { |
98 int form_index = update_password_infobar->GetIdOfSelectedUsername(); | 100 int form_index = update_password_infobar->GetIdOfSelectedUsername(); |
99 DCHECK_GE(form_index, 0); | 101 DCHECK_GE(form_index, 0); |
100 DCHECK_LT(static_cast<size_t>(form_index), GetCurrentForms().size()); | 102 DCHECK_LT(static_cast<size_t>(form_index), GetCurrentForms().size()); |
101 form_manager->Update(*GetCurrentForms()[form_index]); | 103 form_manager->Update(*GetCurrentForms()[form_index]); |
102 } else { | 104 } else { |
103 form_manager->Update(form_manager->pending_credentials()); | 105 form_manager->Update(form_manager->pending_credentials()); |
104 } | 106 } |
105 return true; | 107 return true; |
106 } | 108 } |
107 | 109 |
108 bool UpdatePasswordInfoBarDelegate::Cancel() { | 110 bool UpdatePasswordInfoBarDelegate::Cancel() { |
gone
2016/09/01 18:16:51
nit: You can get rid of this function; the default
dvadym
2016/09/02 11:53:39
Done.
| |
109 return true; | 111 return true; |
110 } | 112 } |
OLD | NEW |