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

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

Issue 19705013: [password autofill] Remove references to PasswordForm from RenderViewImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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_manager.h" 5 #include "chrome/browser/password_manager/password_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 !delegate_->DidLastPageLoadEncounterSSLErrors(); 203 !delegate_->DidLastPageLoadEncounterSSLErrors();
204 provisionally_saved_form.preferred = true; 204 provisionally_saved_form.preferred = true;
205 PasswordFormManager::OtherPossibleUsernamesAction action = 205 PasswordFormManager::OtherPossibleUsernamesAction action =
206 PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES; 206 PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES;
207 if (OtherPossibleUsernamesEnabled()) 207 if (OtherPossibleUsernamesEnabled())
208 action = PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES; 208 action = PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES;
209 manager->ProvisionallySave(provisionally_saved_form, action); 209 manager->ProvisionallySave(provisionally_saved_form, action);
210 provisional_save_manager_.swap(manager); 210 provisional_save_manager_.swap(manager);
211 } 211 }
212 212
213 void PasswordManager::AddSubmissionCallback(
214 const PasswordSubmittedCallback& callback) {
215 submission_callbacks_.push_back(callback);
216 }
217
213 void PasswordManager::AddObserver(LoginModelObserver* observer) { 218 void PasswordManager::AddObserver(LoginModelObserver* observer) {
214 observers_.AddObserver(observer); 219 observers_.AddObserver(observer);
215 } 220 }
216 221
217 void PasswordManager::RemoveObserver(LoginModelObserver* observer) { 222 void PasswordManager::RemoveObserver(LoginModelObserver* observer) {
218 observers_.RemoveObserver(observer); 223 observers_.RemoveObserver(observer);
219 } 224 }
220 225
221 void PasswordManager::DidNavigateAnyFrame( 226 void PasswordManager::DidNavigateMainFrame(
222 const content::LoadCommittedDetails& details, 227 const content::LoadCommittedDetails& details,
223 const content::FrameNavigateParams& params) { 228 const content::FrameNavigateParams& params) {
224 bool password_form_submitted = params.password_form.origin.is_valid(); 229 // Clear data after main frame navigation. We don't want to clear data after
225 230 // subframe navigation as there might be password forms on other frames that
226 // Try to save the password if one was submitted. 231 // could be submitted.
227 if (password_form_submitted) 232 pending_login_managers_.clear();
228 ProvisionallySavePassword(params.password_form);
229
230 // Clear data after submission or main frame navigation. We don't want
231 // to clear data after subframe navigation as there might be password
232 // forms on other frames that could be submitted.
233 if (password_form_submitted || details.is_main_frame)
234 pending_login_managers_.clear();
235 } 233 }
236 234
237 bool PasswordManager::OnMessageReceived(const IPC::Message& message) { 235 bool PasswordManager::OnMessageReceived(const IPC::Message& message) {
238 bool handled = true; 236 bool handled = true;
239 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) 237 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message)
240 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsParsed, 238 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsParsed,
241 OnPasswordFormsParsed) 239 OnPasswordFormsParsed)
242 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered, 240 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered,
243 OnPasswordFormsRendered) 241 OnPasswordFormsRendered)
242 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted,
243 OnPasswordFormSubmitted)
244 IPC_MESSAGE_UNHANDLED(handled = false) 244 IPC_MESSAGE_UNHANDLED(handled = false)
245 IPC_END_MESSAGE_MAP() 245 IPC_END_MESSAGE_MAP()
246 return handled; 246 return handled;
247 } 247 }
248 248
249 void PasswordManager::OnPasswordFormSubmitted(
250 const PasswordForm& password_form) {
251 ProvisionallySavePassword(password_form);
252 for (size_t i = 0; i < submission_callbacks_.size(); ++i) {
253 submission_callbacks_[i].Run(password_form);
254 }
255
256 pending_login_managers_.clear();
257 }
258
249 void PasswordManager::OnPasswordFormsParsed( 259 void PasswordManager::OnPasswordFormsParsed(
250 const std::vector<PasswordForm>& forms) { 260 const std::vector<PasswordForm>& forms) {
251 // Ask the SSLManager for current security. 261 // Ask the SSLManager for current security.
252 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors(); 262 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors();
253 263
254 for (std::vector<PasswordForm>::const_iterator iter = forms.begin(); 264 for (std::vector<PasswordForm>::const_iterator iter = forms.begin();
255 iter != forms.end(); ++iter) { 265 iter != forms.end(); ++iter) {
256 // Don't involve the password manager if this form corresponds to 266 // Don't involve the password manager if this form corresponds to
257 // SpdyProxy authentication, as indicated by the realm. 267 // SpdyProxy authentication, as indicated by the realm.
258 if (EndsWith(iter->signon_realm, kSpdyProxyRealm, true)) 268 if (EndsWith(iter->signon_realm, kSpdyProxyRealm, true))
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 376 }
367 377
368 void PasswordManager::Autofill( 378 void PasswordManager::Autofill(
369 const PasswordForm& form_for_autofill, 379 const PasswordForm& form_for_autofill,
370 const PasswordFormMap& best_matches, 380 const PasswordFormMap& best_matches,
371 const PasswordForm& preferred_match, 381 const PasswordForm& preferred_match,
372 bool wait_for_username) const { 382 bool wait_for_username) const {
373 PossiblyInitializeUsernamesExperiment(best_matches); 383 PossiblyInitializeUsernamesExperiment(best_matches);
374 switch (form_for_autofill.scheme) { 384 switch (form_for_autofill.scheme) {
375 case PasswordForm::SCHEME_HTML: { 385 case PasswordForm::SCHEME_HTML: {
376 // Note the check above is required because the observer_ for a non-HTML 386 // Note the check above is required because the observers_ for a non-HTML
377 // schemed password form may have been freed, so we need to distinguish. 387 // schemed password form may have been freed, so we need to distinguish.
378 autofill::PasswordFormFillData fill_data; 388 autofill::PasswordFormFillData fill_data;
379 InitPasswordFormFillData(form_for_autofill, 389 InitPasswordFormFillData(form_for_autofill,
380 best_matches, 390 best_matches,
381 &preferred_match, 391 &preferred_match,
382 wait_for_username, 392 wait_for_username,
383 OtherPossibleUsernamesEnabled(), 393 OtherPossibleUsernamesEnabled(),
384 &fill_data); 394 &fill_data);
385 delegate_->FillPasswordForm(fill_data); 395 delegate_->FillPasswordForm(fill_data);
386 return; 396 return;
387 } 397 }
388 default: 398 default:
389 FOR_EACH_OBSERVER( 399 FOR_EACH_OBSERVER(
390 LoginModelObserver, 400 LoginModelObserver,
391 observers_, 401 observers_,
392 OnAutofillDataAvailable(preferred_match.username_value, 402 OnAutofillDataAvailable(preferred_match.username_value,
393 preferred_match.password_value)); 403 preferred_match.password_value));
394 } 404 }
395 } 405 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager.h ('k') | chrome/browser/password_manager/password_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698