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 <utility> |
| 8 |
7 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sync/profile_sync_service_factory.h" | 12 #include "chrome/browser/sync/profile_sync_service_factory.h" |
11 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | 13 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
12 #include "chrome/grit/chromium_strings.h" | 14 #include "chrome/grit/chromium_strings.h" |
13 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
14 #include "components/browser_sync/browser/profile_sync_service.h" | 16 #include "components/browser_sync/browser/profile_sync_service.h" |
15 #include "components/infobars/core/infobar.h" | 17 #include "components/infobars/core/infobar.h" |
16 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 18 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
(...skipping 21 matching lines...) Expand all Loading... |
38 sync_driver::SyncService* sync_service = | 40 sync_driver::SyncService* sync_service = |
39 ProfileSyncServiceFactory::GetForProfile(profile); | 41 ProfileSyncServiceFactory::GetForProfile(profile); |
40 bool is_smartlock_branding_enabled = | 42 bool is_smartlock_branding_enabled = |
41 password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service); | 43 password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service); |
42 bool should_show_first_run_experience = | 44 bool should_show_first_run_experience = |
43 password_bubble_experiment::ShouldShowSavePromptFirstRunExperience( | 45 password_bubble_experiment::ShouldShowSavePromptFirstRunExperience( |
44 sync_service, profile->GetPrefs()); | 46 sync_service, profile->GetPrefs()); |
45 InfoBarService::FromWebContents(web_contents) | 47 InfoBarService::FromWebContents(web_contents) |
46 ->AddInfoBar(CreateSavePasswordInfoBar( | 48 ->AddInfoBar(CreateSavePasswordInfoBar( |
47 make_scoped_ptr(new SavePasswordInfoBarDelegate( | 49 make_scoped_ptr(new SavePasswordInfoBarDelegate( |
48 web_contents, form_to_save.Pass(), uma_histogram_suffix, | 50 web_contents, std::move(form_to_save), uma_histogram_suffix, |
49 source_type, is_smartlock_branding_enabled, | 51 source_type, is_smartlock_branding_enabled, |
50 should_show_first_run_experience)))); | 52 should_show_first_run_experience)))); |
51 } | 53 } |
52 | 54 |
53 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { | 55 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { |
54 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", | 56 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", |
55 infobar_response_, | 57 infobar_response_, |
56 password_manager::metrics_util::NUM_RESPONSE_TYPES); | 58 password_manager::metrics_util::NUM_RESPONSE_TYPES); |
57 | 59 |
58 password_manager::metrics_util::LogUIDismissalReason(infobar_response_); | 60 password_manager::metrics_util::LogUIDismissalReason(infobar_response_); |
(...skipping 23 matching lines...) Expand all Loading... |
82 } | 84 } |
83 | 85 |
84 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( | 86 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( |
85 content::WebContents* web_contents, | 87 content::WebContents* web_contents, |
86 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | 88 scoped_ptr<password_manager::PasswordFormManager> form_to_save, |
87 const std::string& uma_histogram_suffix, | 89 const std::string& uma_histogram_suffix, |
88 password_manager::CredentialSourceType source_type, | 90 password_manager::CredentialSourceType source_type, |
89 bool is_smartlock_branding_enabled, | 91 bool is_smartlock_branding_enabled, |
90 bool should_show_first_run_experience) | 92 bool should_show_first_run_experience) |
91 : PasswordManagerInfoBarDelegate(), | 93 : PasswordManagerInfoBarDelegate(), |
92 form_to_save_(form_to_save.Pass()), | 94 form_to_save_(std::move(form_to_save)), |
93 infobar_response_(password_manager::metrics_util::NO_RESPONSE), | 95 infobar_response_(password_manager::metrics_util::NO_RESPONSE), |
94 uma_histogram_suffix_(uma_histogram_suffix), | 96 uma_histogram_suffix_(uma_histogram_suffix), |
95 source_type_(source_type), | 97 source_type_(source_type), |
96 should_show_first_run_experience_(should_show_first_run_experience), | 98 should_show_first_run_experience_(should_show_first_run_experience), |
97 web_contents_(web_contents) { | 99 web_contents_(web_contents) { |
98 if (!uma_histogram_suffix_.empty()) { | 100 if (!uma_histogram_suffix_.empty()) { |
99 password_manager::metrics_util::LogUMAHistogramBoolean( | 101 password_manager::metrics_util::LogUMAHistogramBoolean( |
100 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, | 102 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, |
101 true); | 103 true); |
102 } | 104 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 infobar_response_ = password_manager::metrics_util::REMEMBER_PASSWORD; | 141 infobar_response_ = password_manager::metrics_util::REMEMBER_PASSWORD; |
140 return true; | 142 return true; |
141 } | 143 } |
142 | 144 |
143 bool SavePasswordInfoBarDelegate::Cancel() { | 145 bool SavePasswordInfoBarDelegate::Cancel() { |
144 DCHECK(form_to_save_.get()); | 146 DCHECK(form_to_save_.get()); |
145 form_to_save_->PermanentlyBlacklist(); | 147 form_to_save_->PermanentlyBlacklist(); |
146 infobar_response_ = password_manager::metrics_util::NEVER_REMEMBER_PASSWORD; | 148 infobar_response_ = password_manager::metrics_util::NEVER_REMEMBER_PASSWORD; |
147 return true; | 149 return true; |
148 } | 150 } |
OLD | NEW |