| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 password_bubble_experiment::ShouldShowSavePromptFirstRunExperience( | 37 password_bubble_experiment::ShouldShowSavePromptFirstRunExperience( |
| 38 sync_service, profile->GetPrefs()); | 38 sync_service, profile->GetPrefs()); |
| 39 InfoBarService::FromWebContents(web_contents) | 39 InfoBarService::FromWebContents(web_contents) |
| 40 ->AddInfoBar(CreateSavePasswordInfoBar(make_scoped_ptr( | 40 ->AddInfoBar(CreateSavePasswordInfoBar(make_scoped_ptr( |
| 41 new SavePasswordInfoBarDelegate(web_contents, std::move(form_to_save), | 41 new SavePasswordInfoBarDelegate(web_contents, std::move(form_to_save), |
| 42 is_smartlock_branding_enabled, | 42 is_smartlock_branding_enabled, |
| 43 should_show_first_run_experience)))); | 43 should_show_first_run_experience)))); |
| 44 } | 44 } |
| 45 | 45 |
| 46 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { | 46 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { |
| 47 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", | |
| 48 infobar_response_, | |
| 49 password_manager::metrics_util::NUM_RESPONSE_TYPES); | |
| 50 | |
| 51 password_manager::metrics_util::LogUIDismissalReason(infobar_response_); | 47 password_manager::metrics_util::LogUIDismissalReason(infobar_response_); |
| 52 | 48 |
| 53 if (should_show_first_run_experience_) { | 49 if (should_show_first_run_experience_) { |
| 54 Profile* profile = | 50 Profile* profile = |
| 55 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 51 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 56 password_bubble_experiment::RecordSavePromptFirstRunExperienceWasShown( | 52 password_bubble_experiment::RecordSavePromptFirstRunExperienceWasShown( |
| 57 profile->GetPrefs()); | 53 profile->GetPrefs()); |
| 58 } | 54 } |
| 59 } | 55 } |
| 60 | 56 |
| 61 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( | 57 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( |
| 62 content::WebContents* web_contents, | 58 content::WebContents* web_contents, |
| 63 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | 59 scoped_ptr<password_manager::PasswordFormManager> form_to_save, |
| 64 bool is_smartlock_branding_enabled, | 60 bool is_smartlock_branding_enabled, |
| 65 bool should_show_first_run_experience) | 61 bool should_show_first_run_experience) |
| 66 : PasswordManagerInfoBarDelegate(), | 62 : PasswordManagerInfoBarDelegate(), |
| 67 form_to_save_(std::move(form_to_save)), | 63 form_to_save_(std::move(form_to_save)), |
| 68 infobar_response_(password_manager::metrics_util::NO_RESPONSE), | 64 infobar_response_(password_manager::metrics_util::NO_DIRECT_INTERACTION), |
| 69 should_show_first_run_experience_(should_show_first_run_experience), | 65 should_show_first_run_experience_(should_show_first_run_experience), |
| 70 web_contents_(web_contents) { | 66 web_contents_(web_contents) { |
| 71 base::string16 message; | 67 base::string16 message; |
| 72 gfx::Range message_link_range = gfx::Range(); | 68 gfx::Range message_link_range = gfx::Range(); |
| 73 PasswordTittleType type = | 69 PasswordTittleType type = |
| 74 form_to_save_->pending_credentials().federation_origin.unique() | 70 form_to_save_->pending_credentials().federation_origin.unique() |
| 75 ? PasswordTittleType::SAVE_PASSWORD | 71 ? PasswordTittleType::SAVE_PASSWORD |
| 76 : PasswordTittleType::UPDATE_PASSWORD; | 72 : PasswordTittleType::UPDATE_PASSWORD; |
| 77 GetSavePasswordDialogTitleTextAndLinkRange( | 73 GetSavePasswordDialogTitleTextAndLinkRange( |
| 78 web_contents->GetVisibleURL(), form_to_save_->observed_form().origin, | 74 web_contents->GetVisibleURL(), form_to_save_->observed_form().origin, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 89 : base::string16(); | 85 : base::string16(); |
| 90 } | 86 } |
| 91 | 87 |
| 92 infobars::InfoBarDelegate::InfoBarIdentifier | 88 infobars::InfoBarDelegate::InfoBarIdentifier |
| 93 SavePasswordInfoBarDelegate::GetIdentifier() const { | 89 SavePasswordInfoBarDelegate::GetIdentifier() const { |
| 94 return SAVE_PASSWORD_INFOBAR_DELEGATE; | 90 return SAVE_PASSWORD_INFOBAR_DELEGATE; |
| 95 } | 91 } |
| 96 | 92 |
| 97 void SavePasswordInfoBarDelegate::InfoBarDismissed() { | 93 void SavePasswordInfoBarDelegate::InfoBarDismissed() { |
| 98 DCHECK(form_to_save_.get()); | 94 DCHECK(form_to_save_.get()); |
| 99 infobar_response_ = password_manager::metrics_util::INFOBAR_DISMISSED; | 95 infobar_response_ = password_manager::metrics_util::CLICKED_CANCEL; |
| 100 } | 96 } |
| 101 | 97 |
| 102 base::string16 SavePasswordInfoBarDelegate::GetButtonLabel( | 98 base::string16 SavePasswordInfoBarDelegate::GetButtonLabel( |
| 103 InfoBarButton button) const { | 99 InfoBarButton button) const { |
| 104 return l10n_util::GetStringUTF16((button == BUTTON_OK) | 100 return l10n_util::GetStringUTF16((button == BUTTON_OK) |
| 105 ? IDS_PASSWORD_MANAGER_SAVE_BUTTON | 101 ? IDS_PASSWORD_MANAGER_SAVE_BUTTON |
| 106 : IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON); | 102 : IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON); |
| 107 } | 103 } |
| 108 | 104 |
| 109 bool SavePasswordInfoBarDelegate::Accept() { | 105 bool SavePasswordInfoBarDelegate::Accept() { |
| 110 DCHECK(form_to_save_.get()); | 106 DCHECK(form_to_save_.get()); |
| 111 form_to_save_->Save(); | 107 form_to_save_->Save(); |
| 112 infobar_response_ = password_manager::metrics_util::REMEMBER_PASSWORD; | 108 infobar_response_ = password_manager::metrics_util::CLICKED_SAVE; |
| 113 return true; | 109 return true; |
| 114 } | 110 } |
| 115 | 111 |
| 116 bool SavePasswordInfoBarDelegate::Cancel() { | 112 bool SavePasswordInfoBarDelegate::Cancel() { |
| 117 DCHECK(form_to_save_.get()); | 113 DCHECK(form_to_save_.get()); |
| 118 form_to_save_->PermanentlyBlacklist(); | 114 form_to_save_->PermanentlyBlacklist(); |
| 119 infobar_response_ = password_manager::metrics_util::NEVER_REMEMBER_PASSWORD; | 115 infobar_response_ = password_manager::metrics_util::CLICKED_NEVER; |
| 120 return true; | 116 return true; |
| 121 } | 117 } |
| OLD | NEW |