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

Side by Side Diff: chrome/browser/sync/glue/password_change_processor.cc

Issue 11000016: Move forms/ out of webkit/. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Response to review Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sync/glue/password_change_processor.h" 5 #include "chrome/browser/sync/glue/password_change_processor.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/password_manager/password_store.h" 12 #include "chrome/browser/password_manager/password_store.h"
13 #include "chrome/browser/password_manager/password_store_change.h" 13 #include "chrome/browser/password_manager/password_store_change.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/sync/glue/password_model_associator.h" 15 #include "chrome/browser/sync/glue/password_model_associator.h"
16 #include "chrome/browser/sync/profile_sync_service.h" 16 #include "chrome/browser/sync/profile_sync_service.h"
17 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "content/public/browser/notification_details.h" 19 #include "content/public/browser/notification_details.h"
20 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
21 #include "content/public/common/password_form.h"
21 #include "sync/internal_api/public/change_record.h" 22 #include "sync/internal_api/public/change_record.h"
22 #include "sync/internal_api/public/read_node.h" 23 #include "sync/internal_api/public/read_node.h"
23 #include "sync/internal_api/public/write_node.h" 24 #include "sync/internal_api/public/write_node.h"
24 #include "sync/internal_api/public/write_transaction.h" 25 #include "sync/internal_api/public/write_transaction.h"
25 #include "sync/protocol/password_specifics.pb.h" 26 #include "sync/protocol/password_specifics.pb.h"
26 #include "webkit/forms/password_form.h"
27 27
28 using content::BrowserThread; 28 using content::BrowserThread;
29 29
30 namespace browser_sync { 30 namespace browser_sync {
31 31
32 PasswordChangeProcessor::PasswordChangeProcessor( 32 PasswordChangeProcessor::PasswordChangeProcessor(
33 PasswordModelAssociator* model_associator, 33 PasswordModelAssociator* model_associator,
34 PasswordStore* password_store, 34 PasswordStore* password_store,
35 DataTypeErrorHandler* error_handler) 35 DataTypeErrorHandler* error_handler)
36 : ChangeProcessor(error_handler), 36 : ChangeProcessor(error_handler),
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 for (syncer::ChangeRecordList::const_iterator it = 185 for (syncer::ChangeRecordList::const_iterator it =
186 changes.Get().begin(); it != changes.Get().end(); ++it) { 186 changes.Get().begin(); it != changes.Get().end(); ++it) {
187 if (syncer::ChangeRecord::ACTION_DELETE == 187 if (syncer::ChangeRecord::ACTION_DELETE ==
188 it->action) { 188 it->action) {
189 DCHECK(it->specifics.has_password()) 189 DCHECK(it->specifics.has_password())
190 << "Password specifics data not present on delete!"; 190 << "Password specifics data not present on delete!";
191 DCHECK(it->extra.get()); 191 DCHECK(it->extra.get());
192 syncer::ExtraPasswordChangeRecordData* extra = 192 syncer::ExtraPasswordChangeRecordData* extra =
193 it->extra.get(); 193 it->extra.get();
194 const sync_pb::PasswordSpecificsData& password = extra->unencrypted(); 194 const sync_pb::PasswordSpecificsData& password = extra->unencrypted();
195 webkit::forms::PasswordForm form; 195 content::PasswordForm form;
196 PasswordModelAssociator::CopyPassword(password, &form); 196 PasswordModelAssociator::CopyPassword(password, &form);
197 deleted_passwords_.push_back(form); 197 deleted_passwords_.push_back(form);
198 model_associator_->Disassociate(it->id); 198 model_associator_->Disassociate(it->id);
199 continue; 199 continue;
200 } 200 }
201 201
202 syncer::ReadNode sync_node(trans); 202 syncer::ReadNode sync_node(trans);
203 if (sync_node.InitByIdLookup(it->id) != syncer::BaseNode::INIT_OK) { 203 if (sync_node.InitByIdLookup(it->id) != syncer::BaseNode::INIT_OK) {
204 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 204 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
205 "Password node lookup failed."); 205 "Password node lookup failed.");
206 return; 206 return;
207 } 207 }
208 208
209 // Check that the changed node is a child of the passwords folder. 209 // Check that the changed node is a child of the passwords folder.
210 DCHECK_EQ(password_root.GetId(), sync_node.GetParentId()); 210 DCHECK_EQ(password_root.GetId(), sync_node.GetParentId());
211 DCHECK_EQ(syncer::PASSWORDS, sync_node.GetModelType()); 211 DCHECK_EQ(syncer::PASSWORDS, sync_node.GetModelType());
212 212
213 const sync_pb::PasswordSpecificsData& password_data = 213 const sync_pb::PasswordSpecificsData& password_data =
214 sync_node.GetPasswordSpecifics(); 214 sync_node.GetPasswordSpecifics();
215 webkit::forms::PasswordForm password; 215 content::PasswordForm password;
216 PasswordModelAssociator::CopyPassword(password_data, &password); 216 PasswordModelAssociator::CopyPassword(password_data, &password);
217 217
218 if (syncer::ChangeRecord::ACTION_ADD == it->action) { 218 if (syncer::ChangeRecord::ACTION_ADD == it->action) {
219 std::string tag(PasswordModelAssociator::MakeTag(password)); 219 std::string tag(PasswordModelAssociator::MakeTag(password));
220 model_associator_->Associate(&tag, sync_node.GetId()); 220 model_associator_->Associate(&tag, sync_node.GetId());
221 new_passwords_.push_back(password); 221 new_passwords_.push_back(password);
222 } else { 222 } else {
223 DCHECK_EQ(syncer::ChangeRecord::ACTION_UPDATE, it->action); 223 DCHECK_EQ(syncer::ChangeRecord::ACTION_UPDATE, it->action);
224 updated_passwords_.push_back(password); 224 updated_passwords_.push_back(password);
225 } 225 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 void PasswordChangeProcessor::StopObserving() { 268 void PasswordChangeProcessor::StopObserving() {
269 DCHECK(expected_loop_ == MessageLoop::current()); 269 DCHECK(expected_loop_ == MessageLoop::current());
270 notification_registrar_.Remove( 270 notification_registrar_.Remove(
271 this, 271 this,
272 chrome::NOTIFICATION_LOGINS_CHANGED, 272 chrome::NOTIFICATION_LOGINS_CHANGED,
273 content::Source<PasswordStore>(password_store_)); 273 content::Source<PasswordStore>(password_store_));
274 } 274 }
275 275
276 } // namespace browser_sync 276 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_x_unittest.cc ('k') | chrome/browser/sync/glue/password_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698