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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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-inl.h" 10 #include "base/stl_util-inl.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/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "content/browser/browser_thread.h" 18 #include "content/browser/browser_thread.h"
18 #include "content/common/notification_service.h" 19 #include "content/common/notification_service.h"
19 20
20 using webkit_glue::PasswordForm; 21 using webkit_glue::PasswordForm;
21 22
22 // MigrateHelper handles migration from WebDB to PasswordStore. It runs 23 // MigrateHelper handles migration from WebDB to PasswordStore. It runs
23 // entirely on the UI thread and is owned by PasswordStoreDefault. 24 // entirely on the UI thread and is owned by PasswordStoreDefault.
24 class PasswordStoreDefault::MigrateHelper : public WebDataServiceConsumer { 25 class PasswordStoreDefault::MigrateHelper : public WebDataServiceConsumer {
25 public: 26 public:
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 void PasswordStoreDefault::ReportMetricsImpl() { 124 void PasswordStoreDefault::ReportMetricsImpl() {
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
125 login_db_->ReportMetrics(); 126 login_db_->ReportMetrics();
126 } 127 }
127 128
128 void PasswordStoreDefault::AddLoginImpl(const PasswordForm& form) { 129 void PasswordStoreDefault::AddLoginImpl(const PasswordForm& form) {
129 if (login_db_->AddLogin(form)) { 130 if (login_db_->AddLogin(form)) {
130 PasswordStoreChangeList changes; 131 PasswordStoreChangeList changes;
131 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); 132 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form));
132 NotificationService::current()->Notify( 133 NotificationService::current()->Notify(
133 NotificationType::LOGINS_CHANGED, 134 chrome::NOTIFICATION_LOGINS_CHANGED,
134 Source<PasswordStore>(this), 135 Source<PasswordStore>(this),
135 Details<PasswordStoreChangeList>(&changes)); 136 Details<PasswordStoreChangeList>(&changes));
136 } 137 }
137 } 138 }
138 139
139 void PasswordStoreDefault::UpdateLoginImpl(const PasswordForm& form) { 140 void PasswordStoreDefault::UpdateLoginImpl(const PasswordForm& form) {
140 if (login_db_->UpdateLogin(form, NULL)) { 141 if (login_db_->UpdateLogin(form, NULL)) {
141 PasswordStoreChangeList changes; 142 PasswordStoreChangeList changes;
142 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form)); 143 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form));
143 NotificationService::current()->Notify( 144 NotificationService::current()->Notify(
144 NotificationType::LOGINS_CHANGED, 145 chrome::NOTIFICATION_LOGINS_CHANGED,
145 Source<PasswordStore>(this), 146 Source<PasswordStore>(this),
146 Details<PasswordStoreChangeList>(&changes)); 147 Details<PasswordStoreChangeList>(&changes));
147 } 148 }
148 } 149 }
149 150
150 void PasswordStoreDefault::RemoveLoginImpl(const PasswordForm& form) { 151 void PasswordStoreDefault::RemoveLoginImpl(const PasswordForm& form) {
151 if (login_db_->RemoveLogin(form)) { 152 if (login_db_->RemoveLogin(form)) {
152 PasswordStoreChangeList changes; 153 PasswordStoreChangeList changes;
153 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); 154 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form));
154 NotificationService::current()->Notify( 155 NotificationService::current()->Notify(
155 NotificationType::LOGINS_CHANGED, 156 chrome::NOTIFICATION_LOGINS_CHANGED,
156 Source<PasswordStore>(this), 157 Source<PasswordStore>(this),
157 Details<PasswordStoreChangeList>(&changes)); 158 Details<PasswordStoreChangeList>(&changes));
158 } 159 }
159 } 160 }
160 161
161 void PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl( 162 void PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl(
162 const base::Time& delete_begin, const base::Time& delete_end) { 163 const base::Time& delete_begin, const base::Time& delete_end) {
163 std::vector<PasswordForm*> forms; 164 std::vector<PasswordForm*> forms;
164 if (login_db_->GetLoginsCreatedBetween(delete_begin, delete_end, &forms)) { 165 if (login_db_->GetLoginsCreatedBetween(delete_begin, delete_end, &forms)) {
165 if (login_db_->RemoveLoginsCreatedBetween(delete_begin, delete_end)) { 166 if (login_db_->RemoveLoginsCreatedBetween(delete_begin, delete_end)) {
166 PasswordStoreChangeList changes; 167 PasswordStoreChangeList changes;
167 for (std::vector<PasswordForm*>::const_iterator it = forms.begin(); 168 for (std::vector<PasswordForm*>::const_iterator it = forms.begin();
168 it != forms.end(); ++it) { 169 it != forms.end(); ++it) {
169 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, 170 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE,
170 **it)); 171 **it));
171 } 172 }
172 NotificationService::current()->Notify( 173 NotificationService::current()->Notify(
173 NotificationType::LOGINS_CHANGED, 174 chrome::NOTIFICATION_LOGINS_CHANGED,
174 Source<PasswordStore>(this), 175 Source<PasswordStore>(this),
175 Details<PasswordStoreChangeList>(&changes)); 176 Details<PasswordStoreChangeList>(&changes));
176 } 177 }
177 } 178 }
178 STLDeleteElements(&forms); 179 STLDeleteElements(&forms);
179 } 180 }
180 181
181 void PasswordStoreDefault::GetLoginsImpl( 182 void PasswordStoreDefault::GetLoginsImpl(
182 GetLoginsRequest* request, const webkit_glue::PasswordForm& form) { 183 GetLoginsRequest* request, const webkit_glue::PasswordForm& form) {
183 login_db_->GetLogins(form, &request->value); 184 login_db_->GetLogins(form, &request->value);
(...skipping 25 matching lines...) Expand all
209 } 210 }
210 211
211 void PasswordStoreDefault::MigrateIfNecessary() { 212 void PasswordStoreDefault::MigrateIfNecessary() {
212 PrefService* prefs = profile_->GetPrefs(); 213 PrefService* prefs = profile_->GetPrefs();
213 if (prefs->FindPreference(prefs::kLoginDatabaseMigrated)) 214 if (prefs->FindPreference(prefs::kLoginDatabaseMigrated))
214 return; 215 return;
215 DCHECK(!migrate_helper_.get()); 216 DCHECK(!migrate_helper_.get());
216 migrate_helper_.reset(new MigrateHelper(profile_, web_data_service_, this)); 217 migrate_helper_.reset(new MigrateHelper(profile_, web_data_service_, this));
217 migrate_helper_->Init(); 218 migrate_helper_->Init();
218 } 219 }
OLDNEW
« no previous file with comments | « chrome/browser/omnibox_search_hint.cc ('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