| OLD | NEW |
| 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 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" | 5 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/grit/chromium_strings.h" | 10 #include "chrome/grit/chromium_strings.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 form_to_save_(form_to_save.Pass()), | 85 form_to_save_(form_to_save.Pass()), |
| 86 infobar_response_(password_manager::metrics_util::NO_RESPONSE), | 86 infobar_response_(password_manager::metrics_util::NO_RESPONSE), |
| 87 uma_histogram_suffix_(uma_histogram_suffix) { | 87 uma_histogram_suffix_(uma_histogram_suffix) { |
| 88 if (!uma_histogram_suffix_.empty()) { | 88 if (!uma_histogram_suffix_.empty()) { |
| 89 password_manager::metrics_util::LogUMAHistogramBoolean( | 89 password_manager::metrics_util::LogUMAHistogramBoolean( |
| 90 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, | 90 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, |
| 91 true); | 91 true); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 infobars::InfoBarDelegate::InfoBarAutomationType |
| 96 SavePasswordInfoBarDelegate::GetInfoBarAutomationType() const { |
| 97 return PASSWORD_INFOBAR; |
| 98 } |
| 99 |
| 95 bool SavePasswordInfoBarDelegate::ShouldExpire( | 100 bool SavePasswordInfoBarDelegate::ShouldExpire( |
| 96 const NavigationDetails& details) const { | 101 const NavigationDetails& details) const { |
| 97 return !details.is_redirect && | 102 return !details.is_redirect && |
| 98 infobars::InfoBarDelegate::ShouldExpire(details); | 103 infobars::InfoBarDelegate::ShouldExpire(details); |
| 99 } | 104 } |
| 100 | 105 |
| 106 void SavePasswordInfoBarDelegate::InfoBarDismissed() { |
| 107 DCHECK(form_to_save_.get()); |
| 108 infobar_response_ = password_manager::metrics_util::INFOBAR_DISMISSED; |
| 109 } |
| 110 |
| 111 infobars::InfoBarDelegate::Type |
| 112 SavePasswordInfoBarDelegate::GetInfoBarType() const { |
| 113 return PAGE_ACTION_TYPE; |
| 114 } |
| 115 |
| 101 int SavePasswordInfoBarDelegate::GetIconID() const { | 116 int SavePasswordInfoBarDelegate::GetIconID() const { |
| 102 return IDR_INFOBAR_SAVE_PASSWORD; | 117 return IDR_INFOBAR_SAVE_PASSWORD; |
| 103 } | 118 } |
| 104 | 119 |
| 105 infobars::InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() | |
| 106 const { | |
| 107 return PAGE_ACTION_TYPE; | |
| 108 } | |
| 109 | |
| 110 base::string16 SavePasswordInfoBarDelegate::GetMessageText() const { | 120 base::string16 SavePasswordInfoBarDelegate::GetMessageText() const { |
| 111 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT); | 121 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT); |
| 112 } | 122 } |
| 113 | 123 |
| 114 base::string16 SavePasswordInfoBarDelegate::GetButtonLabel( | 124 base::string16 SavePasswordInfoBarDelegate::GetButtonLabel( |
| 115 InfoBarButton button) const { | 125 InfoBarButton button) const { |
| 116 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 126 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 117 IDS_PASSWORD_MANAGER_SAVE_BUTTON : IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON); | 127 IDS_PASSWORD_MANAGER_SAVE_BUTTON : IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON); |
| 118 } | 128 } |
| 119 | 129 |
| 120 bool SavePasswordInfoBarDelegate::Accept() { | 130 bool SavePasswordInfoBarDelegate::Accept() { |
| 121 DCHECK(form_to_save_.get()); | 131 DCHECK(form_to_save_.get()); |
| 122 form_to_save_->Save(); | 132 form_to_save_->Save(); |
| 123 infobar_response_ = password_manager::metrics_util::REMEMBER_PASSWORD; | 133 infobar_response_ = password_manager::metrics_util::REMEMBER_PASSWORD; |
| 124 return true; | 134 return true; |
| 125 } | 135 } |
| 126 | 136 |
| 127 bool SavePasswordInfoBarDelegate::Cancel() { | 137 bool SavePasswordInfoBarDelegate::Cancel() { |
| 128 DCHECK(form_to_save_.get()); | 138 DCHECK(form_to_save_.get()); |
| 129 form_to_save_->PermanentlyBlacklist(); | 139 form_to_save_->PermanentlyBlacklist(); |
| 130 infobar_response_ = password_manager::metrics_util::NEVER_REMEMBER_PASSWORD; | 140 infobar_response_ = password_manager::metrics_util::NEVER_REMEMBER_PASSWORD; |
| 131 return true; | 141 return true; |
| 132 } | 142 } |
| 133 | |
| 134 void SavePasswordInfoBarDelegate::InfoBarDismissed() { | |
| 135 DCHECK(form_to_save_.get()); | |
| 136 infobar_response_ = password_manager::metrics_util::INFOBAR_DISMISSED; | |
| 137 } | |
| 138 | |
| 139 infobars::InfoBarDelegate::InfoBarAutomationType | |
| 140 SavePasswordInfoBarDelegate::GetInfoBarAutomationType() const { | |
| 141 return PASSWORD_INFOBAR; | |
| 142 } | |
| OLD | NEW |