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

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

Issue 1832933002: Update the |skip_zero_click| flag of a credential when selected in the account chooser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 8 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_dispatc her.h" 5 #include "components/password_manager/content/browser/credential_manager_dispatc her.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 PasswordManagerDriver* driver = 218 PasswordManagerDriver* driver =
219 driver_factory->GetDriverForFrame(web_contents()->GetMainFrame()); 219 driver_factory->GetDriverForFrame(web_contents()->GetMainFrame());
220 return driver->AsWeakPtr(); 220 return driver->AsWeakPtr();
221 } 221 }
222 222
223 void CredentialManagerDispatcher::SendCredential(int request_id, 223 void CredentialManagerDispatcher::SendCredential(int request_id,
224 const CredentialInfo& info) { 224 const CredentialInfo& info) {
225 DCHECK(pending_request_); 225 DCHECK(pending_request_);
226 DCHECK_EQ(pending_request_->id(), request_id); 226 DCHECK_EQ(pending_request_->id(), request_id);
227 227
228 if (PasswordStore* store = GetPasswordStore()) {
229 if (info.type != CredentialType::CREDENTIAL_TYPE_EMPTY &&
230 IsZeroClickAllowed()) {
231 DCHECK(IsUpdatingCredentialAllowed());
232 scoped_ptr<autofill::PasswordForm> form(
233 CreatePasswordFormFromCredentialInfo(info,
234 pending_request_->origin()));
235 form->skip_zero_click = false;
236 store->UpdateLogin(*form);
237 }
238 }
239
240 web_contents()->GetRenderViewHost()->Send( 228 web_contents()->GetRenderViewHost()->Send(
241 new CredentialManagerMsg_SendCredential( 229 new CredentialManagerMsg_SendCredential(
242 web_contents()->GetRenderViewHost()->GetRoutingID(), 230 web_contents()->GetRenderViewHost()->GetRoutingID(),
243 pending_request_->id(), info)); 231 pending_request_->id(), info));
244 pending_request_.reset(); 232 pending_request_.reset();
245 } 233 }
246 234
235 void CredentialManagerDispatcher::SendPasswordForm(
236 int request_id,
237 const autofill::PasswordForm* form) {
238 CredentialInfo info;
239 if (form) {
240 password_manager::CredentialType type_to_return =
241 form->federation_origin.unique()
242 ? CredentialType::CREDENTIAL_TYPE_PASSWORD
243 : CredentialType::CREDENTIAL_TYPE_FEDERATED;
244 info = CredentialInfo(*form, type_to_return);
245 if (PasswordStore* store = GetPasswordStore()) {
246 if (form->skip_zero_click && IsZeroClickAllowed()) {
247 DCHECK(IsUpdatingCredentialAllowed());
248 autofill::PasswordForm update_form = *form;
249 update_form.skip_zero_click = false;
250 store->UpdateLogin(update_form);
251 }
252 }
253 }
254 SendCredential(request_id, info);
255 }
256
247 PasswordManagerClient* CredentialManagerDispatcher::client() const { 257 PasswordManagerClient* CredentialManagerDispatcher::client() const {
248 return client_; 258 return client_;
249 } 259 }
250 260
251 autofill::PasswordForm 261 autofill::PasswordForm
252 CredentialManagerDispatcher::GetSynthesizedFormForOrigin() const { 262 CredentialManagerDispatcher::GetSynthesizedFormForOrigin() const {
253 autofill::PasswordForm synthetic_form; 263 autofill::PasswordForm synthetic_form;
254 synthetic_form.origin = web_contents()->GetLastCommittedURL().GetOrigin(); 264 synthetic_form.origin = web_contents()->GetLastCommittedURL().GetOrigin();
255 synthetic_form.signon_realm = synthetic_form.origin.spec(); 265 synthetic_form.signon_realm = synthetic_form.origin.spec();
256 synthetic_form.scheme = autofill::PasswordForm::SCHEME_HTML; 266 synthetic_form.scheme = autofill::PasswordForm::SCHEME_HTML;
257 synthetic_form.ssl_valid = synthetic_form.origin.SchemeIsCryptographic() && 267 synthetic_form.ssl_valid = synthetic_form.origin.SchemeIsCryptographic() &&
258 !client_->DidLastPageLoadEncounterSSLErrors(); 268 !client_->DidLastPageLoadEncounterSSLErrors();
259 return synthetic_form; 269 return synthetic_form;
260 } 270 }
261 271
262 void CredentialManagerDispatcher::DoneRequiringUserMediation() { 272 void CredentialManagerDispatcher::DoneRequiringUserMediation() {
263 DCHECK(pending_require_user_mediation_); 273 DCHECK(pending_require_user_mediation_);
264 pending_require_user_mediation_.reset(); 274 pending_require_user_mediation_.reset();
265 } 275 }
266 276
267 bool CredentialManagerDispatcher::IsUpdatingCredentialAllowed() const { 277 bool CredentialManagerDispatcher::IsUpdatingCredentialAllowed() const {
268 return !client_->DidLastPageLoadEncounterSSLErrors() && 278 return !client_->DidLastPageLoadEncounterSSLErrors() &&
269 !client_->IsOffTheRecord(); 279 !client_->IsOffTheRecord();
270 } 280 }
271 281
272 } // namespace password_manager 282 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698