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

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

Issue 10227014: Remove the very old code that migrated password data from the WebDataService to PasswordStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/password_store_default.cc
===================================================================
--- chrome/browser/password_manager/password_store_default.cc (revision 133948)
+++ chrome/browser/password_manager/password_store_default.cc (working copy)
@@ -11,7 +11,6 @@
#include "chrome/browser/password_manager/password_store_change.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
@@ -21,106 +20,18 @@
using content::BrowserThread;
using webkit::forms::PasswordForm;
-// MigrateHelper handles migration from WebDB to PasswordStore. It runs
-// entirely on the UI thread and is owned by PasswordStoreDefault.
-class PasswordStoreDefault::MigrateHelper : public WebDataServiceConsumer {
- public:
- MigrateHelper(Profile* profile,
- WebDataService* web_data_service,
- PasswordStore* password_store)
- : profile_(profile),
- web_data_service_(web_data_service),
- password_store_(password_store) {
- }
- ~MigrateHelper();
-
- void Init();
-
- // WebDataServiceConsumer:
- virtual void OnWebDataServiceRequestDone(
- WebDataService::Handle handle,
- const WDTypedResult *result) OVERRIDE;
-
- private:
- typedef std::set<WebDataService::Handle> Handles;
-
- Profile* profile_;
-
- scoped_refptr<WebDataService> web_data_service_;
-
- // This creates a cycle between us and PasswordStore. The cycle is broken
- // from PasswordStoreDefault::Shutdown, which deletes us.
- scoped_refptr<PasswordStore> password_store_;
-
- // Set of handles from requesting data from the WebDB.
- Handles handles_;
-
- DISALLOW_COPY_AND_ASSIGN(MigrateHelper);
-};
-
-PasswordStoreDefault::MigrateHelper::~MigrateHelper() {
- for (Handles::const_iterator i = handles_.begin(); i != handles_.end(); ++i)
- web_data_service_->CancelRequest(*i);
- handles_.clear();
-}
-
-void PasswordStoreDefault::MigrateHelper::Init() {
- handles_.insert(web_data_service_->GetAutofillableLogins(this));
- handles_.insert(web_data_service_->GetBlacklistLogins(this));
-}
-
-void PasswordStoreDefault::MigrateHelper::OnWebDataServiceRequestDone(
- WebDataService::Handle handle,
- const WDTypedResult* result) {
- typedef std::vector<const PasswordForm*> PasswordForms;
-
- DCHECK(handles_.end() != handles_.find(handle));
- DCHECK(password_store_);
-
- handles_.erase(handle);
- if (!result)
- return;
-
- if (PASSWORD_RESULT != result->GetType()) {
- NOTREACHED();
- return;
- }
-
- const PasswordForms& forms =
- static_cast<const WDResult<PasswordForms>*>(result)->GetValue();
- for (PasswordForms::const_iterator it = forms.begin();
- it != forms.end(); ++it) {
- password_store_->AddLogin(**it);
- web_data_service_->RemoveLogin(**it);
- delete *it;
- }
- if (handles_.empty()) {
- profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated,
- true,
- PrefService::UNSYNCABLE_PREF);
- }
-}
-
PasswordStoreDefault::PasswordStoreDefault(LoginDatabase* login_db,
- Profile* profile,
- WebDataService* web_data_service)
- : web_data_service_(web_data_service),
- login_db_(login_db), profile_(profile) {
+ Profile* profile)
+ : login_db_(login_db), profile_(profile) {
DCHECK(login_db);
DCHECK(profile);
- DCHECK(web_data_service);
- MigrateIfNecessary();
}
PasswordStoreDefault::~PasswordStoreDefault() {
- // MigrateHelper should always be NULL as Shutdown should be invoked before
- // the destructor.
- DCHECK(!migrate_helper_.get());
}
void PasswordStoreDefault::ShutdownOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- migrate_helper_.reset();
profile_ = NULL;
}
@@ -211,12 +122,3 @@
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
return login_db_->GetBlacklistLogins(forms);
}
-
-void PasswordStoreDefault::MigrateIfNecessary() {
- PrefService* prefs = profile_->GetPrefs();
- if (prefs->FindPreference(prefs::kLoginDatabaseMigrated))
- return;
- DCHECK(!migrate_helper_.get());
- migrate_helper_.reset(new MigrateHelper(profile_, web_data_service_, this));
- migrate_helper_->Init();
-}

Powered by Google App Engine
This is Rietveld 408576698