Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: components/password_manager/content/browser/credential_manager_impl.cc

Issue 2293443002: Implement logging of the Credential Manager API calls to chrome://password-manager-internals. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/password_manager/content/browser/credential_manager_impl.h" 5 #include "components/password_manager/content/browser/credential_manager_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/user_metrics.h" 10 #include "base/metrics/user_metrics.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "components/autofill/core/common/password_form.h" 13 #include "components/autofill/core/common/password_form.h"
14 #include "components/password_manager/content/browser/content_password_manager_d river.h" 14 #include "components/password_manager/content/browser/content_password_manager_d river.h"
15 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h" 15 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h"
16 #include "components/password_manager/core/browser/affiliated_match_helper.h" 16 #include "components/password_manager/core/browser/affiliated_match_helper.h"
17 #include "components/password_manager/core/browser/credential_manager_logger.h"
17 #include "components/password_manager/core/browser/password_manager_client.h" 18 #include "components/password_manager/core/browser/password_manager_client.h"
18 #include "components/password_manager/core/browser/password_store.h" 19 #include "components/password_manager/core/browser/password_store.h"
19 #include "components/password_manager/core/common/credential_manager_types.h" 20 #include "components/password_manager/core/common/credential_manager_types.h"
20 #include "components/password_manager/core/common/password_manager_pref_names.h" 21 #include "components/password_manager/core/common/password_manager_pref_names.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 23
23 namespace password_manager { 24 namespace password_manager {
24 25
25 namespace { 26 namespace {
26 27
(...skipping 18 matching lines...) Expand all
45 46
46 void CredentialManagerImpl::BindRequest( 47 void CredentialManagerImpl::BindRequest(
47 mojom::CredentialManagerRequest request) { 48 mojom::CredentialManagerRequest request) {
48 bindings_.AddBinding(this, std::move(request)); 49 bindings_.AddBinding(this, std::move(request));
49 } 50 }
50 51
51 void CredentialManagerImpl::Store(const CredentialInfo& credential, 52 void CredentialManagerImpl::Store(const CredentialInfo& credential,
52 const StoreCallback& callback) { 53 const StoreCallback& callback) {
53 DCHECK_NE(CredentialType::CREDENTIAL_TYPE_EMPTY, credential.type); 54 DCHECK_NE(CredentialType::CREDENTIAL_TYPE_EMPTY, credential.type);
54 55
56 CredentialManagerLogger(client_->GetLogManager())
vabr (Chromium) 2016/08/29 13:10:44 For all the current logging the code checks LogMan
vasilii 2016/08/29 15:12:39 Done.
57 .LogStoreCredential(web_contents()->GetLastCommittedURL(),
58 credential.type);
59
55 // Send acknowledge response back. 60 // Send acknowledge response back.
56 callback.Run(); 61 callback.Run();
57 62
58 if (!client_->IsSavingAndFillingEnabledForCurrentPage()) 63 if (!client_->IsSavingAndFillingEnabledForCurrentPage())
59 return; 64 return;
60 65
61 client_->NotifyStorePasswordCalled(); 66 client_->NotifyStorePasswordCalled();
62 67
63 GURL origin = web_contents()->GetLastCommittedURL().GetOrigin(); 68 GURL origin = web_contents()->GetLastCommittedURL().GetOrigin();
64 std::unique_ptr<autofill::PasswordForm> form( 69 std::unique_ptr<autofill::PasswordForm> form(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 102 }
98 103
99 // Otherwise, this is a new form, so as the user if they'd like to save. 104 // Otherwise, this is a new form, so as the user if they'd like to save.
100 client_->PromptUserToSaveOrUpdatePassword( 105 client_->PromptUserToSaveOrUpdatePassword(
101 std::move(form_manager_), CredentialSourceType::CREDENTIAL_SOURCE_API, 106 std::move(form_manager_), CredentialSourceType::CREDENTIAL_SOURCE_API,
102 false); 107 false);
103 } 108 }
104 109
105 void CredentialManagerImpl::RequireUserMediation( 110 void CredentialManagerImpl::RequireUserMediation(
106 const RequireUserMediationCallback& callback) { 111 const RequireUserMediationCallback& callback) {
112 CredentialManagerLogger(client_->GetLogManager())
113 .LogRequireUserMediation(web_contents()->GetLastCommittedURL());
107 PasswordStore* store = GetPasswordStore(); 114 PasswordStore* store = GetPasswordStore();
108 if (!store || !IsUpdatingCredentialAllowed()) { 115 if (!store || !IsUpdatingCredentialAllowed()) {
109 callback.Run(); 116 callback.Run();
110 return; 117 return;
111 } 118 }
112 119
113 if (store->affiliated_match_helper()) { 120 if (store->affiliated_match_helper()) {
114 store->affiliated_match_helper()->GetAffiliatedAndroidRealms( 121 store->affiliated_match_helper()->GetAffiliatedAndroidRealms(
115 GetSynthesizedFormForOrigin(), 122 GetSynthesizedFormForOrigin(),
116 base::Bind(&CredentialManagerImpl::ScheduleRequireMediationTask, 123 base::Bind(&CredentialManagerImpl::ScheduleRequireMediationTask,
(...skipping 26 matching lines...) Expand all
143 150
144 // Send acknowledge response back. 151 // Send acknowledge response back.
145 callback.Run(); 152 callback.Run();
146 } 153 }
147 154
148 void CredentialManagerImpl::Get(bool zero_click_only, 155 void CredentialManagerImpl::Get(bool zero_click_only,
149 bool include_passwords, 156 bool include_passwords,
150 const std::vector<GURL>& federations, 157 const std::vector<GURL>& federations,
151 const GetCallback& callback) { 158 const GetCallback& callback) {
152 PasswordStore* store = GetPasswordStore(); 159 PasswordStore* store = GetPasswordStore();
160 CredentialManagerLogger(client_->GetLogManager())
161 .LogRequestCredential(web_contents()->GetLastCommittedURL(),
162 zero_click_only, federations);
153 if (pending_request_ || !store) { 163 if (pending_request_ || !store) {
154 // Callback error. 164 // Callback error.
155 callback.Run(pending_request_ 165 callback.Run(pending_request_
156 ? mojom::CredentialManagerError::PENDINGREQUEST 166 ? mojom::CredentialManagerError::PENDINGREQUEST
157 : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE, 167 : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE,
158 base::nullopt); 168 base::nullopt);
159 return; 169 return;
160 } 170 }
161 171
162 // Return an empty credential if zero-click is required but disabled, or if 172 // Return an empty credential if zero-click is required but disabled, or if
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 driver_factory->GetDriverForFrame(web_contents()->GetMainFrame()); 228 driver_factory->GetDriverForFrame(web_contents()->GetMainFrame());
219 return driver->AsWeakPtr(); 229 return driver->AsWeakPtr();
220 } 230 }
221 231
222 void CredentialManagerImpl::SendCredential( 232 void CredentialManagerImpl::SendCredential(
223 const SendCredentialCallback& send_callback, 233 const SendCredentialCallback& send_callback,
224 const CredentialInfo& info) { 234 const CredentialInfo& info) {
225 DCHECK(pending_request_); 235 DCHECK(pending_request_);
226 DCHECK(send_callback.Equals(pending_request_->send_callback())); 236 DCHECK(send_callback.Equals(pending_request_->send_callback()));
227 237
238 CredentialManagerLogger(client_->GetLogManager())
239 .LogSendCredential(web_contents()->GetLastCommittedURL(), info.type);
228 send_callback.Run(info); 240 send_callback.Run(info);
229 pending_request_.reset(); 241 pending_request_.reset();
230 } 242 }
231 243
232 void CredentialManagerImpl::SendPasswordForm( 244 void CredentialManagerImpl::SendPasswordForm(
233 const SendCredentialCallback& send_callback, 245 const SendCredentialCallback& send_callback,
234 const autofill::PasswordForm* form) { 246 const autofill::PasswordForm* form) {
235 CredentialInfo info; 247 CredentialInfo info;
236 if (form) { 248 if (form) {
237 password_manager::CredentialType type_to_return = 249 password_manager::CredentialType type_to_return =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 DCHECK(pending_require_user_mediation_); 285 DCHECK(pending_require_user_mediation_);
274 pending_require_user_mediation_.reset(); 286 pending_require_user_mediation_.reset();
275 } 287 }
276 288
277 bool CredentialManagerImpl::IsUpdatingCredentialAllowed() const { 289 bool CredentialManagerImpl::IsUpdatingCredentialAllowed() const {
278 return !client_->DidLastPageLoadEncounterSSLErrors() && 290 return !client_->DidLastPageLoadEncounterSSLErrors() &&
279 !client_->IsOffTheRecord(); 291 !client_->IsOffTheRecord();
280 } 292 }
281 293
282 } // namespace password_manager 294 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698