Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/password_manager_delegate_impl.h" | 5 #include "chrome/browser/password_manager/password_manager_delegate_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/test/perftimer.h" | |
| 10 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/password_manager/password_form_manager.h" | 13 #include "chrome/browser/password_manager/password_form_manager.h" |
| 13 #include "chrome/browser/password_manager/password_manager.h" | 14 #include "chrome/browser/password_manager/password_manager.h" |
| 15 #include "chrome/browser/password_manager/password_manager_util.h" | |
| 14 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 17 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 16 #include "components/autofill/content/browser/autofill_driver_impl.h" | 18 #include "components/autofill/content/browser/autofill_driver_impl.h" |
| 17 #include "components/autofill/core/browser/autofill_manager.h" | 19 #include "components/autofill/core/browser/autofill_manager.h" |
| 18 #include "components/autofill/core/common/autofill_messages.h" | 20 #include "components/autofill/core/common/autofill_messages.h" |
| 19 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
| 20 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/password_form.h" | 24 #include "content/public/common/password_form.h" |
| 23 #include "content/public/common/ssl_status.h" | 25 #include "content/public/common/ssl_status.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 46 PasswordFormManager* form_to_save); | 48 PasswordFormManager* form_to_save); |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 enum ResponseType { | 51 enum ResponseType { |
| 50 NO_RESPONSE = 0, | 52 NO_RESPONSE = 0, |
| 51 REMEMBER_PASSWORD, | 53 REMEMBER_PASSWORD, |
| 52 DONT_REMEMBER_PASSWORD, | 54 DONT_REMEMBER_PASSWORD, |
| 53 NUM_RESPONSE_TYPES, | 55 NUM_RESPONSE_TYPES, |
| 54 }; | 56 }; |
| 55 | 57 |
| 58 PerfTimer timer_; | |
|
Garrett Casto
2013/08/28 01:09:17
These should be grouped with the other password me
| |
| 59 | |
| 60 std::string domain_name_; | |
| 61 | |
| 56 SavePasswordInfoBarDelegate(InfoBarService* infobar_service, | 62 SavePasswordInfoBarDelegate(InfoBarService* infobar_service, |
| 57 PasswordFormManager* form_to_save); | 63 PasswordFormManager* form_to_save); |
| 58 virtual ~SavePasswordInfoBarDelegate(); | 64 virtual ~SavePasswordInfoBarDelegate(); |
| 59 | 65 |
| 60 // ConfirmInfoBarDelegate | 66 // ConfirmInfoBarDelegate |
| 61 virtual int GetIconID() const OVERRIDE; | 67 virtual int GetIconID() const OVERRIDE; |
| 62 virtual Type GetInfoBarType() const OVERRIDE; | 68 virtual Type GetInfoBarType() const OVERRIDE; |
| 63 virtual string16 GetMessageText() const OVERRIDE; | 69 virtual string16 GetMessageText() const OVERRIDE; |
| 64 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 70 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 65 virtual bool Accept() OVERRIDE; | 71 virtual bool Accept() OVERRIDE; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 105 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
| 100 new SavePasswordInfoBarDelegate(infobar_service, form_to_save))); | 106 new SavePasswordInfoBarDelegate(infobar_service, form_to_save))); |
| 101 } | 107 } |
| 102 | 108 |
| 103 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( | 109 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( |
| 104 InfoBarService* infobar_service, | 110 InfoBarService* infobar_service, |
| 105 PasswordFormManager* form_to_save) | 111 PasswordFormManager* form_to_save) |
| 106 : ConfirmInfoBarDelegate(infobar_service), | 112 : ConfirmInfoBarDelegate(infobar_service), |
| 107 form_to_save_(form_to_save), | 113 form_to_save_(form_to_save), |
| 108 infobar_response_(NO_RESPONSE) { | 114 infobar_response_(NO_RESPONSE) { |
| 115 PasswordManagerUtil::IsDomainNameMonitored(form_to_save->realm(), | |
| 116 domain_name_); | |
| 117 if (domain_name_.size()) | |
| 118 domain_name_.insert(0, "_"); | |
| 119 UMA_HISTOGRAM_BOOLEAN("PasswordManager.InfobarDisplayed" + domain_name_, | |
| 120 true); | |
| 109 } | 121 } |
| 110 | 122 |
| 111 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { | 123 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { |
| 124 // Time which allows us to consider that the info bar has been | |
| 125 // displayed during enough time for the user to make a decision. | |
| 126 const int kTime = 1000; | |
| 112 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", | 127 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", |
| 113 infobar_response_, NUM_RESPONSE_TYPES); | 128 infobar_response_, NUM_RESPONSE_TYPES); |
| 129 UMA_HISTOGRAM_BOOLEAN( | |
| 130 "PasswordManager.InfobarDislayedTooShortly" + domain_name_, | |
|
Garrett Casto
2013/08/28 01:09:17
This seems like it would be better as a histogram
| |
| 131 timer_.Elapsed().InMilliseconds() < kTime); | |
| 114 } | 132 } |
| 115 | 133 |
| 116 int SavePasswordInfoBarDelegate::GetIconID() const { | 134 int SavePasswordInfoBarDelegate::GetIconID() const { |
| 117 return IDR_INFOBAR_SAVE_PASSWORD; | 135 return IDR_INFOBAR_SAVE_PASSWORD; |
| 118 } | 136 } |
| 119 | 137 |
| 120 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { | 138 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { |
| 121 return PAGE_ACTION_TYPE; | 139 return PAGE_ACTION_TYPE; |
| 122 } | 140 } |
| 123 | 141 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { | 201 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { |
| 184 content::NavigationEntry* entry = | 202 content::NavigationEntry* entry = |
| 185 web_contents_->GetController().GetActiveEntry(); | 203 web_contents_->GetController().GetActiveEntry(); |
| 186 if (!entry) { | 204 if (!entry) { |
| 187 NOTREACHED(); | 205 NOTREACHED(); |
| 188 return false; | 206 return false; |
| 189 } | 207 } |
| 190 | 208 |
| 191 return net::IsCertStatusError(entry->GetSSL().cert_status); | 209 return net::IsCertStatusError(entry->GetSSL().cert_status); |
| 192 } | 210 } |
| OLD | NEW |