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

Side by Side Diff: chrome/browser/password_manager/password_form_manager.cc

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
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 "chrome/browser/password_manager/password_form_manager.h" 5 #include "chrome/browser/password_manager/password_form_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 pending_credentials_.preferred = true; 120 pending_credentials_.preferred = true;
121 pending_credentials_.blacklisted_by_user = true; 121 pending_credentials_.blacklisted_by_user = true;
122 pending_credentials_.username_value.clear(); 122 pending_credentials_.username_value.clear();
123 pending_credentials_.password_value.clear(); 123 pending_credentials_.password_value.clear();
124 124
125 // Retroactively forget existing matches for this form, so we NEVER prompt or 125 // Retroactively forget existing matches for this form, so we NEVER prompt or
126 // autofill it again. 126 // autofill it again.
127 if (!best_matches_.empty()) { 127 if (!best_matches_.empty()) {
128 PasswordFormMap::const_iterator iter; 128 PasswordFormMap::const_iterator iter;
129 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( 129 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
130 profile_, Profile::EXPLICIT_ACCESS); 130 profile_, Profile::EXPLICIT_ACCESS).get();
131 if (!password_store) { 131 if (!password_store) {
132 NOTREACHED(); 132 NOTREACHED();
133 return; 133 return;
134 } 134 }
135 for (iter = best_matches_.begin(); iter != best_matches_.end(); ++iter) { 135 for (iter = best_matches_.begin(); iter != best_matches_.end(); ++iter) {
136 // We want to remove existing matches for this form so that the exact 136 // We want to remove existing matches for this form so that the exact
137 // origin match with |blackisted_by_user == true| is the only result that 137 // origin match with |blackisted_by_user == true| is the only result that
138 // shows up in the future for this origin URL. However, we don't want to 138 // shows up in the future for this origin URL. However, we don't want to
139 // delete logins that were actually saved on a different page (hence with 139 // delete logins that were actually saved on a different page (hence with
140 // different origin URL) and just happened to match this form because of 140 // different origin URL) and just happened to match this form because of
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (IsNewLogin()) 233 if (IsNewLogin())
234 SaveAsNewLogin(true); 234 SaveAsNewLogin(true);
235 else 235 else
236 UpdateLogin(); 236 UpdateLogin();
237 } 237 }
238 238
239 void PasswordFormManager::FetchMatchingLoginsFromPasswordStore() { 239 void PasswordFormManager::FetchMatchingLoginsFromPasswordStore() {
240 DCHECK_EQ(state_, PRE_MATCHING_PHASE); 240 DCHECK_EQ(state_, PRE_MATCHING_PHASE);
241 state_ = MATCHING_PHASE; 241 state_ = MATCHING_PHASE;
242 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( 242 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
243 profile_, Profile::EXPLICIT_ACCESS); 243 profile_, Profile::EXPLICIT_ACCESS).get();
244 if (!password_store) { 244 if (!password_store) {
245 NOTREACHED(); 245 NOTREACHED();
246 return; 246 return;
247 } 247 }
248 password_store->GetLogins(observed_form_, this); 248 password_store->GetLogins(observed_form_, this);
249 } 249 }
250 250
251 bool PasswordFormManager::HasCompletedMatching() { 251 bool PasswordFormManager::HasCompletedMatching() {
252 return state_ == POST_MATCHING_PHASE; 252 return state_ == POST_MATCHING_PHASE;
253 } 253 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 DCHECK_EQ(state_, POST_MATCHING_PHASE); 391 DCHECK_EQ(state_, POST_MATCHING_PHASE);
392 DCHECK(IsNewLogin()); 392 DCHECK(IsNewLogin());
393 // The new_form is being used to sign in, so it is preferred. 393 // The new_form is being used to sign in, so it is preferred.
394 DCHECK(pending_credentials_.preferred); 394 DCHECK(pending_credentials_.preferred);
395 // new_form contains the same basic data as observed_form_ (because its the 395 // new_form contains the same basic data as observed_form_ (because its the
396 // same form), but with the newly added credentials. 396 // same form), but with the newly added credentials.
397 397
398 DCHECK(!profile_->IsOffTheRecord()); 398 DCHECK(!profile_->IsOffTheRecord());
399 399
400 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( 400 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
401 profile_, Profile::IMPLICIT_ACCESS); 401 profile_, Profile::IMPLICIT_ACCESS).get();
402 if (!password_store) { 402 if (!password_store) {
403 NOTREACHED(); 403 NOTREACHED();
404 return; 404 return;
405 } 405 }
406 406
407 pending_credentials_.date_created = Time::Now(); 407 pending_credentials_.date_created = Time::Now();
408 SanitizePossibleUsernames(&pending_credentials_); 408 SanitizePossibleUsernames(&pending_credentials_);
409 password_store->AddLogin(pending_credentials_); 409 password_store->AddLogin(pending_credentials_);
410 410
411 if (reset_preferred_login) { 411 if (reset_preferred_login) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 DCHECK_EQ(state_, POST_MATCHING_PHASE); 449 DCHECK_EQ(state_, POST_MATCHING_PHASE);
450 DCHECK(preferred_match_); 450 DCHECK(preferred_match_);
451 // If we're doing an Update, we either autofilled correctly and need to 451 // If we're doing an Update, we either autofilled correctly and need to
452 // update the stats, or the user typed in a new password for autofilled 452 // update the stats, or the user typed in a new password for autofilled
453 // username, or the user selected one of the non-preferred matches, 453 // username, or the user selected one of the non-preferred matches,
454 // thus requiring a swap of preferred bits. 454 // thus requiring a swap of preferred bits.
455 DCHECK(!IsNewLogin() && pending_credentials_.preferred); 455 DCHECK(!IsNewLogin() && pending_credentials_.preferred);
456 DCHECK(!profile_->IsOffTheRecord()); 456 DCHECK(!profile_->IsOffTheRecord());
457 457
458 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( 458 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
459 profile_, Profile::IMPLICIT_ACCESS); 459 profile_, Profile::IMPLICIT_ACCESS).get();
460 if (!password_store) { 460 if (!password_store) {
461 NOTREACHED(); 461 NOTREACHED();
462 return; 462 return;
463 } 463 }
464 464
465 // Update metadata. 465 // Update metadata.
466 ++pending_credentials_.times_used; 466 ++pending_credentials_.times_used;
467 467
468 UpdatePreferredLoginState(password_store); 468 UpdatePreferredLoginState(password_store);
469 469
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 577
578 void PasswordFormManager::SubmitFailed() { 578 void PasswordFormManager::SubmitFailed() {
579 submit_result_ = kSubmitResultFailed; 579 submit_result_ = kSubmitResultFailed;
580 } 580 }
581 581
582 void PasswordFormManager::SendNotBlacklistedToRenderer() { 582 void PasswordFormManager::SendNotBlacklistedToRenderer() {
583 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); 583 content::RenderViewHost* host = web_contents_->GetRenderViewHost();
584 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), 584 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(),
585 observed_form_)); 585 observed_form_));
586 } 586 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/message_center_settings_controller.cc ('k') | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698