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 21 matching lines...) Expand all Loading... | |
| 45 static void Create(content::WebContents* web_contents, | 47 static void Create(content::WebContents* web_contents, |
| 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 }; |
| 57 PerfTimer timer_; | |
|
vabr (Chromium)
2013/08/28 15:49:45
As Garrett pointed out, these variables should be
| |
| 58 std::string domain_name_; | |
| 55 | 59 |
| 56 SavePasswordInfoBarDelegate(InfoBarService* infobar_service, | 60 SavePasswordInfoBarDelegate(InfoBarService* infobar_service, |
| 57 PasswordFormManager* form_to_save); | 61 PasswordFormManager* form_to_save); |
| 58 virtual ~SavePasswordInfoBarDelegate(); | 62 virtual ~SavePasswordInfoBarDelegate(); |
| 59 | 63 |
| 60 // ConfirmInfoBarDelegate | 64 // ConfirmInfoBarDelegate |
| 61 virtual int GetIconID() const OVERRIDE; | 65 virtual int GetIconID() const OVERRIDE; |
| 62 virtual Type GetInfoBarType() const OVERRIDE; | 66 virtual Type GetInfoBarType() const OVERRIDE; |
| 63 virtual string16 GetMessageText() const OVERRIDE; | 67 virtual string16 GetMessageText() const OVERRIDE; |
| 64 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 68 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 103 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
| 100 new SavePasswordInfoBarDelegate(infobar_service, form_to_save))); | 104 new SavePasswordInfoBarDelegate(infobar_service, form_to_save))); |
| 101 } | 105 } |
| 102 | 106 |
| 103 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( | 107 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( |
| 104 InfoBarService* infobar_service, | 108 InfoBarService* infobar_service, |
| 105 PasswordFormManager* form_to_save) | 109 PasswordFormManager* form_to_save) |
| 106 : ConfirmInfoBarDelegate(infobar_service), | 110 : ConfirmInfoBarDelegate(infobar_service), |
| 107 form_to_save_(form_to_save), | 111 form_to_save_(form_to_save), |
| 108 infobar_response_(NO_RESPONSE) { | 112 infobar_response_(NO_RESPONSE) { |
| 113 password_manager_util::IsDomainNameMonitored(form_to_save->realm(), | |
| 114 &domain_name_); | |
| 115 if (domain_name_.size()) | |
| 116 domain_name_.insert(0, "_"); | |
| 117 UMA_HISTOGRAM_BOOLEAN("PasswordManager.InfobarDisplayed" + domain_name_, | |
| 118 true); | |
| 109 } | 119 } |
| 110 | 120 |
| 111 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { | 121 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { |
| 122 // Time which allows us to consider that the info bar has been | |
| 123 // displayed during enough time for the user to make a decision. | |
| 124 const int kTime = 1000; | |
| 112 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", | 125 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", |
| 113 infobar_response_, NUM_RESPONSE_TYPES); | 126 infobar_response_, NUM_RESPONSE_TYPES); |
| 127 UMA_HISTOGRAM_BOOLEAN( | |
| 128 "PasswordManager.InfobarDisappearedQuickly" + domain_name_, | |
|
vabr (Chromium)
2013/08/28 15:49:45
I really liked Garrett's proposal to make this a U
| |
| 129 timer_.Elapsed().InMilliseconds() < kTime); | |
| 114 } | 130 } |
| 115 | 131 |
| 116 int SavePasswordInfoBarDelegate::GetIconID() const { | 132 int SavePasswordInfoBarDelegate::GetIconID() const { |
| 117 return IDR_INFOBAR_SAVE_PASSWORD; | 133 return IDR_INFOBAR_SAVE_PASSWORD; |
| 118 } | 134 } |
| 119 | 135 |
| 120 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { | 136 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { |
| 121 return PAGE_ACTION_TYPE; | 137 return PAGE_ACTION_TYPE; |
| 122 } | 138 } |
| 123 | 139 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { | 199 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { |
| 184 content::NavigationEntry* entry = | 200 content::NavigationEntry* entry = |
| 185 web_contents_->GetController().GetActiveEntry(); | 201 web_contents_->GetController().GetActiveEntry(); |
| 186 if (!entry) { | 202 if (!entry) { |
| 187 NOTREACHED(); | 203 NOTREACHED(); |
| 188 return false; | 204 return false; |
| 189 } | 205 } |
| 190 | 206 |
| 191 return net::IsCertStatusError(entry->GetSSL().cert_status); | 207 return net::IsCertStatusError(entry->GetSSL().cert_status); |
| 192 } | 208 } |
| OLD | NEW |