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/string_number_conversions.h" | |
9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/test/perftimer.h" | |
10 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 12 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
11 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "chrome/browser/password_manager/password_form_manager.h" | 14 #include "chrome/browser/password_manager/password_form_manager.h" |
13 #include "chrome/browser/password_manager/password_manager.h" | 15 #include "chrome/browser/password_manager/password_manager.h" |
16 #include "chrome/browser/password_manager/password_manager_metrics_util.h" | |
14 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 18 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
16 #include "components/autofill/content/browser/autofill_driver_impl.h" | 19 #include "components/autofill/content/browser/autofill_driver_impl.h" |
17 #include "components/autofill/core/browser/autofill_manager.h" | 20 #include "components/autofill/core/browser/autofill_manager.h" |
18 #include "components/autofill/core/common/autofill_messages.h" | 21 #include "components/autofill/core/common/autofill_messages.h" |
19 #include "components/autofill/core/common/password_form.h" | 22 #include "components/autofill/core/common/password_form.h" |
20 #include "content/public/browser/navigation_entry.h" | 23 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
22 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/ssl_status.h" | 26 #include "content/public/common/ssl_status.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 | 70 |
68 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; | 71 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; |
69 | 72 |
70 // The PasswordFormManager managing the form we're asking the user about, | 73 // The PasswordFormManager managing the form we're asking the user about, |
71 // and should update as per her decision. | 74 // and should update as per her decision. |
72 scoped_ptr<PasswordFormManager> form_to_save_; | 75 scoped_ptr<PasswordFormManager> form_to_save_; |
73 | 76 |
74 // Used to track the results we get from the info bar. | 77 // Used to track the results we get from the info bar. |
75 ResponseType infobar_response_; | 78 ResponseType infobar_response_; |
76 | 79 |
80 // Save password prompt lifetime needed for a UMA signal. | |
81 PerfTimer timer_; | |
82 | |
83 // The group name corresponding to the domain name of | |
84 // |form_to_save_| if the form is on a monitored domain. | |
85 // Otherwise, an empty string. | |
86 std::string uma_histogram_suffix_; | |
87 | |
77 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); | 88 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); |
78 }; | 89 }; |
79 | 90 |
80 // static | 91 // static |
81 void SavePasswordInfoBarDelegate::Create(content::WebContents* web_contents, | 92 void SavePasswordInfoBarDelegate::Create(content::WebContents* web_contents, |
82 PasswordFormManager* form_to_save) { | 93 PasswordFormManager* form_to_save) { |
83 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 94 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
84 // Don't show the password manager infobar if this form is for a google | 95 // Don't show the password manager infobar if this form is for a google |
85 // account and we are going to show the one-click signin infobar. | 96 // account and we are going to show the one-click signin infobar. |
86 GURL realm(form_to_save->realm()); | 97 GURL realm(form_to_save->realm()); |
(...skipping 12 matching lines...) Expand all Loading... | |
99 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 110 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
100 new SavePasswordInfoBarDelegate(infobar_service, form_to_save))); | 111 new SavePasswordInfoBarDelegate(infobar_service, form_to_save))); |
101 } | 112 } |
102 | 113 |
103 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( | 114 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( |
104 InfoBarService* infobar_service, | 115 InfoBarService* infobar_service, |
105 PasswordFormManager* form_to_save) | 116 PasswordFormManager* form_to_save) |
106 : ConfirmInfoBarDelegate(infobar_service), | 117 : ConfirmInfoBarDelegate(infobar_service), |
107 form_to_save_(form_to_save), | 118 form_to_save_(form_to_save), |
108 infobar_response_(NO_RESPONSE) { | 119 infobar_response_(NO_RESPONSE) { |
120 uma_histogram_suffix_ = password_manager_metrics_util::MonitoredDomainGroup( | |
vabr (Chromium)
2013/09/11 17:31:24
nit: this could be done in the initialiser list:
jdomingos
2013/09/11 19:15:28
Done.
| |
121 form_to_save->realm()); | |
122 if (!uma_histogram_suffix_.empty()) { | |
123 int group_number = 0; | |
124 std::string string_group_number = | |
125 uma_histogram_suffix_.substr(uma_histogram_suffix_.find("_") + 1); | |
126 | |
127 if (!base::StringToInt(string_group_number, &group_number)) | |
vabr (Chromium)
2013/09/11 17:31:24
You have just written an int to a string in Monito
jdomingos
2013/09/11 19:15:28
Done.
| |
128 return; | |
129 password_manager_metrics_util::LogUMAHistogramCounts( | |
130 "PasswordManager.SavePasswordPromptDisplayed", | |
131 group_number); | |
132 } | |
109 } | 133 } |
110 | 134 |
111 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { | 135 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { |
112 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", | 136 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", |
113 infobar_response_, NUM_RESPONSE_TYPES); | 137 infobar_response_, NUM_RESPONSE_TYPES); |
138 // Time which allows us to consider that the info bar has been | |
139 // displayed during enough time for the user to make a decision. | |
vabr (Chromium)
2013/09/11 17:31:24
This is not grammatically correct, and could me mo
jdomingos
2013/09/11 19:15:28
Done.
| |
140 const int kTime = 1000; | |
141 | |
142 if (!uma_histogram_suffix_.empty()) { | |
143 password_manager_metrics_util::LogUMAHistogramEnumeration( | |
144 "PasswordManager.SavePasswordPromptResponse_" + uma_histogram_suffix_, | |
145 infobar_response_, NUM_RESPONSE_TYPES); | |
146 password_manager_metrics_util::LogUMAHistogramBoolean( | |
147 "PasswordManager.SavePasswordPromptDisappearedQuickly" + | |
148 uma_histogram_suffix_, | |
149 timer_.Elapsed().InMilliseconds() < kTime); | |
150 } | |
114 } | 151 } |
115 | 152 |
116 int SavePasswordInfoBarDelegate::GetIconID() const { | 153 int SavePasswordInfoBarDelegate::GetIconID() const { |
117 return IDR_INFOBAR_SAVE_PASSWORD; | 154 return IDR_INFOBAR_SAVE_PASSWORD; |
118 } | 155 } |
119 | 156 |
120 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { | 157 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { |
121 return PAGE_ACTION_TYPE; | 158 return PAGE_ACTION_TYPE; |
122 } | 159 } |
123 | 160 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { | 220 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { |
184 content::NavigationEntry* entry = | 221 content::NavigationEntry* entry = |
185 web_contents_->GetController().GetActiveEntry(); | 222 web_contents_->GetController().GetActiveEntry(); |
186 if (!entry) { | 223 if (!entry) { |
187 NOTREACHED(); | 224 NOTREACHED(); |
188 return false; | 225 return false; |
189 } | 226 } |
190 | 227 |
191 return net::IsCertStatusError(entry->GetSSL().cert_status); | 228 return net::IsCertStatusError(entry->GetSSL().cert_status); |
192 } | 229 } |
OLD | NEW |