summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-20 20:45:09 +0000
committerstuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-20 20:45:09 +0000
commit631f0d40b34036928a3b4e3fc327de325904e8af (patch)
tree8c5675d130605651078c8968a0b72f01387f283f
parentfca2b960ea67f126cbbb616d04166d85b6c72776 (diff)
downloadchromium_src-631f0d40b34036928a3b4e3fc327de325904e8af.zip
chromium_src-631f0d40b34036928a3b4e3fc327de325904e8af.tar.gz
chromium_src-631f0d40b34036928a3b4e3fc327de325904e8af.tar.bz2
Change GetAllLogins to GetAllBlacklistLogins.
BUG=none TEST=accessing the list of passwords and password blacklists should still work. Review URL: http://codereview.chromium.org/149778 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21100 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/password_manager/login_database.cc22
-rw-r--r--chrome/browser/password_manager/login_database.h21
-rw-r--r--chrome/browser/password_manager/login_database_unittest.cc28
-rw-r--r--chrome/browser/password_manager/password_store.cc9
-rw-r--r--chrome/browser/password_manager/password_store.h18
-rw-r--r--chrome/browser/password_manager/password_store_default.cc14
-rw-r--r--chrome/browser/password_manager/password_store_default.h8
-rw-r--r--chrome/browser/password_manager/password_store_mac.cc21
-rw-r--r--chrome/browser/password_manager/password_store_mac.h4
-rw-r--r--chrome/browser/views/options/exceptions_page_view.cc8
-rw-r--r--chrome/browser/views/options/passwords_page_view.cc2
-rw-r--r--chrome/browser/webdata/web_data_service.cc31
-rw-r--r--chrome/browser/webdata/web_data_service.h10
13 files changed, 108 insertions, 88 deletions
diff --git a/chrome/browser/password_manager/login_database.cc b/chrome/browser/password_manager/login_database.cc
index 965e9c3..c948db2 100644
--- a/chrome/browser/password_manager/login_database.cc
+++ b/chrome/browser/password_manager/login_database.cc
@@ -296,8 +296,18 @@ bool LoginDatabase::GetLogins(const PasswordForm& form,
return result == SQLITE_DONE;
}
-bool LoginDatabase::GetAllLogins(std::vector<PasswordForm*>* forms,
- bool include_blacklisted) const {
+bool LoginDatabase::GetAutofillableLogins(
+ std::vector<PasswordForm*>* forms) const {
+ return GetAllLoginsWithBlacklistSetting(false, forms);
+}
+
+bool LoginDatabase::GetBlacklistLogins(
+ std::vector<PasswordForm*>* forms) const {
+ return GetAllLoginsWithBlacklistSetting(true, forms);
+}
+
+bool LoginDatabase::GetAllLoginsWithBlacklistSetting(
+ bool blacklisted, std::vector<PasswordForm*>* forms) const {
DCHECK(forms);
SQLStatement s;
// You *must* change LoginTableColumns if this query changes.
@@ -305,15 +315,15 @@ bool LoginDatabase::GetAllLogins(std::vector<PasswordForm*>* forms,
"username_element, username_value, "
"password_element, password_value, "
"submit_element, signon_realm, ssl_valid, preferred, "
- "date_created, blacklisted_by_user, scheme FROM logins ";
- if (!include_blacklisted)
- stmt.append("WHERE blacklisted_by_user == 0 ");
- stmt.append("ORDER BY origin_url");
+ "date_created, blacklisted_by_user, scheme FROM logins "
+ "WHERE blacklisted_by_user == ? "
+ "ORDER BY origin_url";
if (s.prepare(db_, stmt.c_str()) != SQLITE_OK) {
NOTREACHED() << "Statement prepare failed";
return false;
}
+ s.bind_int(0, blacklisted ? 1 : 0);
int result;
while ((result = s.step()) == SQLITE_ROW) {
diff --git a/chrome/browser/password_manager/login_database.h b/chrome/browser/password_manager/login_database.h
index e2619ae..9e34192 100644
--- a/chrome/browser/password_manager/login_database.h
+++ b/chrome/browser/password_manager/login_database.h
@@ -50,12 +50,14 @@ class LoginDatabase {
bool GetLogins(const webkit_glue::PasswordForm& form,
std::vector<webkit_glue::PasswordForm*>* forms) const;
- // Loads the complete list of password forms into the specified vector |forms|
- // if include_blacklisted is true, otherwise only loads those which are
- // actually autofillable; i.e haven't been blacklisted by the user selecting
- // the 'Never for this site' button.
- bool GetAllLogins(std::vector<webkit_glue::PasswordForm*>* forms,
- bool include_blacklisted) const;
+ // Loads the complete list of autofillable password forms (i.e., not blacklist
+ // entries) into |forms|.
+ bool GetAutofillableLogins(
+ std::vector<webkit_glue::PasswordForm*>* forms) const;
+
+ // Loads the complete list of blacklist forms into |forms|.
+ bool GetBlacklistLogins(
+ std::vector<webkit_glue::PasswordForm*>* forms) const;
protected:
// Returns an encrypted version of plain_text.
@@ -70,10 +72,15 @@ class LoginDatabase {
private:
// Fills |form| from the values in the given statement (which is assumed to
- // be of the form used by GetLogins/GetAllLogins).
+ // be of the form used by the Get*Logins methods).
void InitPasswordFormFromStatement(webkit_glue::PasswordForm* form,
SQLStatement* s) const;
+ // Loads all logins whose blacklist setting matches |blacklisted| into
+ // |forms|.
+ bool GetAllLoginsWithBlacklistSetting(
+ bool blacklisted, std::vector<webkit_glue::PasswordForm*>* forms) const;
+
sqlite3* db_;
MetaTableHelper meta_table_;
diff --git a/chrome/browser/password_manager/login_database_unittest.cc b/chrome/browser/password_manager/login_database_unittest.cc
index 8b4f6a9..201c93f 100644
--- a/chrome/browser/password_manager/login_database_unittest.cc
+++ b/chrome/browser/password_manager/login_database_unittest.cc
@@ -56,7 +56,7 @@ TEST_F(LoginDatabaseTest, Logins) {
std::vector<PasswordForm*> result;
// Verify the database is empty.
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(0U, result.size());
// Example password form.
@@ -75,7 +75,7 @@ TEST_F(LoginDatabaseTest, Logins) {
// Add it and make sure it is there.
EXPECT_TRUE(db->AddLogin(form));
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(1U, result.size());
delete result[0];
result.clear();
@@ -118,7 +118,7 @@ TEST_F(LoginDatabaseTest, Logins) {
// Let's imagine the user logs into the secure site.
EXPECT_TRUE(db->AddLogin(form4));
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(2U, result.size());
delete result[0];
delete result[1];
@@ -132,7 +132,7 @@ TEST_F(LoginDatabaseTest, Logins) {
// The user chose to forget the original but not the new.
EXPECT_TRUE(db->RemoveLogin(form));
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(1U, result.size());
delete result[0];
result.clear();
@@ -168,7 +168,7 @@ TEST_F(LoginDatabaseTest, Logins) {
delete result[0];
result.clear();
// Only one record.
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(1U, result.size());
// Password element was updated.
#if defined(OS_MACOSX)
@@ -184,7 +184,7 @@ TEST_F(LoginDatabaseTest, Logins) {
// Make sure everything can disappear.
EXPECT_TRUE(db->RemoveLogin(form4));
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(0U, result.size());
}
@@ -220,7 +220,7 @@ TEST_F(LoginDatabaseTest, ClearPrivateData_SavedPasswords) {
std::vector<PasswordForm*> result;
// Verify the database is empty.
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(0U, result.size());
base::Time now = base::Time::Now();
@@ -234,7 +234,7 @@ TEST_F(LoginDatabaseTest, ClearPrivateData_SavedPasswords) {
EXPECT_TRUE(AddTimestampedLogin(db.get(), "4", L"foo4", now + one_day));
// Verify inserts worked.
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(4U, result.size());
ClearResults(&result);
@@ -242,7 +242,7 @@ TEST_F(LoginDatabaseTest, ClearPrivateData_SavedPasswords) {
db->RemoveLoginsCreatedBetween(now, base::Time());
// Should have deleted half of what we inserted.
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(2U, result.size());
ClearResults(&result);
@@ -250,7 +250,7 @@ TEST_F(LoginDatabaseTest, ClearPrivateData_SavedPasswords) {
db->RemoveLoginsCreatedBetween(base::Time(), base::Time());
// Verify nothing is left.
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
EXPECT_EQ(0U, result.size());
}
@@ -263,7 +263,7 @@ TEST_F(LoginDatabaseTest, BlacklistedLogins) {
std::vector<PasswordForm*> result;
// Verify the database is empty.
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ EXPECT_TRUE(db->GetBlacklistLogins(&result));
ASSERT_EQ(0U, result.size());
// Save a form as blacklisted.
@@ -281,7 +281,7 @@ TEST_F(LoginDatabaseTest, BlacklistedLogins) {
EXPECT_TRUE(db->AddLogin(form));
// Get all non-blacklisted logins (should be none).
- EXPECT_TRUE(db->GetAllLogins(&result, false));
+ EXPECT_TRUE(db->GetAutofillableLogins(&result));
ASSERT_EQ(0U, result.size());
// GetLogins should give the blacklisted result.
@@ -289,8 +289,8 @@ TEST_F(LoginDatabaseTest, BlacklistedLogins) {
EXPECT_EQ(1U, result.size());
ClearResults(&result);
- // So should GetAll including blacklisted.
- EXPECT_TRUE(db->GetAllLogins(&result, true));
+ // So should GetAllBlacklistedLogins.
+ EXPECT_TRUE(db->GetBlacklistLogins(&result));
EXPECT_EQ(1U, result.size());
ClearResults(&result);
}
diff --git a/chrome/browser/password_manager/password_store.cc b/chrome/browser/password_manager/password_store.cc
index ac8e911..72ce9a7 100644
--- a/chrome/browser/password_manager/password_store.cc
+++ b/chrome/browser/password_manager/password_store.cc
@@ -58,19 +58,20 @@ int PasswordStore::GetLogins(const PasswordForm& form,
return handle;
}
-int PasswordStore::GetAllLogins(PasswordStoreConsumer* consumer) {
+int PasswordStore::GetAutofillableLogins(PasswordStoreConsumer* consumer) {
int handle = GetNewRequestHandle();
GetLoginsRequest* request = new GetLoginsRequest(consumer, handle);
- ScheduleTask(NewRunnableMethod(this, &PasswordStore::GetAllLoginsImpl,
+ ScheduleTask(NewRunnableMethod(this,
+ &PasswordStore::GetAutofillableLoginsImpl,
request));
return handle;
}
-int PasswordStore::GetAllAutofillableLogins(PasswordStoreConsumer* consumer) {
+int PasswordStore::GetBlacklistLogins(PasswordStoreConsumer* consumer) {
int handle = GetNewRequestHandle();
GetLoginsRequest* request = new GetLoginsRequest(consumer, handle);
ScheduleTask(NewRunnableMethod(this,
- &PasswordStore::GetAllAutofillableLoginsImpl,
+ &PasswordStore::GetBlacklistLoginsImpl,
request));
return handle;
}
diff --git a/chrome/browser/password_manager/password_store.h b/chrome/browser/password_manager/password_store.h
index 22f8fb3..03612b7 100644
--- a/chrome/browser/password_manager/password_store.h
+++ b/chrome/browser/password_manager/password_store.h
@@ -58,16 +58,16 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> {
virtual int GetLogins(const webkit_glue::PasswordForm& form,
PasswordStoreConsumer* consumer);
- // Gets the complete list of PasswordForms and returns a handle so the async
- // request can be tracked. Implement the PasswordStoreConsumer interface to
- // be notified on completion.
- virtual int GetAllLogins(PasswordStoreConsumer* consumer);
-
// Gets the complete list of PasswordForms that are not blacklist entries--and
// are thus auto-fillable--and returns a handle so the async request can be
// tracked. Implement the PasswordStoreConsumer interface to be notified
// on completion.
- virtual int GetAllAutofillableLogins(PasswordStoreConsumer* consumer);
+ virtual int GetAutofillableLogins(PasswordStoreConsumer* consumer);
+
+ // Gets the complete list of PasswordForms that are blacklist entries, and
+ // returns a handle so the async request can be tracked. Implement the
+ // PasswordStoreConsumer interface to be notified on completion.
+ virtual int GetBlacklistLogins(PasswordStoreConsumer* consumer);
// Cancels a previous Get*Logins query (async)
virtual void CancelLoginsQuery(int handle);
@@ -108,10 +108,10 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> {
const base::Time& delete_end) = 0;
virtual void GetLoginsImpl(GetLoginsRequest* request,
const webkit_glue::PasswordForm& form) = 0;
- // Finds all PasswordForms, and notifies the consumer.
- virtual void GetAllLoginsImpl(GetLoginsRequest* request) = 0;
// Finds all non-blacklist PasswordForms, and notifies the consumer.
- virtual void GetAllAutofillableLoginsImpl(GetLoginsRequest* request) = 0;
+ virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request) = 0;
+ // Finds all blacklist PasswordForms, and notifies the consumer.
+ virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request) = 0;
// Notifies the consumer that a Get*Logins() request is complete.
void NotifyConsumer(GetLoginsRequest* request,
diff --git a/chrome/browser/password_manager/password_store_default.cc b/chrome/browser/password_manager/password_store_default.cc
index 4fdd1afc..c27d932 100644
--- a/chrome/browser/password_manager/password_store_default.cc
+++ b/chrome/browser/password_manager/password_store_default.cc
@@ -49,16 +49,17 @@ int PasswordStoreDefault::GetLogins(const PasswordForm& form,
return CreateNewRequestForQuery(web_data_handle, consumer);
}
-int PasswordStoreDefault::GetAllLogins(PasswordStoreConsumer* consumer) {
+int PasswordStoreDefault::GetAutofillableLogins(
+ PasswordStoreConsumer* consumer) {
WebDataService::Handle web_data_handle =
- web_data_service_->GetAllLogins(this);
+ web_data_service_->GetAutofillableLogins(this);
return CreateNewRequestForQuery(web_data_handle, consumer);
}
-int PasswordStoreDefault::GetAllAutofillableLogins(
+int PasswordStoreDefault::GetBlacklistLogins(
PasswordStoreConsumer* consumer) {
WebDataService::Handle web_data_handle =
- web_data_service_->GetAllAutofillableLogins(this);
+ web_data_service_->GetBlacklistLogins(this);
return CreateNewRequestForQuery(web_data_handle, consumer);
}
@@ -97,11 +98,12 @@ void PasswordStoreDefault::GetLoginsImpl(
NOTREACHED();
}
-void PasswordStoreDefault::GetAllLoginsImpl(GetLoginsRequest* request) {
+void PasswordStoreDefault::GetAutofillableLoginsImpl(
+ GetLoginsRequest* request) {
NOTREACHED();
}
-void PasswordStoreDefault::GetAllAutofillableLoginsImpl(
+void PasswordStoreDefault::GetBlacklistLoginsImpl(
GetLoginsRequest* request) {
NOTREACHED();
}
diff --git a/chrome/browser/password_manager/password_store_default.h b/chrome/browser/password_manager/password_store_default.h
index aba016b..dad6e28 100644
--- a/chrome/browser/password_manager/password_store_default.h
+++ b/chrome/browser/password_manager/password_store_default.h
@@ -36,8 +36,8 @@ class PasswordStoreDefault : public PasswordStore,
const base::Time& delete_end);
virtual int GetLogins(const webkit_glue::PasswordForm& form,
PasswordStoreConsumer* consumer);
- virtual int GetAllLogins(PasswordStoreConsumer* consumer);
- virtual int GetAllAutofillableLogins(PasswordStoreConsumer* consumer);
+ virtual int GetAutofillableLogins(PasswordStoreConsumer* consumer);
+ virtual int GetBlacklistLogins(PasswordStoreConsumer* consumer);
virtual void CancelLoginsQuery(int handle);
protected:
@@ -49,8 +49,8 @@ class PasswordStoreDefault : public PasswordStore,
const base::Time& delete_end);
void GetLoginsImpl(GetLoginsRequest* request,
const webkit_glue::PasswordForm& form);
- void GetAllLoginsImpl(GetLoginsRequest* request);
- void GetAllAutofillableLoginsImpl(GetLoginsRequest* request);
+ void GetAutofillableLoginsImpl(GetLoginsRequest* request);
+ void GetBlacklistLoginsImpl(GetLoginsRequest* request);
// Called when a WebDataService method finishes.
virtual void OnWebDataServiceRequestDone(WebDataService::Handle h,
diff --git a/chrome/browser/password_manager/password_store_mac.cc b/chrome/browser/password_manager/password_store_mac.cc
index d5327be..cc05047 100644
--- a/chrome/browser/password_manager/password_store_mac.cc
+++ b/chrome/browser/password_manager/password_store_mac.cc
@@ -804,24 +804,15 @@ void PasswordStoreMac::GetLoginsImpl(GetLoginsRequest* request,
NotifyConsumer(request, merged_forms);
}
-void PasswordStoreMac::GetAllLoginsImpl(GetLoginsRequest* request) {
+void PasswordStoreMac::GetBlacklistLoginsImpl(GetLoginsRequest* request) {
std::vector<PasswordForm*> database_forms;
- login_metadata_db_->GetAllLogins(&database_forms, true);
-
- std::vector<PasswordForm*> merged_forms =
- internal_keychain_helpers::GetPasswordsForForms(*keychain_,
- &database_forms);
-
- // Clean up any orphaned database entries.
- RemoveDatabaseForms(database_forms);
- STLDeleteElements(&database_forms);
-
- NotifyConsumer(request, merged_forms);
+ login_metadata_db_->GetBlacklistLogins(&database_forms);
+ NotifyConsumer(request, database_forms);
}
-void PasswordStoreMac::GetAllAutofillableLoginsImpl(GetLoginsRequest* request) {
+void PasswordStoreMac::GetAutofillableLoginsImpl(GetLoginsRequest* request) {
std::vector<PasswordForm*> database_forms;
- login_metadata_db_->GetAllLogins(&database_forms, false);
+ login_metadata_db_->GetAutofillableLogins(&database_forms);
std::vector<PasswordForm*> merged_forms =
internal_keychain_helpers::GetPasswordsForForms(*keychain_,
@@ -861,7 +852,7 @@ bool PasswordStoreMac::DatabaseHasFormMatchingKeychainForm(
std::vector<PasswordForm*> PasswordStoreMac::GetUnusedKeychainForms() {
std::vector<PasswordForm*> database_forms;
- login_metadata_db_->GetAllLogins(&database_forms, false);
+ login_metadata_db_->GetAutofillableLogins(&database_forms);
MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get());
owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
diff --git a/chrome/browser/password_manager/password_store_mac.h b/chrome/browser/password_manager/password_store_mac.h
index 7874c24..45ca859 100644
--- a/chrome/browser/password_manager/password_store_mac.h
+++ b/chrome/browser/password_manager/password_store_mac.h
@@ -33,8 +33,8 @@ class PasswordStoreMac : public PasswordStore {
const base::Time& delete_end);
void GetLoginsImpl(GetLoginsRequest* request,
const webkit_glue::PasswordForm& form);
- void GetAllLoginsImpl(GetLoginsRequest* request);
- void GetAllAutofillableLoginsImpl(GetLoginsRequest* request);
+ void GetAutofillableLoginsImpl(GetLoginsRequest* request);
+ void GetBlacklistLoginsImpl(GetLoginsRequest* request);
// Adds the given form to the Keychain if it's something we want to store
// there (i.e., not a blacklist entry). Returns true if the operation
diff --git a/chrome/browser/views/options/exceptions_page_view.cc b/chrome/browser/views/options/exceptions_page_view.cc
index db1069a..a77ce01 100644
--- a/chrome/browser/views/options/exceptions_page_view.cc
+++ b/chrome/browser/views/options/exceptions_page_view.cc
@@ -41,7 +41,7 @@ int ExceptionsTableModel::CompareValues(int row1, int row2,
void ExceptionsTableModel::GetAllExceptionsForProfile() {
DCHECK(!pending_login_query_);
- pending_login_query_ = password_store()->GetAllLogins(this);
+ pending_login_query_ = password_store()->GetBlacklistLogins(this);
}
void ExceptionsTableModel::OnPasswordStoreRequestDone(
@@ -53,10 +53,8 @@ void ExceptionsTableModel::OnPasswordStoreRequestDone(
std::wstring languages =
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
for (size_t i = 0; i < result.size(); ++i) {
- if (result[i]->blacklisted_by_user) {
- saved_signons_.push_back(new PasswordRow(
- gfx::SortedDisplayURL(result[i]->origin, languages), result[i]));
- }
+ saved_signons_.push_back(new PasswordRow(
+ gfx::SortedDisplayURL(result[i]->origin, languages), result[i]));
}
if (observer_)
observer_->OnModelChanged();
diff --git a/chrome/browser/views/options/passwords_page_view.cc b/chrome/browser/views/options/passwords_page_view.cc
index e32ae55..bee94c3 100644
--- a/chrome/browser/views/options/passwords_page_view.cc
+++ b/chrome/browser/views/options/passwords_page_view.cc
@@ -105,7 +105,7 @@ void PasswordsTableModel::SetObserver(TableModelObserver* observer) {
void PasswordsTableModel::GetAllSavedLoginsForProfile() {
DCHECK(!pending_login_query_);
- pending_login_query_ = password_store()->GetAllAutofillableLogins(this);
+ pending_login_query_ = password_store()->GetAutofillableLogins(this);
}
void PasswordsTableModel::OnPasswordStoreRequestDone(
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index b93ae6d..c428729 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -362,23 +362,24 @@ WebDataService::Handle WebDataService::GetLogins(
return request->GetHandle();
}
-WebDataService::Handle WebDataService::GetAllAutofillableLogins(
+WebDataService::Handle WebDataService::GetAutofillableLogins(
WebDataServiceConsumer* consumer) {
WebDataRequest* request =
new WebDataRequest(this, GetNextRequestHandle(), consumer);
RegisterRequest(request);
ScheduleTask(NewRunnableMethod(this,
- &WebDataService::GetAllAutofillableLoginsImpl,
+ &WebDataService::GetAutofillableLoginsImpl,
request));
return request->GetHandle();
}
-WebDataService::Handle WebDataService::GetAllLogins(
- WebDataServiceConsumer* consumer) {
+WebDataService::Handle WebDataService::GetBlacklistLogins(
+ WebDataServiceConsumer* consumer) {
WebDataRequest* request =
new WebDataRequest(this, GetNextRequestHandle(), consumer);
RegisterRequest(request);
- ScheduleTask(NewRunnableMethod(this, &WebDataService::GetAllLoginsImpl,
+ ScheduleTask(NewRunnableMethod(this,
+ &WebDataService::GetBlacklistLoginsImpl,
request));
return request->GetHandle();
}
@@ -536,7 +537,7 @@ void WebDataService::GetLoginsImpl(GenericRequest<PasswordForm>* request) {
request->RequestComplete();
}
-void WebDataService::GetAllAutofillableLoginsImpl(WebDataRequest* request) {
+void WebDataService::GetAutofillableLoginsImpl(WebDataRequest* request) {
if (db_ && !request->IsCancelled()) {
std::vector<PasswordForm*> forms;
db_->GetAllLogins(&forms, false);
@@ -546,12 +547,22 @@ void WebDataService::GetAllAutofillableLoginsImpl(WebDataRequest* request) {
request->RequestComplete();
}
-void WebDataService::GetAllLoginsImpl(WebDataRequest* request) {
+void WebDataService::GetBlacklistLoginsImpl(WebDataRequest* request) {
if (db_ && !request->IsCancelled()) {
- std::vector<PasswordForm*> forms;
- db_->GetAllLogins(&forms, true);
+ std::vector<PasswordForm*> all_forms;
+ db_->GetAllLogins(&all_forms, true);
+ std::vector<PasswordForm*> blacklist_forms;
+ for (std::vector<PasswordForm*>::iterator i = all_forms.begin();
+ i != all_forms.end(); ++i) {
+ scoped_ptr<PasswordForm> form(*i);
+ if (form->blacklisted_by_user) {
+ blacklist_forms.push_back(form.release());
+ }
+ }
+ all_forms.clear();
request->SetResult(
- new WDResult<std::vector<PasswordForm*> >(PASSWORD_RESULT, forms));
+ new WDResult<std::vector<PasswordForm*> >(PASSWORD_RESULT,
+ blacklist_forms));
}
request->RequestComplete();
}
diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h
index 9e52ba8..539ece9 100644
--- a/chrome/browser/webdata/web_data_service.h
+++ b/chrome/browser/webdata/web_data_service.h
@@ -340,13 +340,13 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> {
// |consumer| will be notified when the request is done. The result is of
// type WDResult<std::vector<PasswordForm*>>.
// The result will be null on failure. The |consumer| owns all PasswordForms.
- Handle GetAllAutofillableLogins(WebDataServiceConsumer* consumer);
+ Handle GetAutofillableLogins(WebDataServiceConsumer* consumer);
- // Gets the complete list of password forms.
+ // Gets the complete list of password forms that have been blacklisted.
// |consumer| will be notified when the request is done. The result is of
// type WDResult<std::vector<PasswordForm*>>.
// The result will be null on failure. The |consumer| owns all PasswordForm's.
- Handle GetAllLogins(WebDataServiceConsumer* consumer);
+ Handle GetBlacklistLogins(WebDataServiceConsumer* consumer);
#if defined(OS_WIN)
// Adds |info| to the list of imported passwords from ie7/ie8.
@@ -450,8 +450,8 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> {
void RemoveLoginsCreatedBetweenImpl(
GenericRequest2<base::Time, base::Time>* request);
void GetLoginsImpl(GenericRequest<webkit_glue::PasswordForm>* request);
- void GetAllAutofillableLoginsImpl(WebDataRequest* request);
- void GetAllLoginsImpl(WebDataRequest* request);
+ void GetAutofillableLoginsImpl(WebDataRequest* request);
+ void GetBlacklistLoginsImpl(WebDataRequest* request);
#if defined(OS_WIN)
void AddIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request);
void RemoveIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request);