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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 69 |
| 68 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; | 70 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; |
| 69 | 71 |
| 70 // The PasswordFormManager managing the form we're asking the user about, | 72 // The PasswordFormManager managing the form we're asking the user about, |
| 71 // and should update as per her decision. | 73 // and should update as per her decision. |
| 72 scoped_ptr<PasswordFormManager> form_to_save_; | 74 scoped_ptr<PasswordFormManager> form_to_save_; |
| 73 | 75 |
| 74 // Used to track the results we get from the info bar. | 76 // Used to track the results we get from the info bar. |
| 75 ResponseType infobar_response_; | 77 ResponseType infobar_response_; |
| 76 | 78 |
| 79 // Save password prompt lifetime needed for a UMA signal. | |
| 80 PerfTimer timer_; | |
| 81 | |
| 82 // The domain name of the current webpage. This variable is used for UMA | |
| 83 // signals. | |
|
Ilya Sherman
2013/08/29 06:42:21
This comment doesn't fully reflect the use of the
jdomingos
2013/08/30 21:09:20
Done.
| |
| 84 std::string domain_name_; | |
| 85 | |
| 77 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); | 86 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); |
| 78 }; | 87 }; |
| 79 | 88 |
| 80 // static | 89 // static |
| 81 void SavePasswordInfoBarDelegate::Create(content::WebContents* web_contents, | 90 void SavePasswordInfoBarDelegate::Create(content::WebContents* web_contents, |
| 82 PasswordFormManager* form_to_save) { | 91 PasswordFormManager* form_to_save) { |
| 83 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 92 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 84 // Don't show the password manager infobar if this form is for a google | 93 // 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. | 94 // account and we are going to show the one-click signin infobar. |
| 86 GURL realm(form_to_save->realm()); | 95 GURL realm(form_to_save->realm()); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 99 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 108 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
| 100 new SavePasswordInfoBarDelegate(infobar_service, form_to_save))); | 109 new SavePasswordInfoBarDelegate(infobar_service, form_to_save))); |
| 101 } | 110 } |
| 102 | 111 |
| 103 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( | 112 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( |
| 104 InfoBarService* infobar_service, | 113 InfoBarService* infobar_service, |
| 105 PasswordFormManager* form_to_save) | 114 PasswordFormManager* form_to_save) |
| 106 : ConfirmInfoBarDelegate(infobar_service), | 115 : ConfirmInfoBarDelegate(infobar_service), |
| 107 form_to_save_(form_to_save), | 116 form_to_save_(form_to_save), |
| 108 infobar_response_(NO_RESPONSE) { | 117 infobar_response_(NO_RESPONSE) { |
| 118 password_manager_util::IsDomainNameMonitored(form_to_save->realm(), | |
| 119 &domain_name_); | |
| 120 if (domain_name_.size()) | |
| 121 domain_name_.insert(0, "_"); | |
| 122 UMA_HISTOGRAM_BOOLEAN("PasswordManager.InfobarDisplayed" + domain_name_, | |
| 123 true); | |
|
Ilya Sherman
2013/08/29 06:42:21
This will not work, for the reasons that the other
Ilya Sherman
2013/08/29 06:42:21
This is a little strange, because it causes the me
jdomingos
2013/08/30 21:09:20
Hi Ilya,
Indeed regarding the PasswordManager.Inf
jdomingos
2013/08/30 21:09:20
Done.
| |
| 109 } | 124 } |
| 110 | 125 |
| 111 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { | 126 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { |
| 127 // Time which allows us to consider that the info bar has been | |
| 128 // displayed during enough time for the user to make a decision. | |
|
Ilya Sherman
2013/08/29 06:42:21
I don't understand what this comment means. Could
jdomingos
2013/08/30 21:09:20
The comment here was for a previous variable which
| |
| 112 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", | 129 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", |
| 113 infobar_response_, NUM_RESPONSE_TYPES); | 130 infobar_response_, NUM_RESPONSE_TYPES); |
| 131 UMA_HISTOGRAM_TIMES( | |
| 132 "PasswordManager.InfobarLifetime" + domain_name_, | |
|
Ilya Sherman
2013/08/29 06:42:21
As above, you'll need to inline the macro, because
Ilya Sherman
2013/08/29 06:42:21
As above, it's strange that the un-suffixed Passwo
jdomingos
2013/08/30 21:09:20
You are right, as above this is not the expected b
jdomingos
2013/08/30 21:09:20
Done.
| |
| 133 timer_.Elapsed()); | |
| 114 } | 134 } |
| 115 | 135 |
| 116 int SavePasswordInfoBarDelegate::GetIconID() const { | 136 int SavePasswordInfoBarDelegate::GetIconID() const { |
| 117 return IDR_INFOBAR_SAVE_PASSWORD; | 137 return IDR_INFOBAR_SAVE_PASSWORD; |
| 118 } | 138 } |
| 119 | 139 |
| 120 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { | 140 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { |
| 121 return PAGE_ACTION_TYPE; | 141 return PAGE_ACTION_TYPE; |
| 122 } | 142 } |
| 123 | 143 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { | 203 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { |
| 184 content::NavigationEntry* entry = | 204 content::NavigationEntry* entry = |
| 185 web_contents_->GetController().GetActiveEntry(); | 205 web_contents_->GetController().GetActiveEntry(); |
| 186 if (!entry) { | 206 if (!entry) { |
| 187 NOTREACHED(); | 207 NOTREACHED(); |
| 188 return false; | 208 return false; |
| 189 } | 209 } |
| 190 | 210 |
| 191 return net::IsCertStatusError(entry->GetSSL().cert_status); | 211 return net::IsCertStatusError(entry->GetSSL().cert_status); |
| 192 } | 212 } |
| OLD | NEW |