| OLD | NEW |
| 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_model_associator.h" | 5 #include "chrome/browser/sync/glue/password_model_associator.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace browser_sync { | 25 namespace browser_sync { |
| 26 | 26 |
| 27 const char kPasswordTag[] = "google_chrome_passwords"; | 27 const char kPasswordTag[] = "google_chrome_passwords"; |
| 28 | 28 |
| 29 PasswordModelAssociator::PasswordModelAssociator( | 29 PasswordModelAssociator::PasswordModelAssociator( |
| 30 ProfileSyncService* sync_service, | 30 ProfileSyncService* sync_service, |
| 31 PasswordStore* password_store, | 31 PasswordStore* password_store, |
| 32 DataTypeErrorHandler* error_handler) | 32 DataTypeErrorHandler* error_handler) |
| 33 : sync_service_(sync_service), | 33 : sync_service_(sync_service), |
| 34 password_store_(password_store), | 34 password_store_(password_store), |
| 35 password_node_id_(csync::kInvalidId), | 35 password_node_id_(syncer::kInvalidId), |
| 36 abort_association_pending_(false), | 36 abort_association_pending_(false), |
| 37 expected_loop_(MessageLoop::current()), | 37 expected_loop_(MessageLoop::current()), |
| 38 error_handler_(error_handler) { | 38 error_handler_(error_handler) { |
| 39 DCHECK(sync_service_); | 39 DCHECK(sync_service_); |
| 40 DCHECK(password_store_); | 40 DCHECK(password_store_); |
| 41 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
| 42 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 42 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 43 #else | 43 #else |
| 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 45 #endif | 45 #endif |
| 46 } | 46 } |
| 47 | 47 |
| 48 PasswordModelAssociator::~PasswordModelAssociator() {} | 48 PasswordModelAssociator::~PasswordModelAssociator() {} |
| 49 | 49 |
| 50 csync::SyncError PasswordModelAssociator::AssociateModels() { | 50 syncer::SyncError PasswordModelAssociator::AssociateModels() { |
| 51 csync::SyncError error; | 51 syncer::SyncError error; |
| 52 DCHECK(expected_loop_ == MessageLoop::current()); | 52 DCHECK(expected_loop_ == MessageLoop::current()); |
| 53 { | 53 { |
| 54 base::AutoLock lock(abort_association_pending_lock_); | 54 base::AutoLock lock(abort_association_pending_lock_); |
| 55 abort_association_pending_ = false; | 55 abort_association_pending_ = false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // We must not be holding a transaction when we interact with the password | 58 // We must not be holding a transaction when we interact with the password |
| 59 // store, as it can post tasks to the UI thread which can itself be blocked | 59 // store, as it can post tasks to the UI thread which can itself be blocked |
| 60 // on our transaction, resulting in deadlock. (http://crbug.com/70658) | 60 // on our transaction, resulting in deadlock. (http://crbug.com/70658) |
| 61 std::vector<webkit::forms::PasswordForm*> passwords; | 61 std::vector<webkit::forms::PasswordForm*> passwords; |
| 62 if (!password_store_->FillAutofillableLogins(&passwords) || | 62 if (!password_store_->FillAutofillableLogins(&passwords) || |
| 63 !password_store_->FillBlacklistLogins(&passwords)) { | 63 !password_store_->FillBlacklistLogins(&passwords)) { |
| 64 STLDeleteElements(&passwords); | 64 STLDeleteElements(&passwords); |
| 65 return error_handler_->CreateAndUploadError( | 65 return error_handler_->CreateAndUploadError( |
| 66 FROM_HERE, | 66 FROM_HERE, |
| 67 "Could not get the password entries.", | 67 "Could not get the password entries.", |
| 68 model_type()); | 68 model_type()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 std::set<std::string> current_passwords; | 71 std::set<std::string> current_passwords; |
| 72 PasswordVector new_passwords; | 72 PasswordVector new_passwords; |
| 73 PasswordVector updated_passwords; | 73 PasswordVector updated_passwords; |
| 74 { | 74 { |
| 75 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 75 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 76 csync::ReadNode password_root(&trans); | 76 syncer::ReadNode password_root(&trans); |
| 77 if (password_root.InitByTagLookup(kPasswordTag) != | 77 if (password_root.InitByTagLookup(kPasswordTag) != |
| 78 csync::BaseNode::INIT_OK) { | 78 syncer::BaseNode::INIT_OK) { |
| 79 return error_handler_->CreateAndUploadError( | 79 return error_handler_->CreateAndUploadError( |
| 80 FROM_HERE, | 80 FROM_HERE, |
| 81 "Server did not create the top-level password node. We " | 81 "Server did not create the top-level password node. We " |
| 82 "might be running against an out-of-date server.", | 82 "might be running against an out-of-date server.", |
| 83 model_type()); | 83 model_type()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 for (std::vector<webkit::forms::PasswordForm*>::iterator ix = | 86 for (std::vector<webkit::forms::PasswordForm*>::iterator ix = |
| 87 passwords.begin(); | 87 passwords.begin(); |
| 88 ix != passwords.end(); ++ix) { | 88 ix != passwords.end(); ++ix) { |
| 89 if (IsAbortPending()) { | 89 if (IsAbortPending()) { |
| 90 return csync::SyncError(); | 90 return syncer::SyncError(); |
| 91 } | 91 } |
| 92 std::string tag = MakeTag(**ix); | 92 std::string tag = MakeTag(**ix); |
| 93 | 93 |
| 94 csync::ReadNode node(&trans); | 94 syncer::ReadNode node(&trans); |
| 95 if (node.InitByClientTagLookup(syncable::PASSWORDS, tag) == | 95 if (node.InitByClientTagLookup(syncable::PASSWORDS, tag) == |
| 96 csync::BaseNode::INIT_OK) { | 96 syncer::BaseNode::INIT_OK) { |
| 97 const sync_pb::PasswordSpecificsData& password = | 97 const sync_pb::PasswordSpecificsData& password = |
| 98 node.GetPasswordSpecifics(); | 98 node.GetPasswordSpecifics(); |
| 99 DCHECK_EQ(tag, MakeTag(password)); | 99 DCHECK_EQ(tag, MakeTag(password)); |
| 100 | 100 |
| 101 webkit::forms::PasswordForm new_password; | 101 webkit::forms::PasswordForm new_password; |
| 102 | 102 |
| 103 if (MergePasswords(password, **ix, &new_password)) { | 103 if (MergePasswords(password, **ix, &new_password)) { |
| 104 csync::WriteNode write_node(&trans); | 104 syncer::WriteNode write_node(&trans); |
| 105 if (write_node.InitByClientTagLookup(syncable::PASSWORDS, tag) != | 105 if (write_node.InitByClientTagLookup(syncable::PASSWORDS, tag) != |
| 106 csync::BaseNode::INIT_OK) { | 106 syncer::BaseNode::INIT_OK) { |
| 107 STLDeleteElements(&passwords); | 107 STLDeleteElements(&passwords); |
| 108 return error_handler_->CreateAndUploadError( | 108 return error_handler_->CreateAndUploadError( |
| 109 FROM_HERE, | 109 FROM_HERE, |
| 110 "Failed to edit password sync node.", | 110 "Failed to edit password sync node.", |
| 111 model_type()); | 111 model_type()); |
| 112 } | 112 } |
| 113 WriteToSyncNode(new_password, &write_node); | 113 WriteToSyncNode(new_password, &write_node); |
| 114 updated_passwords.push_back(new_password); | 114 updated_passwords.push_back(new_password); |
| 115 } | 115 } |
| 116 | 116 |
| 117 Associate(&tag, node.GetId()); | 117 Associate(&tag, node.GetId()); |
| 118 } else { | 118 } else { |
| 119 csync::WriteNode node(&trans); | 119 syncer::WriteNode node(&trans); |
| 120 csync::WriteNode::InitUniqueByCreationResult result = | 120 syncer::WriteNode::InitUniqueByCreationResult result = |
| 121 node.InitUniqueByCreation(syncable::PASSWORDS, password_root, tag); | 121 node.InitUniqueByCreation(syncable::PASSWORDS, password_root, tag); |
| 122 if (result != csync::WriteNode::INIT_SUCCESS) { | 122 if (result != syncer::WriteNode::INIT_SUCCESS) { |
| 123 STLDeleteElements(&passwords); | 123 STLDeleteElements(&passwords); |
| 124 return error_handler_->CreateAndUploadError( | 124 return error_handler_->CreateAndUploadError( |
| 125 FROM_HERE, | 125 FROM_HERE, |
| 126 "Failed to create password sync node.", | 126 "Failed to create password sync node.", |
| 127 model_type()); | 127 model_type()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 WriteToSyncNode(**ix, &node); | 130 WriteToSyncNode(**ix, &node); |
| 131 | 131 |
| 132 Associate(&tag, node.GetId()); | 132 Associate(&tag, node.GetId()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 current_passwords.insert(tag); | 135 current_passwords.insert(tag); |
| 136 } | 136 } |
| 137 | 137 |
| 138 STLDeleteElements(&passwords); | 138 STLDeleteElements(&passwords); |
| 139 | 139 |
| 140 int64 sync_child_id = password_root.GetFirstChildId(); | 140 int64 sync_child_id = password_root.GetFirstChildId(); |
| 141 while (sync_child_id != csync::kInvalidId) { | 141 while (sync_child_id != syncer::kInvalidId) { |
| 142 csync::ReadNode sync_child_node(&trans); | 142 syncer::ReadNode sync_child_node(&trans); |
| 143 if (sync_child_node.InitByIdLookup(sync_child_id) != | 143 if (sync_child_node.InitByIdLookup(sync_child_id) != |
| 144 csync::BaseNode::INIT_OK) { | 144 syncer::BaseNode::INIT_OK) { |
| 145 return error_handler_->CreateAndUploadError( | 145 return error_handler_->CreateAndUploadError( |
| 146 FROM_HERE, | 146 FROM_HERE, |
| 147 "Failed to fetch child node.", | 147 "Failed to fetch child node.", |
| 148 model_type()); | 148 model_type()); |
| 149 } | 149 } |
| 150 const sync_pb::PasswordSpecificsData& password = | 150 const sync_pb::PasswordSpecificsData& password = |
| 151 sync_child_node.GetPasswordSpecifics(); | 151 sync_child_node.GetPasswordSpecifics(); |
| 152 std::string tag = MakeTag(password); | 152 std::string tag = MakeTag(password); |
| 153 | 153 |
| 154 // The password only exists on the server. Add it to the local | 154 // The password only exists on the server. Add it to the local |
| (...skipping 17 matching lines...) Expand all Loading... |
| 172 &updated_passwords, | 172 &updated_passwords, |
| 173 NULL); | 173 NULL); |
| 174 if (error.IsSet()) { | 174 if (error.IsSet()) { |
| 175 return error; | 175 return error; |
| 176 } | 176 } |
| 177 | 177 |
| 178 return error; | 178 return error; |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool PasswordModelAssociator::DeleteAllNodes( | 181 bool PasswordModelAssociator::DeleteAllNodes( |
| 182 csync::WriteTransaction* trans) { | 182 syncer::WriteTransaction* trans) { |
| 183 DCHECK(expected_loop_ == MessageLoop::current()); | 183 DCHECK(expected_loop_ == MessageLoop::current()); |
| 184 for (PasswordToSyncIdMap::iterator node_id = id_map_.begin(); | 184 for (PasswordToSyncIdMap::iterator node_id = id_map_.begin(); |
| 185 node_id != id_map_.end(); ++node_id) { | 185 node_id != id_map_.end(); ++node_id) { |
| 186 csync::WriteNode sync_node(trans); | 186 syncer::WriteNode sync_node(trans); |
| 187 if (sync_node.InitByIdLookup(node_id->second) != | 187 if (sync_node.InitByIdLookup(node_id->second) != |
| 188 csync::BaseNode::INIT_OK) { | 188 syncer::BaseNode::INIT_OK) { |
| 189 LOG(ERROR) << "Typed url node lookup failed."; | 189 LOG(ERROR) << "Typed url node lookup failed."; |
| 190 return false; | 190 return false; |
| 191 } | 191 } |
| 192 sync_node.Remove(); | 192 sync_node.Remove(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 id_map_.clear(); | 195 id_map_.clear(); |
| 196 id_map_inverse_.clear(); | 196 id_map_inverse_.clear(); |
| 197 return true; | 197 return true; |
| 198 } | 198 } |
| 199 | 199 |
| 200 csync::SyncError PasswordModelAssociator::DisassociateModels() { | 200 syncer::SyncError PasswordModelAssociator::DisassociateModels() { |
| 201 id_map_.clear(); | 201 id_map_.clear(); |
| 202 id_map_inverse_.clear(); | 202 id_map_inverse_.clear(); |
| 203 return csync::SyncError(); | 203 return syncer::SyncError(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 bool PasswordModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { | 206 bool PasswordModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { |
| 207 DCHECK(has_nodes); | 207 DCHECK(has_nodes); |
| 208 *has_nodes = false; | 208 *has_nodes = false; |
| 209 int64 password_sync_id; | 209 int64 password_sync_id; |
| 210 if (!GetSyncIdForTaggedNode(kPasswordTag, &password_sync_id)) { | 210 if (!GetSyncIdForTaggedNode(kPasswordTag, &password_sync_id)) { |
| 211 LOG(ERROR) << "Server did not create the top-level password node. We " | 211 LOG(ERROR) << "Server did not create the top-level password node. We " |
| 212 << "might be running against an out-of-date server."; | 212 << "might be running against an out-of-date server."; |
| 213 return false; | 213 return false; |
| 214 } | 214 } |
| 215 csync::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 215 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 216 | 216 |
| 217 csync::ReadNode password_node(&trans); | 217 syncer::ReadNode password_node(&trans); |
| 218 if (password_node.InitByIdLookup(password_sync_id) != | 218 if (password_node.InitByIdLookup(password_sync_id) != |
| 219 csync::BaseNode::INIT_OK) { | 219 syncer::BaseNode::INIT_OK) { |
| 220 LOG(ERROR) << "Server did not create the top-level password node. We " | 220 LOG(ERROR) << "Server did not create the top-level password node. We " |
| 221 << "might be running against an out-of-date server."; | 221 << "might be running against an out-of-date server."; |
| 222 return false; | 222 return false; |
| 223 } | 223 } |
| 224 | 224 |
| 225 // The sync model has user created nodes if the password folder has any | 225 // The sync model has user created nodes if the password folder has any |
| 226 // children. | 226 // children. |
| 227 *has_nodes = password_node.HasChildren(); | 227 *has_nodes = password_node.HasChildren(); |
| 228 return true; | 228 return true; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void PasswordModelAssociator::AbortAssociation() { | 231 void PasswordModelAssociator::AbortAssociation() { |
| 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 233 base::AutoLock lock(abort_association_pending_lock_); | 233 base::AutoLock lock(abort_association_pending_lock_); |
| 234 abort_association_pending_ = true; | 234 abort_association_pending_ = true; |
| 235 } | 235 } |
| 236 | 236 |
| 237 bool PasswordModelAssociator::CryptoReadyIfNecessary() { | 237 bool PasswordModelAssociator::CryptoReadyIfNecessary() { |
| 238 // We only access the cryptographer while holding a transaction. | 238 // We only access the cryptographer while holding a transaction. |
| 239 csync::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 239 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 240 // We always encrypt passwords, so no need to check if encryption is enabled. | 240 // We always encrypt passwords, so no need to check if encryption is enabled. |
| 241 return sync_service_->IsCryptographerReady(&trans); | 241 return sync_service_->IsCryptographerReady(&trans); |
| 242 } | 242 } |
| 243 | 243 |
| 244 const std::string* PasswordModelAssociator::GetChromeNodeFromSyncId( | 244 const std::string* PasswordModelAssociator::GetChromeNodeFromSyncId( |
| 245 int64 sync_id) { | 245 int64 sync_id) { |
| 246 return NULL; | 246 return NULL; |
| 247 } | 247 } |
| 248 | 248 |
| 249 bool PasswordModelAssociator::InitSyncNodeFromChromeId( | 249 bool PasswordModelAssociator::InitSyncNodeFromChromeId( |
| 250 const std::string& node_id, | 250 const std::string& node_id, |
| 251 csync::BaseNode* sync_node) { | 251 syncer::BaseNode* sync_node) { |
| 252 return false; | 252 return false; |
| 253 } | 253 } |
| 254 | 254 |
| 255 bool PasswordModelAssociator::IsAbortPending() { | 255 bool PasswordModelAssociator::IsAbortPending() { |
| 256 base::AutoLock lock(abort_association_pending_lock_); | 256 base::AutoLock lock(abort_association_pending_lock_); |
| 257 return abort_association_pending_; | 257 return abort_association_pending_; |
| 258 } | 258 } |
| 259 | 259 |
| 260 int64 PasswordModelAssociator::GetSyncIdFromChromeId( | 260 int64 PasswordModelAssociator::GetSyncIdFromChromeId( |
| 261 const std::string& password) { | 261 const std::string& password) { |
| 262 PasswordToSyncIdMap::const_iterator iter = id_map_.find(password); | 262 PasswordToSyncIdMap::const_iterator iter = id_map_.find(password); |
| 263 return iter == id_map_.end() ? csync::kInvalidId : iter->second; | 263 return iter == id_map_.end() ? syncer::kInvalidId : iter->second; |
| 264 } | 264 } |
| 265 | 265 |
| 266 void PasswordModelAssociator::Associate( | 266 void PasswordModelAssociator::Associate( |
| 267 const std::string* password, int64 sync_id) { | 267 const std::string* password, int64 sync_id) { |
| 268 DCHECK(expected_loop_ == MessageLoop::current()); | 268 DCHECK(expected_loop_ == MessageLoop::current()); |
| 269 DCHECK_NE(csync::kInvalidId, sync_id); | 269 DCHECK_NE(syncer::kInvalidId, sync_id); |
| 270 DCHECK(id_map_.find(*password) == id_map_.end()); | 270 DCHECK(id_map_.find(*password) == id_map_.end()); |
| 271 DCHECK(id_map_inverse_.find(sync_id) == id_map_inverse_.end()); | 271 DCHECK(id_map_inverse_.find(sync_id) == id_map_inverse_.end()); |
| 272 id_map_[*password] = sync_id; | 272 id_map_[*password] = sync_id; |
| 273 id_map_inverse_[sync_id] = *password; | 273 id_map_inverse_[sync_id] = *password; |
| 274 } | 274 } |
| 275 | 275 |
| 276 void PasswordModelAssociator::Disassociate(int64 sync_id) { | 276 void PasswordModelAssociator::Disassociate(int64 sync_id) { |
| 277 DCHECK(expected_loop_ == MessageLoop::current()); | 277 DCHECK(expected_loop_ == MessageLoop::current()); |
| 278 SyncIdToPasswordMap::iterator iter = id_map_inverse_.find(sync_id); | 278 SyncIdToPasswordMap::iterator iter = id_map_inverse_.find(sync_id); |
| 279 if (iter == id_map_inverse_.end()) | 279 if (iter == id_map_inverse_.end()) |
| 280 return; | 280 return; |
| 281 CHECK(id_map_.erase(iter->second)); | 281 CHECK(id_map_.erase(iter->second)); |
| 282 id_map_inverse_.erase(iter); | 282 id_map_inverse_.erase(iter); |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool PasswordModelAssociator::GetSyncIdForTaggedNode(const std::string& tag, | 285 bool PasswordModelAssociator::GetSyncIdForTaggedNode(const std::string& tag, |
| 286 int64* sync_id) { | 286 int64* sync_id) { |
| 287 csync::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 287 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 288 csync::ReadNode sync_node(&trans); | 288 syncer::ReadNode sync_node(&trans); |
| 289 if (sync_node.InitByTagLookup(tag.c_str()) != csync::BaseNode::INIT_OK) | 289 if (sync_node.InitByTagLookup(tag.c_str()) != syncer::BaseNode::INIT_OK) |
| 290 return false; | 290 return false; |
| 291 *sync_id = sync_node.GetId(); | 291 *sync_id = sync_node.GetId(); |
| 292 return true; | 292 return true; |
| 293 } | 293 } |
| 294 | 294 |
| 295 csync::SyncError PasswordModelAssociator::WriteToPasswordStore( | 295 syncer::SyncError PasswordModelAssociator::WriteToPasswordStore( |
| 296 const PasswordVector* new_passwords, | 296 const PasswordVector* new_passwords, |
| 297 const PasswordVector* updated_passwords, | 297 const PasswordVector* updated_passwords, |
| 298 const PasswordVector* deleted_passwords) { | 298 const PasswordVector* deleted_passwords) { |
| 299 if (new_passwords) { | 299 if (new_passwords) { |
| 300 for (PasswordVector::const_iterator password = new_passwords->begin(); | 300 for (PasswordVector::const_iterator password = new_passwords->begin(); |
| 301 password != new_passwords->end(); ++password) { | 301 password != new_passwords->end(); ++password) { |
| 302 password_store_->AddLoginImpl(*password); | 302 password_store_->AddLoginImpl(*password); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 | 305 |
| 306 if (updated_passwords) { | 306 if (updated_passwords) { |
| 307 for (PasswordVector::const_iterator password = updated_passwords->begin(); | 307 for (PasswordVector::const_iterator password = updated_passwords->begin(); |
| 308 password != updated_passwords->end(); ++password) { | 308 password != updated_passwords->end(); ++password) { |
| 309 password_store_->UpdateLoginImpl(*password); | 309 password_store_->UpdateLoginImpl(*password); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 if (deleted_passwords) { | 313 if (deleted_passwords) { |
| 314 for (PasswordVector::const_iterator password = deleted_passwords->begin(); | 314 for (PasswordVector::const_iterator password = deleted_passwords->begin(); |
| 315 password != deleted_passwords->end(); ++password) { | 315 password != deleted_passwords->end(); ++password) { |
| 316 password_store_->RemoveLoginImpl(*password); | 316 password_store_->RemoveLoginImpl(*password); |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| 320 if (new_passwords || updated_passwords || deleted_passwords) { | 320 if (new_passwords || updated_passwords || deleted_passwords) { |
| 321 // We have to notify password store observers of the change by hand since | 321 // We have to notify password store observers of the change by hand since |
| 322 // we use internal password store interfaces to make changes synchronously. | 322 // we use internal password store interfaces to make changes synchronously. |
| 323 password_store_->PostNotifyLoginsChanged(); | 323 password_store_->PostNotifyLoginsChanged(); |
| 324 } | 324 } |
| 325 return csync::SyncError(); | 325 return syncer::SyncError(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 // static | 328 // static |
| 329 void PasswordModelAssociator::CopyPassword( | 329 void PasswordModelAssociator::CopyPassword( |
| 330 const sync_pb::PasswordSpecificsData& password, | 330 const sync_pb::PasswordSpecificsData& password, |
| 331 webkit::forms::PasswordForm* new_password) { | 331 webkit::forms::PasswordForm* new_password) { |
| 332 new_password->scheme = | 332 new_password->scheme = |
| 333 static_cast<webkit::forms::PasswordForm::Scheme>(password.scheme()); | 333 static_cast<webkit::forms::PasswordForm::Scheme>(password.scheme()); |
| 334 new_password->signon_realm = password.signon_realm(); | 334 new_password->signon_realm = password.signon_realm(); |
| 335 new_password->origin = GURL(password.origin()); | 335 new_password->origin = GURL(password.origin()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } else { | 383 } else { |
| 384 CopyPassword(password, new_password); | 384 CopyPassword(password, new_password); |
| 385 } | 385 } |
| 386 | 386 |
| 387 return true; | 387 return true; |
| 388 } | 388 } |
| 389 | 389 |
| 390 // static | 390 // static |
| 391 void PasswordModelAssociator::WriteToSyncNode( | 391 void PasswordModelAssociator::WriteToSyncNode( |
| 392 const webkit::forms::PasswordForm& password_form, | 392 const webkit::forms::PasswordForm& password_form, |
| 393 csync::WriteNode* node) { | 393 syncer::WriteNode* node) { |
| 394 sync_pb::PasswordSpecificsData password; | 394 sync_pb::PasswordSpecificsData password; |
| 395 password.set_scheme(password_form.scheme); | 395 password.set_scheme(password_form.scheme); |
| 396 password.set_signon_realm(password_form.signon_realm); | 396 password.set_signon_realm(password_form.signon_realm); |
| 397 password.set_origin(password_form.origin.spec()); | 397 password.set_origin(password_form.origin.spec()); |
| 398 password.set_action(password_form.action.spec()); | 398 password.set_action(password_form.action.spec()); |
| 399 password.set_username_element(UTF16ToUTF8(password_form.username_element)); | 399 password.set_username_element(UTF16ToUTF8(password_form.username_element)); |
| 400 password.set_password_element(UTF16ToUTF8(password_form.password_element)); | 400 password.set_password_element(UTF16ToUTF8(password_form.password_element)); |
| 401 password.set_username_value(UTF16ToUTF8(password_form.username_value)); | 401 password.set_username_value(UTF16ToUTF8(password_form.username_value)); |
| 402 password.set_password_value(UTF16ToUTF8(password_form.password_value)); | 402 password.set_password_value(UTF16ToUTF8(password_form.password_value)); |
| 403 password.set_ssl_valid(password_form.ssl_valid); | 403 password.set_ssl_valid(password_form.ssl_valid); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 const std::string& password_element, | 436 const std::string& password_element, |
| 437 const std::string& signon_realm) { | 437 const std::string& signon_realm) { |
| 438 return net::EscapePath(origin_url) + "|" + | 438 return net::EscapePath(origin_url) + "|" + |
| 439 net::EscapePath(username_element) + "|" + | 439 net::EscapePath(username_element) + "|" + |
| 440 net::EscapePath(username_value) + "|" + | 440 net::EscapePath(username_value) + "|" + |
| 441 net::EscapePath(password_element) + "|" + | 441 net::EscapePath(password_element) + "|" + |
| 442 net::EscapePath(signon_realm); | 442 net::EscapePath(signon_realm); |
| 443 } | 443 } |
| 444 | 444 |
| 445 } // namespace browser_sync | 445 } // namespace browser_sync |
| OLD | NEW |