| 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 "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" | 10 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 : ConfirmInfoBarDelegate(), | 91 : ConfirmInfoBarDelegate(), |
| 92 form_to_save_(form_to_save.Pass()), | 92 form_to_save_(form_to_save.Pass()), |
| 93 infobar_response_(password_manager::metrics_util::NO_RESPONSE), | 93 infobar_response_(password_manager::metrics_util::NO_RESPONSE), |
| 94 uma_histogram_suffix_(uma_histogram_suffix), | 94 uma_histogram_suffix_(uma_histogram_suffix), |
| 95 source_type_(source_type) { | 95 source_type_(source_type) { |
| 96 if (!uma_histogram_suffix_.empty()) { | 96 if (!uma_histogram_suffix_.empty()) { |
| 97 password_manager::metrics_util::LogUMAHistogramBoolean( | 97 password_manager::metrics_util::LogUMAHistogramBoolean( |
| 98 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, | 98 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, |
| 99 true); | 99 true); |
| 100 } | 100 } |
| 101 int brand_string_id = is_smartlock_branding_enabled | 101 title_link_range_ = gfx::Range(); |
| 102 ? IDS_PASSWORD_MANAGER_SMART_LOCK | 102 if (is_smartlock_branding_enabled) { |
| 103 : IDS_SAVE_PASSWORD_TITLE_BRAND; | 103 size_t offset = 0; |
| 104 title_ = l10n_util::GetStringFUTF16( | 104 base::string16 title_link = |
| 105 IDS_SAVE_PASSWORD, l10n_util::GetStringUTF16(brand_string_id)); | 105 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK); |
| 106 title_ = l10n_util::GetStringFUTF16(IDS_SAVE_PASSWORD, title_link, &offset); |
| 107 title_link_range_ = gfx::Range(offset, offset + title_link.length()); |
| 108 } else { |
| 109 title_ = l10n_util::GetStringFUTF16( |
| 110 IDS_SAVE_PASSWORD, |
| 111 l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_TITLE_BRAND)); |
| 112 } |
| 106 } | 113 } |
| 107 | 114 |
| 108 bool SavePasswordInfoBarDelegate::ShouldShowMoreButton() { | 115 bool SavePasswordInfoBarDelegate::ShouldShowMoreButton() { |
| 109 return source_type_ == | 116 return source_type_ == |
| 110 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API; | 117 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API; |
| 111 } | 118 } |
| 112 | 119 |
| 113 infobars::InfoBarDelegate::Type | 120 infobars::InfoBarDelegate::Type |
| 114 SavePasswordInfoBarDelegate::GetInfoBarType() const { | 121 SavePasswordInfoBarDelegate::GetInfoBarType() const { |
| 115 return PAGE_ACTION_TYPE; | 122 return PAGE_ACTION_TYPE; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 DCHECK(form_to_save_.get()); | 164 DCHECK(form_to_save_.get()); |
| 158 if (source_type_ == | 165 if (source_type_ == |
| 159 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API) { | 166 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API) { |
| 160 InfoBarDismissed(); | 167 InfoBarDismissed(); |
| 161 } else { | 168 } else { |
| 162 form_to_save_->PermanentlyBlacklist(); | 169 form_to_save_->PermanentlyBlacklist(); |
| 163 infobar_response_ = password_manager::metrics_util::NEVER_REMEMBER_PASSWORD; | 170 infobar_response_ = password_manager::metrics_util::NEVER_REMEMBER_PASSWORD; |
| 164 } | 171 } |
| 165 return true; | 172 return true; |
| 166 } | 173 } |
| 174 |
| 175 bool SavePasswordInfoBarDelegate::LinkClicked( |
| 176 WindowOpenDisposition disposition) { |
| 177 InfoBarService::WebContentsFromInfoBar(infobar()) |
| 178 ->OpenURL(content::OpenURLParams( |
| 179 GURL(l10n_util::GetStringUTF16( |
| 180 IDS_PASSWORD_MANAGER_SMART_LOCK_ARTICLE)), |
| 181 content::Referrer(), |
| 182 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 183 ui::PAGE_TRANSITION_LINK, false)); |
| 184 return true; |
| 185 } |
| OLD | NEW |