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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
OLDNEW
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 <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "chrome/browser/password_manager/password_store_change.h" 11 #include "chrome/browser/password_manager/password_store_change.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/webdata/web_data_service.h" 14 #include "chrome/browser/webdata/web_data_service.h"
15 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "content/browser/browser_thread.h" 18 #include "content/browser/browser_thread.h"
19 #include "content/common/notification_service.h" 19 #include "content/public/browser/notification_service.h"
20 20
21 using webkit_glue::PasswordForm; 21 using webkit_glue::PasswordForm;
22 22
23 // MigrateHelper handles migration from WebDB to PasswordStore. It runs 23 // MigrateHelper handles migration from WebDB to PasswordStore. It runs
24 // entirely on the UI thread and is owned by PasswordStoreDefault. 24 // entirely on the UI thread and is owned by PasswordStoreDefault.
25 class PasswordStoreDefault::MigrateHelper : public WebDataServiceConsumer { 25 class PasswordStoreDefault::MigrateHelper : public WebDataServiceConsumer {
26 public: 26 public:
27 MigrateHelper(Profile* profile, 27 MigrateHelper(Profile* profile,
28 WebDataService* web_data_service, 28 WebDataService* web_data_service,
29 PasswordStore* password_store) 29 PasswordStore* password_store)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 void PasswordStoreDefault::ReportMetricsImpl() { 124 void PasswordStoreDefault::ReportMetricsImpl() {
125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
126 login_db_->ReportMetrics(); 126 login_db_->ReportMetrics();
127 } 127 }
128 128
129 void PasswordStoreDefault::AddLoginImpl(const PasswordForm& form) { 129 void PasswordStoreDefault::AddLoginImpl(const PasswordForm& form) {
130 if (login_db_->AddLogin(form)) { 130 if (login_db_->AddLogin(form)) {
131 PasswordStoreChangeList changes; 131 PasswordStoreChangeList changes;
132 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); 132 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form));
133 NotificationService::current()->Notify( 133 content::NotificationService::current()->Notify(
134 chrome::NOTIFICATION_LOGINS_CHANGED, 134 chrome::NOTIFICATION_LOGINS_CHANGED,
135 content::Source<PasswordStore>(this), 135 content::Source<PasswordStore>(this),
136 content::Details<PasswordStoreChangeList>(&changes)); 136 content::Details<PasswordStoreChangeList>(&changes));
137 } 137 }
138 } 138 }
139 139
140 void PasswordStoreDefault::UpdateLoginImpl(const PasswordForm& form) { 140 void PasswordStoreDefault::UpdateLoginImpl(const PasswordForm& form) {
141 if (login_db_->UpdateLogin(form, NULL)) { 141 if (login_db_->UpdateLogin(form, NULL)) {
142 PasswordStoreChangeList changes; 142 PasswordStoreChangeList changes;
143 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form)); 143 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form));
144 NotificationService::current()->Notify( 144 content::NotificationService::current()->Notify(
145 chrome::NOTIFICATION_LOGINS_CHANGED, 145 chrome::NOTIFICATION_LOGINS_CHANGED,
146 content::Source<PasswordStore>(this), 146 content::Source<PasswordStore>(this),
147 content::Details<PasswordStoreChangeList>(&changes)); 147 content::Details<PasswordStoreChangeList>(&changes));
148 } 148 }
149 } 149 }
150 150
151 void PasswordStoreDefault::RemoveLoginImpl(const PasswordForm& form) { 151 void PasswordStoreDefault::RemoveLoginImpl(const PasswordForm& form) {
152 if (login_db_->RemoveLogin(form)) { 152 if (login_db_->RemoveLogin(form)) {
153 PasswordStoreChangeList changes; 153 PasswordStoreChangeList changes;
154 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); 154 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form));
155 NotificationService::current()->Notify( 155 content::NotificationService::current()->Notify(
156 chrome::NOTIFICATION_LOGINS_CHANGED, 156 chrome::NOTIFICATION_LOGINS_CHANGED,
157 content::Source<PasswordStore>(this), 157 content::Source<PasswordStore>(this),
158 content::Details<PasswordStoreChangeList>(&changes)); 158 content::Details<PasswordStoreChangeList>(&changes));
159 } 159 }
160 } 160 }
161 161
162 void PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl( 162 void PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl(
163 const base::Time& delete_begin, const base::Time& delete_end) { 163 const base::Time& delete_begin, const base::Time& delete_end) {
164 std::vector<PasswordForm*> forms; 164 std::vector<PasswordForm*> forms;
165 if (login_db_->GetLoginsCreatedBetween(delete_begin, delete_end, &forms)) { 165 if (login_db_->GetLoginsCreatedBetween(delete_begin, delete_end, &forms)) {
166 if (login_db_->RemoveLoginsCreatedBetween(delete_begin, delete_end)) { 166 if (login_db_->RemoveLoginsCreatedBetween(delete_begin, delete_end)) {
167 PasswordStoreChangeList changes; 167 PasswordStoreChangeList changes;
168 for (std::vector<PasswordForm*>::const_iterator it = forms.begin(); 168 for (std::vector<PasswordForm*>::const_iterator it = forms.begin();
169 it != forms.end(); ++it) { 169 it != forms.end(); ++it) {
170 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, 170 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE,
171 **it)); 171 **it));
172 } 172 }
173 NotificationService::current()->Notify( 173 content::NotificationService::current()->Notify(
174 chrome::NOTIFICATION_LOGINS_CHANGED, 174 chrome::NOTIFICATION_LOGINS_CHANGED,
175 content::Source<PasswordStore>(this), 175 content::Source<PasswordStore>(this),
176 content::Details<PasswordStoreChangeList>(&changes)); 176 content::Details<PasswordStoreChangeList>(&changes));
177 } 177 }
178 } 178 }
179 STLDeleteElements(&forms); 179 STLDeleteElements(&forms);
180 } 180 }
181 181
182 void PasswordStoreDefault::GetLoginsImpl( 182 void PasswordStoreDefault::GetLoginsImpl(
183 GetLoginsRequest* request, const webkit_glue::PasswordForm& form) { 183 GetLoginsRequest* request, const webkit_glue::PasswordForm& form) {
(...skipping 26 matching lines...) Expand all
210 } 210 }
211 211
212 void PasswordStoreDefault::MigrateIfNecessary() { 212 void PasswordStoreDefault::MigrateIfNecessary() {
213 PrefService* prefs = profile_->GetPrefs(); 213 PrefService* prefs = profile_->GetPrefs();
214 if (prefs->FindPreference(prefs::kLoginDatabaseMigrated)) 214 if (prefs->FindPreference(prefs::kLoginDatabaseMigrated))
215 return; 215 return;
216 DCHECK(!migrate_helper_.get()); 216 DCHECK(!migrate_helper_.get());
217 migrate_helper_.reset(new MigrateHelper(profile_, web_data_service_, this)); 217 migrate_helper_.reset(new MigrateHelper(profile_, web_data_service_, this));
218 migrate_helper_->Init(); 218 migrate_helper_->Init();
219 } 219 }
OLDNEW
« no previous file with comments | « chrome/browser/oom_priority_manager_browsertest.cc ('k') | chrome/browser/password_manager/password_store_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698