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

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

Issue 9950139: Prevent the PasswordManager from provisionally saving data from username-less forms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make sure the code is actually not reachable Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/password_manager/password_form_manager.h" 9 #include "chrome/browser/password_manager/password_form_manager.h"
10 #include "chrome/browser/password_manager/password_manager_delegate.h" 10 #include "chrome/browser/password_manager/password_manager_delegate.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // results for the given form and autofill. If this is the case, we just 105 // results for the given form and autofill. If this is the case, we just
106 // give up. 106 // give up.
107 if (!manager->HasCompletedMatching()) 107 if (!manager->HasCompletedMatching())
108 return; 108 return;
109 109
110 // Also get out of here if the user told us to 'never remember' passwords for 110 // Also get out of here if the user told us to 'never remember' passwords for
111 // this form. 111 // this form.
112 if (manager->IsBlacklisted()) 112 if (manager->IsBlacklisted())
113 return; 113 return;
114 114
115 // Bail if we're missing any of the necessary form components.
116 if (!manager->HasValidPasswordForm())
117 return;
118
115 PasswordForm provisionally_saved_form(form); 119 PasswordForm provisionally_saved_form(form);
116 provisionally_saved_form.ssl_valid = form.origin.SchemeIsSecure() && 120 provisionally_saved_form.ssl_valid = form.origin.SchemeIsSecure() &&
117 !delegate_->DidLastPageLoadEncounterSSLErrors(); 121 !delegate_->DidLastPageLoadEncounterSSLErrors();
118 provisionally_saved_form.preferred = true; 122 provisionally_saved_form.preferred = true;
119 manager->ProvisionallySave(provisionally_saved_form); 123 manager->ProvisionallySave(provisionally_saved_form);
120 provisional_save_manager_.swap(manager); 124 provisional_save_manager_.swap(manager);
121 } 125 }
122 126
123 void PasswordManager::SetObserver(LoginModelObserver* observer) { 127 void PasswordManager::SetObserver(LoginModelObserver* observer) {
124 observer_ = observer; 128 observer_ = observer;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return; 181 return;
178 182
179 DCHECK(IsEnabled()); 183 DCHECK(IsEnabled());
180 184
181 // First, check for a failed login attempt. 185 // First, check for a failed login attempt.
182 for (std::vector<PasswordForm>::const_iterator iter = visible_forms.begin(); 186 for (std::vector<PasswordForm>::const_iterator iter = visible_forms.begin();
183 iter != visible_forms.end(); ++iter) { 187 iter != visible_forms.end(); ++iter) {
184 if (provisional_save_manager_->DoesManage(*iter)) { 188 if (provisional_save_manager_->DoesManage(*iter)) {
185 // The form trying to be saved has immediately re-appeared. Assume login 189 // The form trying to be saved has immediately re-appeared. Assume login
186 // failure and abort this save, by clearing provisional_save_manager_. 190 // failure and abort this save, by clearing provisional_save_manager_.
187 // Don't delete the login managers since the user may try again
188 // and we want to be able to save in that case.
189 provisional_save_manager_->SubmitFailed(); 191 provisional_save_manager_->SubmitFailed();
190 provisional_save_manager_.reset(); 192 provisional_save_manager_.reset();
191 return; 193 return;
192 } 194 }
193 } 195 }
194 196
195 if (!provisional_save_manager_->HasValidPasswordForm()) { 197 if (!provisional_save_manager_->HasValidPasswordForm()) {
196 // Form is not completely valid - we do not support it. 198 // Form is not completely valid - we do not support it.
197 NOTREACHED(); 199 NOTREACHED();
198 provisional_save_manager_.reset(); 200 provisional_save_manager_.reset();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 observer_->OnAutofillDataAvailable(preferred_match.username_value, 238 observer_->OnAutofillDataAvailable(preferred_match.username_value,
237 preferred_match.password_value); 239 preferred_match.password_value);
238 } 240 }
239 } 241 }
240 } 242 }
241 243
242 bool PasswordManager::IsEnabled() const { 244 bool PasswordManager::IsEnabled() const {
243 const Profile* profile = delegate_->GetProfileForPasswordManager(); 245 const Profile* profile = delegate_->GetProfileForPasswordManager();
244 return profile && !profile->IsOffTheRecord() && *password_manager_enabled_; 246 return profile && !profile->IsOffTheRecord() && *password_manager_enabled_;
245 } 247 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698