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/sync/profile_sync_service.h" | 10 #include "chrome/browser/sync/profile_sync_service.h" |
11 #include "chrome/browser/sync/profile_sync_service_factory.h" | 11 #include "chrome/browser/sync/profile_sync_service_factory.h" |
12 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | 12 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
13 #include "chrome/grit/chromium_strings.h" | 13 #include "chrome/grit/chromium_strings.h" |
14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
15 #include "components/infobars/core/infobar.h" | 15 #include "components/infobars/core/infobar.h" |
16 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 16 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
17 #include "components/password_manager/core/browser/password_manager_client.h" | 17 #include "components/password_manager/core/browser/password_manager_client.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 int GetCancelButtonText(password_manager::CredentialSourceType source_type) { | 24 int GetCancelButtonText(password_manager::CredentialSourceType source_type) { |
25 return source_type == | 25 return IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON; |
26 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API | |
27 ? IDS_PASSWORD_MANAGER_SAVE_PASSWORD_SMART_LOCK_NO_THANKS_BUTTON | |
28 : IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON; | |
29 } | 26 } |
30 | 27 |
31 } // namespace | 28 } // namespace |
32 | 29 |
33 // static | 30 // static |
34 void SavePasswordInfoBarDelegate::Create( | 31 void SavePasswordInfoBarDelegate::Create( |
35 content::WebContents* web_contents, | 32 content::WebContents* web_contents, |
36 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | 33 scoped_ptr<password_manager::PasswordFormManager> form_to_save, |
37 const std::string& uma_histogram_suffix, | 34 const std::string& uma_histogram_suffix, |
38 password_manager::CredentialSourceType source_type) { | 35 password_manager::CredentialSourceType source_type) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 130 |
134 bool SavePasswordInfoBarDelegate::Accept() { | 131 bool SavePasswordInfoBarDelegate::Accept() { |
135 DCHECK(form_to_save_.get()); | 132 DCHECK(form_to_save_.get()); |
136 form_to_save_->Save(); | 133 form_to_save_->Save(); |
137 infobar_response_ = password_manager::metrics_util::REMEMBER_PASSWORD; | 134 infobar_response_ = password_manager::metrics_util::REMEMBER_PASSWORD; |
138 return true; | 135 return true; |
139 } | 136 } |
140 | 137 |
141 bool SavePasswordInfoBarDelegate::Cancel() { | 138 bool SavePasswordInfoBarDelegate::Cancel() { |
142 DCHECK(form_to_save_.get()); | 139 DCHECK(form_to_save_.get()); |
143 if (source_type_ == | 140 form_to_save_->PermanentlyBlacklist(); |
144 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API) { | 141 infobar_response_ = password_manager::metrics_util::NEVER_REMEMBER_PASSWORD; |
145 InfoBarDismissed(); | |
146 } else { | |
147 form_to_save_->PermanentlyBlacklist(); | |
148 infobar_response_ = password_manager::metrics_util::NEVER_REMEMBER_PASSWORD; | |
149 } | |
150 return true; | 142 return true; |
151 } | 143 } |
OLD | NEW |