| OLD | NEW | 
|---|
| 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/sync/engine/syncapi.h" | 5 #include "chrome/browser/sync/engine/syncapi.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <bitset> | 8 #include <bitset> | 
| 9 #include <iomanip> | 9 #include <iomanip> | 
| 10 #include <list> | 10 #include <list> | 
| (...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1784       return; | 1784       return; | 
| 1785     } | 1785     } | 
| 1786 | 1786 | 
| 1787     nigori.CopyFrom(node.GetNigoriSpecifics()); | 1787     nigori.CopyFrom(node.GetNigoriSpecifics()); | 
| 1788     if (!nigori.encrypted().blob().empty()) { | 1788     if (!nigori.encrypted().blob().empty()) { | 
| 1789       if (cryptographer->CanDecrypt(nigori.encrypted())) { | 1789       if (cryptographer->CanDecrypt(nigori.encrypted())) { | 
| 1790         cryptographer->SetKeys(nigori.encrypted()); | 1790         cryptographer->SetKeys(nigori.encrypted()); | 
| 1791       } else { | 1791       } else { | 
| 1792         cryptographer->SetPendingKeys(nigori.encrypted()); | 1792         cryptographer->SetPendingKeys(nigori.encrypted()); | 
| 1793         FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 1793         FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 
| 1794                           OnPassphraseRequired(true)); | 1794                           OnPassphraseRequired(sync_api::DECRYPTION)); | 
| 1795       } | 1795       } | 
| 1796     } | 1796     } | 
| 1797   } | 1797   } | 
| 1798 | 1798 | 
| 1799   // Refresh list of encrypted datatypes. | 1799   // Refresh list of encrypted datatypes. | 
| 1800   syncable::ModelTypeSet encrypted_types = | 1800   syncable::ModelTypeSet encrypted_types = | 
| 1801       syncable::GetEncryptedDataTypesFromNigori(nigori); | 1801       syncable::GetEncryptedDataTypesFromNigori(nigori); | 
| 1802 | 1802 | 
| 1803   // Ensure any datatypes that need encryption are encrypted. | 1803   // Ensure any datatypes that need encryption are encrypted. | 
| 1804   EncryptDataTypes(encrypted_types); | 1804   EncryptDataTypes(encrypted_types); | 
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1946     const std::string& passphrase, bool is_explicit) { | 1946     const std::string& passphrase, bool is_explicit) { | 
| 1947   // All accesses to the cryptographer are protected by a transaction. | 1947   // All accesses to the cryptographer are protected by a transaction. | 
| 1948   WriteTransaction trans(GetUserShare()); | 1948   WriteTransaction trans(GetUserShare()); | 
| 1949   Cryptographer* cryptographer = trans.GetCryptographer(); | 1949   Cryptographer* cryptographer = trans.GetCryptographer(); | 
| 1950   KeyParams params = {"localhost", "dummy", passphrase}; | 1950   KeyParams params = {"localhost", "dummy", passphrase}; | 
| 1951 | 1951 | 
| 1952   if (cryptographer->has_pending_keys()) { | 1952   if (cryptographer->has_pending_keys()) { | 
| 1953     if (!cryptographer->DecryptPendingKeys(params)) { | 1953     if (!cryptographer->DecryptPendingKeys(params)) { | 
| 1954       VLOG(1) << "Passphrase failed to decrypt pending keys."; | 1954       VLOG(1) << "Passphrase failed to decrypt pending keys."; | 
| 1955       FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 1955       FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 
| 1956                         OnPassphraseFailed()); | 1956                         OnPassphraseRequired(sync_api::DECRYPTION_FAILED)); | 
| 1957       return; | 1957       return; | 
| 1958     } | 1958     } | 
| 1959 | 1959 | 
| 1960     // TODO(tim): If this is the first time the user has entered a passphrase | 1960     // TODO(tim): If this is the first time the user has entered a passphrase | 
| 1961     // since the protocol changed to store passphrase preferences in the cloud, | 1961     // since the protocol changed to store passphrase preferences in the cloud, | 
| 1962     // make sure we update this preference. See bug 62103. | 1962     // make sure we update this preference. See bug 62103. | 
| 1963     if (is_explicit) | 1963     if (is_explicit) | 
| 1964       SetUsingExplicitPassphrasePrefForMigration(&trans); | 1964       SetUsingExplicitPassphrasePrefForMigration(&trans); | 
| 1965 | 1965 | 
| 1966     // Nudge the syncer so that encrypted datatype updates that were waiting for | 1966     // Nudge the syncer so that encrypted datatype updates that were waiting for | 
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2499           if (!nigori.encrypted().blob().empty()) { | 2499           if (!nigori.encrypted().blob().empty()) { | 
| 2500             DCHECK(!cryptographer->CanDecrypt(nigori.encrypted())); | 2500             DCHECK(!cryptographer->CanDecrypt(nigori.encrypted())); | 
| 2501             cryptographer->SetPendingKeys(nigori.encrypted()); | 2501             cryptographer->SetPendingKeys(nigori.encrypted()); | 
| 2502           } | 2502           } | 
| 2503         } | 2503         } | 
| 2504 | 2504 | 
| 2505         // If we've completed a sync cycle and the cryptographer isn't ready | 2505         // If we've completed a sync cycle and the cryptographer isn't ready | 
| 2506         // yet, prompt the user for a passphrase. | 2506         // yet, prompt the user for a passphrase. | 
| 2507         if (cryptographer->has_pending_keys()) { | 2507         if (cryptographer->has_pending_keys()) { | 
| 2508           FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 2508           FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 
| 2509                             OnPassphraseRequired(true)); | 2509                             OnPassphraseRequired(sync_api::ENCRYPTION)); | 
| 2510         } else if (!cryptographer->is_ready()) { | 2510         } else if (!cryptographer->is_ready()) { | 
| 2511           FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 2511           FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 
| 2512                             OnPassphraseRequired(false)); | 2512                             OnPassphraseRequired(sync_api::DECRYPTION)); | 
| 2513         } else { | 2513         } else { | 
| 2514           FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 2514           FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 
| 2515                             OnEncryptionComplete(encrypted_types)); | 2515                             OnEncryptionComplete(encrypted_types)); | 
| 2516         } | 2516         } | 
| 2517       } | 2517       } | 
| 2518     } | 2518     } | 
| 2519 | 2519 | 
| 2520     if (!initialized()) | 2520     if (!initialized()) | 
| 2521       return; | 2521       return; | 
| 2522 | 2522 | 
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2833 void SyncManager::TriggerOnIncomingNotificationForTest( | 2833 void SyncManager::TriggerOnIncomingNotificationForTest( | 
| 2834     const syncable::ModelTypeBitSet& model_types) { | 2834     const syncable::ModelTypeBitSet& model_types) { | 
| 2835   syncable::ModelTypePayloadMap model_types_with_payloads = | 2835   syncable::ModelTypePayloadMap model_types_with_payloads = | 
| 2836       syncable::ModelTypePayloadMapFromBitSet(model_types, | 2836       syncable::ModelTypePayloadMapFromBitSet(model_types, | 
| 2837           std::string()); | 2837           std::string()); | 
| 2838 | 2838 | 
| 2839   data_->OnIncomingNotification(model_types_with_payloads); | 2839   data_->OnIncomingNotification(model_types_with_payloads); | 
| 2840 } | 2840 } | 
| 2841 | 2841 | 
| 2842 }  // namespace sync_api | 2842 }  // namespace sync_api | 
| OLD | NEW | 
|---|