Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_store_default.h" | 5 #include "chrome/browser/password_manager/password_store_default.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); | 66 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); |
| 67 NotificationService::current()->Notify( | 67 NotificationService::current()->Notify( |
| 68 NotificationType::LOGINS_CHANGED, | 68 NotificationType::LOGINS_CHANGED, |
| 69 Source<PasswordStore>(this), | 69 Source<PasswordStore>(this), |
| 70 Details<PasswordStoreChangeList>(&changes)); | 70 Details<PasswordStoreChangeList>(&changes)); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 void PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl( | 74 void PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl( |
| 75 const base::Time& delete_begin, const base::Time& delete_end) { | 75 const base::Time& delete_begin, const base::Time& delete_end) { |
| 76 | |
|
James Hawkins
2011/03/16 22:39:35
Remove blank line.
| |
| 76 std::vector<PasswordForm*> forms; | 77 std::vector<PasswordForm*> forms; |
| 77 if (login_db_->GetLoginsCreatedBetween(delete_begin, delete_end, &forms)) { | 78 if (login_db_->GetLoginsCreatedBetween(delete_begin, delete_end, &forms)) { |
| 78 if (login_db_->RemoveLoginsCreatedBetween(delete_begin, delete_end)) { | 79 if (login_db_->RemoveLoginsCreatedBetween(delete_begin, delete_end)) { |
| 79 PasswordStoreChangeList changes; | 80 PasswordStoreChangeList changes; |
| 80 for (std::vector<PasswordForm*>::const_iterator it = forms.begin(); | 81 for (std::vector<PasswordForm*>::const_iterator it = forms.begin(); |
| 81 it != forms.end(); ++it) { | 82 it != forms.end(); ++it) { |
| 82 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, | 83 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, |
| 83 **it)); | 84 **it)); |
| 84 } | 85 } |
| 85 NotificationService::current()->Notify( | 86 NotificationService::current()->Notify( |
| 86 NotificationType::LOGINS_CHANGED, | 87 NotificationType::LOGINS_CHANGED, |
| 87 Source<PasswordStore>(this), | 88 Source<PasswordStore>(this), |
| 88 Details<PasswordStoreChangeList>(&changes)); | 89 Details<PasswordStoreChangeList>(&changes)); |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 STLDeleteElements(&forms); | 92 STLDeleteElements(&forms); |
| 92 } | 93 } |
| 93 | 94 |
| 94 void PasswordStoreDefault::GetLoginsImpl( | 95 void PasswordStoreDefault::GetLoginsImpl( |
| 95 GetLoginsRequest* request, const webkit_glue::PasswordForm& form) { | 96 GetLoginsRequest* request, const webkit_glue::PasswordForm& form) { |
| 96 std::vector<PasswordForm*> forms; | 97 login_db_->GetLogins(form, &request->value); |
| 97 login_db_->GetLogins(form, &forms); | 98 ForwardLoginsResult(request); |
| 98 NotifyConsumer(request, forms); | |
| 99 } | 99 } |
| 100 | 100 |
| 101 void PasswordStoreDefault::GetAutofillableLoginsImpl( | 101 void PasswordStoreDefault::GetAutofillableLoginsImpl( |
| 102 GetLoginsRequest* request) { | 102 GetLoginsRequest* request) { |
| 103 std::vector<PasswordForm*> forms; | 103 FillAutofillableLogins(&request->value); |
| 104 FillAutofillableLogins(&forms); | 104 ForwardLoginsResult(request); |
| 105 NotifyConsumer(request, forms); | |
| 106 } | 105 } |
| 107 | 106 |
| 108 void PasswordStoreDefault::GetBlacklistLoginsImpl( | 107 void PasswordStoreDefault::GetBlacklistLoginsImpl( |
| 109 GetLoginsRequest* request) { | 108 GetLoginsRequest* request) { |
| 110 std::vector<PasswordForm*> forms; | 109 FillBlacklistLogins(&request->value); |
| 111 FillBlacklistLogins(&forms); | 110 ForwardLoginsResult(request); |
| 112 NotifyConsumer(request, forms); | |
| 113 } | 111 } |
| 114 | 112 |
| 115 bool PasswordStoreDefault::FillAutofillableLogins( | 113 bool PasswordStoreDefault::FillAutofillableLogins( |
| 116 std::vector<PasswordForm*>* forms) { | 114 std::vector<PasswordForm*>* forms) { |
| 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 118 return login_db_->GetAutofillableLogins(forms); | 116 return login_db_->GetAutofillableLogins(forms); |
| 119 } | 117 } |
| 120 | 118 |
| 121 bool PasswordStoreDefault::FillBlacklistLogins( | 119 bool PasswordStoreDefault::FillBlacklistLogins( |
| 122 std::vector<PasswordForm*>* forms) { | 120 std::vector<PasswordForm*>* forms) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 it != forms.end(); ++it) { | 152 it != forms.end(); ++it) { |
| 155 AddLogin(**it); | 153 AddLogin(**it); |
| 156 web_data_service_->RemoveLogin(**it); | 154 web_data_service_->RemoveLogin(**it); |
| 157 delete *it; | 155 delete *it; |
| 158 } | 156 } |
| 159 if (handles_.empty()) { | 157 if (handles_.empty()) { |
| 160 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 158 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 161 true); | 159 true); |
| 162 } | 160 } |
| 163 } | 161 } |
| OLD | NEW |