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

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

Issue 1656005: Fix password mgr heuristics for sites that keep the login form around after signin (Closed)
Patch Set: Responding to feedback Created 10 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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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.h" 5 #include "chrome/browser/password_manager/password_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (provisional_save_manager_->IsNewLogin()) { 109 if (provisional_save_manager_->IsNewLogin()) {
110 delegate_->AddSavePasswordInfoBar(provisional_save_manager_.release()); 110 delegate_->AddSavePasswordInfoBar(provisional_save_manager_.release());
111 } else { 111 } else {
112 // If the save is not a new username entry, then we just want to save this 112 // If the save is not a new username entry, then we just want to save this
113 // data (since the user already has related data saved), so don't prompt. 113 // data (since the user already has related data saved), so don't prompt.
114 provisional_save_manager_->Save(); 114 provisional_save_manager_->Save();
115 provisional_save_manager_.reset(); 115 provisional_save_manager_.reset();
116 } 116 }
117 } 117 }
118 118
119 void PasswordManager::PasswordFormsSeen( 119 void PasswordManager::PasswordFormsFound(
120 const std::vector<PasswordForm>& forms) { 120 const std::vector<PasswordForm>& forms) {
121 if (!delegate_->GetProfileForPasswordManager()) 121 if (!delegate_->GetProfileForPasswordManager())
122 return; 122 return;
123 if (!*password_manager_enabled_) 123 if (!*password_manager_enabled_)
124 return; 124 return;
125 125
126 // Ask the SSLManager for current security. 126 // Ask the SSLManager for current security.
127 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors(); 127 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors();
128 128
129 std::vector<PasswordForm>::const_iterator iter; 129 std::vector<PasswordForm>::const_iterator iter;
130 for (iter = forms.begin(); iter != forms.end(); iter++) { 130 for (iter = forms.begin(); iter != forms.end(); iter++) {
131 if (provisional_save_manager_.get() && 131 bool ssl_valid = iter->origin.SchemeIsSecure() && !had_ssl_error;
132 provisional_save_manager_->DoesManage(*iter)) { 132 PasswordFormManager* manager =
133 // The form trying to be saved has immediately re-appeared. Assume 133 new PasswordFormManager(delegate_->GetProfileForPasswordManager(),
134 // login failure and abort this save. Fallback to pending login state 134 this, *iter, ssl_valid);
135 // since the user may try again. 135 pending_login_managers_.push_back(manager);
136 pending_login_managers_.push_back(provisional_save_manager_.release()); 136 manager->FetchMatchingLoginsFromWebDatabase();
137 }
138 }
139
140 void PasswordManager::PasswordFormsVisible(
141 const std::vector<PasswordForm>& visible_forms) {
142 if (!provisional_save_manager_.get())
143 return;
144 std::vector<PasswordForm>::const_iterator iter;
145 for (iter = visible_forms.begin(); iter != visible_forms.end(); iter++) {
146 if (provisional_save_manager_->DoesManage(*iter)) {
147 // The form trying to be saved has immediately re-appeared. Assume login
148 // failure and abort this save, by clearing provisional_save_manager_.
137 // Don't delete the login managers since the user may try again 149 // Don't delete the login managers since the user may try again
138 // and we want to be able to save in that case. 150 // and we want to be able to save in that case.
151 provisional_save_manager_.release();
139 break; 152 break;
140 } else {
141 bool ssl_valid = iter->origin.SchemeIsSecure() && !had_ssl_error;
142 PasswordFormManager* manager =
143 new PasswordFormManager(delegate_->GetProfileForPasswordManager(),
144 this, *iter, ssl_valid);
145 pending_login_managers_.push_back(manager);
146 manager->FetchMatchingLoginsFromWebDatabase();
147 } 153 }
148 } 154 }
149 } 155 }
150 156
151 void PasswordManager::Autofill( 157 void PasswordManager::Autofill(
152 const PasswordForm& form_for_autofill, 158 const PasswordForm& form_for_autofill,
153 const PasswordFormMap& best_matches, 159 const PasswordFormMap& best_matches,
154 const PasswordForm* const preferred_match) const { 160 const PasswordForm* const preferred_match) const {
155 DCHECK(preferred_match); 161 DCHECK(preferred_match);
156 switch (form_for_autofill.scheme) { 162 switch (form_for_autofill.scheme) {
(...skipping 12 matching lines...) Expand all
169 return; 175 return;
170 } 176 }
171 default: 177 default:
172 if (observer_) { 178 if (observer_) {
173 observer_->OnAutofillDataAvailable( 179 observer_->OnAutofillDataAvailable(
174 UTF16ToWideHack(preferred_match->username_value), 180 UTF16ToWideHack(preferred_match->username_value),
175 UTF16ToWideHack(preferred_match->password_value)); 181 UTF16ToWideHack(preferred_match->password_value));
176 } 182 }
177 } 183 }
178 } 184 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager.h ('k') | chrome/browser/password_manager/password_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698