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

Unified Diff: chrome/browser/password_manager/password_store.cc

Issue 10209036: Per bug 121738, ignore old saved logins for http*://www.google.com. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/password_store.cc
===================================================================
--- chrome/browser/password_manager/password_store.cc (revision 134866)
+++ chrome/browser/password_manager/password_store.cc (working copy)
@@ -22,6 +22,21 @@
std::vector<PasswordForm*> >(callback) {
}
+void PasswordStore::GetLoginsRequest::ApplyIgnoreLoginsCutoff() {
+ if (!ignore_logins_cutoff_.is_null()) {
+ // Count down rather than up since we may be deleting elements.
+ // Note that in principle it could be more efficient to copy the whole array
+ // since that's worst-case linear time, but we expect that elements will be
+ // deleted rarely and lists will be small, so this avoids the copies.
+ for (size_t i = value.size(); i > 0; --i) {
+ if (value[i - 1]->date_created < ignore_logins_cutoff_) {
+ delete value[i - 1];
+ value.erase(value.begin() + (i - 1));
+ }
+ }
+ }
+}
+
PasswordStore::GetLoginsRequest::~GetLoginsRequest() {
if (canceled()) {
STLDeleteElements(&value);
@@ -61,7 +76,23 @@
CancelableRequestProvider::Handle PasswordStore::GetLogins(
const PasswordForm& form, PasswordStoreConsumer* consumer) {
- return Schedule(&PasswordStore::GetLoginsImpl, consumer, form);
+ // Per http://crbug.com/121738, we deliberately ignore saved logins for
+ // http*://www.google.com/ that were stored prior to 2012. (Google now uses
+ // https://accounts.google.com/ for all login forms, so these should be
+ // unused.) We don't delete them just yet, and they'll still be visible in the
+ // password manager, but we won't use them to autofill any forms. This is a
+ // security feature to help minimize damage that can be done by XSS attacks.
+ // TODO(mdm): actually delete them at some point, say M24 or so.
+ time_t ignore_logins_cutoff = 0;
+ if (form.scheme == PasswordForm::SCHEME_HTML &&
+ (form.signon_realm == "http://www.google.com" ||
+ form.signon_realm == "http://www.google.com/" ||
+ form.signon_realm == "https://www.google.com" ||
+ form.signon_realm == "https://www.google.com/")) {
+ ignore_logins_cutoff = 1325376000; // 00:00 Jan 1 2012 UTC
Ilya Sherman 2012/05/07 07:15:10 nit: Please use base::Time::FromUTCExploded() -- b
Mike Mammarella 2012/05/07 15:48:13 I thought about that, but it's both less concise a
Ilya Sherman 2012/05/07 20:12:02 The TimeT functions are documented as deprecated:
+ }
+ return Schedule(&PasswordStore::GetLoginsImpl, consumer, form,
+ base::Time::FromTimeT(ignore_logins_cutoff));
}
CancelableRequestProvider::Handle PasswordStore::GetAutofillableLogins(
@@ -98,6 +129,7 @@
}
void PasswordStore::ForwardLoginsResult(GetLoginsRequest* request) {
+ request->ApplyIgnoreLoginsCutoff();
request->ForwardResult(request->handle(), request->value);
}
@@ -112,14 +144,16 @@
return request->handle();
}
-template<typename BackendFunc, typename ArgA>
+template<typename BackendFunc>
CancelableRequestProvider::Handle PasswordStore::Schedule(
- BackendFunc func, PasswordStoreConsumer* consumer, const ArgA& a) {
+ BackendFunc func, PasswordStoreConsumer* consumer,
+ const PasswordForm& form, const base::Time& ignore_logins_cutoff) {
scoped_refptr<GetLoginsRequest> request(NewGetLoginsRequest(
base::Bind(&PasswordStoreConsumer::OnPasswordStoreRequestDone,
base::Unretained(consumer))));
+ request->set_ignore_logins_cutoff(ignore_logins_cutoff);
AddRequest(request, consumer->cancelable_consumer());
- ScheduleTask(base::Bind(func, this, request, a));
+ ScheduleTask(base::Bind(func, this, request, form));
return request->handle();
}
@@ -135,7 +169,6 @@
#if !defined(OS_MACOSX)
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
#endif // !defined(OS_MACOSX)
-
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&PasswordStore::NotifyLoginsChanged, this));
« no previous file with comments | « chrome/browser/password_manager/password_store.h ('k') | chrome/browser/password_manager/password_store_default_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698