| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #else | 34 #else |
| 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 36 #endif | 36 #endif |
| 37 } | 37 } |
| 38 | 38 |
| 39 PasswordModelAssociator::~PasswordModelAssociator() {} | 39 PasswordModelAssociator::~PasswordModelAssociator() {} |
| 40 | 40 |
| 41 bool PasswordModelAssociator::AssociateModels() { | 41 bool PasswordModelAssociator::AssociateModels() { |
| 42 DCHECK(expected_loop_ == MessageLoop::current()); | 42 DCHECK(expected_loop_ == MessageLoop::current()); |
| 43 { | 43 { |
| 44 AutoLock lock(abort_association_pending_lock_); | 44 base::AutoLock lock(abort_association_pending_lock_); |
| 45 abort_association_pending_ = false; | 45 abort_association_pending_ = false; |
| 46 } | 46 } |
| 47 | 47 |
| 48 sync_api::WriteTransaction trans( | 48 sync_api::WriteTransaction trans( |
| 49 sync_service_->backend()->GetUserShareHandle()); | 49 sync_service_->backend()->GetUserShareHandle()); |
| 50 sync_api::ReadNode password_root(&trans); | 50 sync_api::ReadNode password_root(&trans); |
| 51 if (!password_root.InitByTagLookup(kPasswordTag)) { | 51 if (!password_root.InitByTagLookup(kPasswordTag)) { |
| 52 LOG(ERROR) << "Server did not create the top-level password node. We " | 52 LOG(ERROR) << "Server did not create the top-level password node. We " |
| 53 << "might be running against an out-of-date server."; | 53 << "might be running against an out-of-date server."; |
| 54 return false; | 54 return false; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 187 } |
| 188 | 188 |
| 189 // The sync model has user created nodes if the password folder has any | 189 // The sync model has user created nodes if the password folder has any |
| 190 // children. | 190 // children. |
| 191 *has_nodes = sync_api::kInvalidId != password_node.GetFirstChildId(); | 191 *has_nodes = sync_api::kInvalidId != password_node.GetFirstChildId(); |
| 192 return true; | 192 return true; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void PasswordModelAssociator::AbortAssociation() { | 195 void PasswordModelAssociator::AbortAssociation() { |
| 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 197 AutoLock lock(abort_association_pending_lock_); | 197 base::AutoLock lock(abort_association_pending_lock_); |
| 198 abort_association_pending_ = true; | 198 abort_association_pending_ = true; |
| 199 } | 199 } |
| 200 | 200 |
| 201 const std::string* PasswordModelAssociator::GetChromeNodeFromSyncId( | 201 const std::string* PasswordModelAssociator::GetChromeNodeFromSyncId( |
| 202 int64 sync_id) { | 202 int64 sync_id) { |
| 203 return NULL; | 203 return NULL; |
| 204 } | 204 } |
| 205 | 205 |
| 206 bool PasswordModelAssociator::InitSyncNodeFromChromeId( | 206 bool PasswordModelAssociator::InitSyncNodeFromChromeId( |
| 207 const std::string& node_id, | 207 const std::string& node_id, |
| 208 sync_api::BaseNode* sync_node) { | 208 sync_api::BaseNode* sync_node) { |
| 209 return false; | 209 return false; |
| 210 } | 210 } |
| 211 | 211 |
| 212 bool PasswordModelAssociator::IsAbortPending() { | 212 bool PasswordModelAssociator::IsAbortPending() { |
| 213 AutoLock lock(abort_association_pending_lock_); | 213 base::AutoLock lock(abort_association_pending_lock_); |
| 214 return abort_association_pending_; | 214 return abort_association_pending_; |
| 215 } | 215 } |
| 216 | 216 |
| 217 int64 PasswordModelAssociator::GetSyncIdFromChromeId( | 217 int64 PasswordModelAssociator::GetSyncIdFromChromeId( |
| 218 const std::string& password) { | 218 const std::string& password) { |
| 219 PasswordToSyncIdMap::const_iterator iter = id_map_.find(password); | 219 PasswordToSyncIdMap::const_iterator iter = id_map_.find(password); |
| 220 return iter == id_map_.end() ? sync_api::kInvalidId : iter->second; | 220 return iter == id_map_.end() ? sync_api::kInvalidId : iter->second; |
| 221 } | 221 } |
| 222 | 222 |
| 223 void PasswordModelAssociator::Associate( | 223 void PasswordModelAssociator::Associate( |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 const std::string& password_element, | 388 const std::string& password_element, |
| 389 const std::string& signon_realm) { | 389 const std::string& signon_realm) { |
| 390 return EscapePath(origin_url) + "|" + | 390 return EscapePath(origin_url) + "|" + |
| 391 EscapePath(username_element) + "|" + | 391 EscapePath(username_element) + "|" + |
| 392 EscapePath(username_value) + "|" + | 392 EscapePath(username_value) + "|" + |
| 393 EscapePath(password_element) + "|" + | 393 EscapePath(password_element) + "|" + |
| 394 EscapePath(signon_realm); | 394 EscapePath(signon_realm); |
| 395 } | 395 } |
| 396 | 396 |
| 397 } // namespace browser_sync | 397 } // namespace browser_sync |
| OLD | NEW |