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

Side by Side Diff: components/password_manager/core/browser/password_form_manager.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 11 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 (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 "components/password_manager/core/browser/password_form_manager.h" 5 #include "components/password_manager/core/browser/password_form_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 scoped_ptr<autofill::PasswordForm> mutable_provisionally_saved_form( 258 scoped_ptr<autofill::PasswordForm> mutable_provisionally_saved_form(
259 new PasswordForm(credentials)); 259 new PasswordForm(credentials));
260 if (credentials.IsPossibleChangePasswordForm() && 260 if (credentials.IsPossibleChangePasswordForm() &&
261 !credentials.username_value.empty() && 261 !credentials.username_value.empty() &&
262 IsProbablyNotUsername(credentials.username_value)) { 262 IsProbablyNotUsername(credentials.username_value)) {
263 mutable_provisionally_saved_form->username_value.clear(); 263 mutable_provisionally_saved_form->username_value.clear();
264 mutable_provisionally_saved_form->username_element.clear(); 264 mutable_provisionally_saved_form->username_element.clear();
265 is_possible_change_password_form_without_username_ = true; 265 is_possible_change_password_form_without_username_ = true;
266 } 266 }
267 provisionally_saved_form_ = mutable_provisionally_saved_form.Pass(); 267 provisionally_saved_form_ = std::move(mutable_provisionally_saved_form);
268 other_possible_username_action_ = action; 268 other_possible_username_action_ = action;
269 269
270 if (HasCompletedMatching()) 270 if (HasCompletedMatching())
271 CreatePendingCredentials(); 271 CreatePendingCredentials();
272 } 272 }
273 273
274 void PasswordFormManager::Save() { 274 void PasswordFormManager::Save() {
275 DCHECK_EQ(state_, POST_MATCHING_PHASE); 275 DCHECK_EQ(state_, POST_MATCHING_PHASE);
276 DCHECK(!client_->IsOffTheRecord()); 276 DCHECK(!client_->IsOffTheRecord());
277 277
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 398 }
399 399
400 // Remove credentials which need to be ignored from |logins_result|. 400 // Remove credentials which need to be ignored from |logins_result|.
401 if (!observed_form_.ssl_valid) { 401 if (!observed_form_.ssl_valid) {
402 logins_result.erase( 402 logins_result.erase(
403 std::partition(logins_result.begin(), logins_result.end(), 403 std::partition(logins_result.begin(), logins_result.end(),
404 [](PasswordForm* form) { return !form->ssl_valid; }), 404 [](PasswordForm* form) { return !form->ssl_valid; }),
405 logins_result.end()); 405 logins_result.end());
406 } 406 }
407 logins_result = 407 logins_result =
408 client_->GetStoreResultFilter()->FilterResults(logins_result.Pass()); 408 client_->GetStoreResultFilter()->FilterResults(std::move(logins_result));
409 409
410 // Deal with blacklisted forms. 410 // Deal with blacklisted forms.
411 auto begin_blacklisted = std::partition( 411 auto begin_blacklisted = std::partition(
412 logins_result.begin(), logins_result.end(), 412 logins_result.begin(), logins_result.end(),
413 [](PasswordForm* form) { return !form->blacklisted_by_user; }); 413 [](PasswordForm* form) { return !form->blacklisted_by_user; });
414 for (auto it = begin_blacklisted; it != logins_result.end(); ++it) { 414 for (auto it = begin_blacklisted; it != logins_result.end(); ++it) {
415 if (IsBlacklistMatch(**it)) { 415 if (IsBlacklistMatch(**it)) {
416 blacklisted_matches_.push_back(*it); 416 blacklisted_matches_.push_back(*it);
417 *it = nullptr; 417 *it = nullptr;
418 } 418 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 // Websites that participate in affiliation-based matching will normally 470 // Websites that participate in affiliation-based matching will normally
471 // have a single authentication system per domain, therefore affiliation 471 // have a single authentication system per domain, therefore affiliation
472 // based matches are desired to be offered on any login form on the site. 472 // based matches are desired to be offered on any login form on the site.
473 // However, for Android credentials, most meta-data attributes are empty, 473 // However, for Android credentials, most meta-data attributes are empty,
474 // so they will have a very low score, hence need to be protected against 474 // so they will have a very low score, hence need to be protected against
475 // the high-scoring logins saved from the website. 475 // the high-scoring logins saved from the website.
476 is_credential_protected |= IsValidAndroidFacetURI(login->signon_realm); 476 is_credential_protected |= IsValidAndroidFacetURI(login->signon_realm);
477 477
478 if (is_credential_protected) 478 if (is_credential_protected)
479 protected_credentials.push_back(login.Pass()); 479 protected_credentials.push_back(std::move(login));
480 else 480 else
481 not_best_matches_.push_back(login.Pass()); 481 not_best_matches_.push_back(std::move(login));
482 continue; 482 continue;
483 } 483 }
484 484
485 // If there is another best-score match for the same username then leave it 485 // If there is another best-score match for the same username then leave it
486 // and add the current form to |not_best_matches_|. 486 // and add the current form to |not_best_matches_|.
487 const base::string16& username = login->username_value; 487 const base::string16& username = login->username_value;
488 auto best_match_username = best_matches_.find(username); 488 auto best_match_username = best_matches_.find(username);
489 if (best_match_username == best_matches_.end()) { 489 if (best_match_username == best_matches_.end()) {
490 if (login->preferred) 490 if (login->preferred)
491 preferred_match_ = login.get(); 491 preferred_match_ = login.get();
492 best_matches_.insert(std::make_pair(username, std::move(login))); 492 best_matches_.insert(std::make_pair(username, std::move(login)));
493 } else { 493 } else {
494 not_best_matches_.push_back(std::move(login)); 494 not_best_matches_.push_back(std::move(login));
495 } 495 }
496 } 496 }
497 497
498 // Add the protected results if we don't already have a result with the same 498 // Add the protected results if we don't already have a result with the same
499 // username. 499 // username.
500 for (ScopedVector<PasswordForm>::iterator it = protected_credentials.begin(); 500 for (ScopedVector<PasswordForm>::iterator it = protected_credentials.begin();
501 it != protected_credentials.end(); ++it) { 501 it != protected_credentials.end(); ++it) {
502 // Take ownership of the PasswordForm from the ScopedVector. 502 // Take ownership of the PasswordForm from the ScopedVector.
503 scoped_ptr<PasswordForm> protege(*it); 503 scoped_ptr<PasswordForm> protege(*it);
504 *it = nullptr; 504 *it = nullptr;
505 const base::string16& username = protege->username_value; 505 const base::string16& username = protege->username_value;
506 if (best_matches_.find(username) == best_matches_.end()) 506 if (best_matches_.find(username) == best_matches_.end())
507 best_matches_.insert(std::make_pair(username, std::move(protege))); 507 best_matches_.insert(std::make_pair(username, std::move(protege)));
508 else 508 else
509 not_best_matches_.push_back(protege.Pass()); 509 not_best_matches_.push_back(std::move(protege));
510 } 510 }
511 511
512 UMA_HISTOGRAM_COUNTS("PasswordManager.NumPasswordsNotShown", 512 UMA_HISTOGRAM_COUNTS("PasswordManager.NumPasswordsNotShown",
513 logins_result_size - best_matches_.size()); 513 logins_result_size - best_matches_.size());
514 514
515 if (!best_matches_.empty()) { 515 if (!best_matches_.empty()) {
516 // It is possible we have at least one match but have no preferred_match_, 516 // It is possible we have at least one match but have no preferred_match_,
517 // because a user may have chosen to 'Forget' the preferred match. So we 517 // because a user may have chosen to 'Forget' the preferred match. So we
518 // just pick the first one and whichever the user selects for submit will 518 // just pick the first one and whichever the user selects for submit will
519 // be saved as preferred. 519 // be saved as preferred.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 596
597 scoped_ptr<BrowserSavePasswordProgressLogger> logger; 597 scoped_ptr<BrowserSavePasswordProgressLogger> logger;
598 if (password_manager_util::IsLoggingActive(client_)) { 598 if (password_manager_util::IsLoggingActive(client_)) {
599 logger.reset( 599 logger.reset(
600 new BrowserSavePasswordProgressLogger(client_->GetLogManager())); 600 new BrowserSavePasswordProgressLogger(client_->GetLogManager()));
601 logger->LogMessage(Logger::STRING_ON_GET_STORE_RESULTS_METHOD); 601 logger->LogMessage(Logger::STRING_ON_GET_STORE_RESULTS_METHOD);
602 logger->LogNumber(Logger::STRING_NUMBER_RESULTS, results.size()); 602 logger->LogNumber(Logger::STRING_NUMBER_RESULTS, results.size());
603 } 603 }
604 604
605 if (!results.empty()) 605 if (!results.empty())
606 OnRequestDone(results.Pass()); 606 OnRequestDone(std::move(results));
607 state_ = POST_MATCHING_PHASE; 607 state_ = POST_MATCHING_PHASE;
608 608
609 // If password store was slow and provisionally saved form is already here 609 // If password store was slow and provisionally saved form is already here
610 // then create pending credentials (see http://crbug.com/470322). 610 // then create pending credentials (see http://crbug.com/470322).
611 if (provisionally_saved_form_) 611 if (provisionally_saved_form_)
612 CreatePendingCredentials(); 612 CreatePendingCredentials();
613 613
614 if (manager_action_ != kManagerActionBlacklisted) { 614 if (manager_action_ != kManagerActionBlacklisted) {
615 for (auto const& driver : drivers_) 615 for (auto const& driver : drivers_)
616 ProcessFrameInternal(driver); 616 ProcessFrameInternal(driver);
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 continue; 1338 continue;
1339 } 1339 }
1340 password_store->RemoveLogin(*credential_to_delete->second); 1340 password_store->RemoveLogin(*credential_to_delete->second);
1341 if (credential_to_delete->second.get() == preferred_match_) 1341 if (credential_to_delete->second.get() == preferred_match_)
1342 preferred_match_ = nullptr; 1342 preferred_match_ = nullptr;
1343 best_matches_.erase(credential_to_delete); 1343 best_matches_.erase(credential_to_delete);
1344 } 1344 }
1345 } 1345 }
1346 1346
1347 } // namespace password_manager 1347 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698