Index: chrome/browser/sync/profile_sync_service.cc |
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc |
index 5257b6a8d80ae2b68c6bda3994bf83895148dcf1..0eb2d40512647fec78700c374b4a891f09b7e342 100644 |
--- a/chrome/browser/sync/profile_sync_service.cc |
+++ b/chrome/browser/sync/profile_sync_service.cc |
@@ -33,6 +33,7 @@ |
#include "chrome/browser/sync/api/sync_error.h" |
#include "chrome/browser/sync/backend_migrator.h" |
#include "chrome/browser/sync/glue/change_processor.h" |
+#include "chrome/browser/sync/glue/chrome_encryptor.h" |
#include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" |
#include "chrome/browser/sync/glue/data_type_controller.h" |
#include "chrome/browser/sync/glue/session_data_type_controller.h" |
@@ -397,6 +398,11 @@ void ProfileSyncService::StartUp() { |
last_synced_time_ = sync_prefs_.GetLastSyncedTime(); |
+ std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken(); |
Nicolas Zea
2012/04/03 23:47:20
OS_CHROMEOS
kochi
2012/04/04 00:10:20
Done.
|
+ if (bootstrap_token.empty()) { |
+ sync_prefs_.SetEncryptionBootstrapToken( |
+ sync_prefs_.GetSpareBootstrapToken()); |
+ } |
CreateBackend(); |
// Initialize the backend. Every time we start up a new SyncBackendHost, |
@@ -1071,6 +1077,20 @@ void ProfileSyncService::UpdateSelectedTypesHistogram( |
} |
} |
+void ProfileSyncService::RefreshSpareBootstrapToken( |
+ const std::string& passphrase) { |
+ browser_sync::ChromeEncryptor encryptor; |
+ browser_sync::Cryptographer temp_cryptographer(&encryptor); |
+ browser_sync::KeyParams key_params = {"localhost", "dummy", passphrase}; |
+ |
+ std::string bootstrap_token; |
+ if (!temp_cryptographer.AddKey(key_params)) { |
+ NOTREACHED() << "Failed to add key to cryptographer."; |
+ } |
+ temp_cryptographer.GetBootstrapToken(&bootstrap_token); |
+ sync_prefs_.SetSpareBootstrapToken(bootstrap_token); |
+} |
+ |
void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything, |
syncable::ModelTypeSet chosen_types) { |
if (!backend_.get() && |
@@ -1429,6 +1449,9 @@ void ProfileSyncService::Observe(int type, |
// backend starts up. |
ConsumeCachedPassphraseIfPossible(); |
} |
+#if defined(OS_CHROMEOS) |
+ RefreshSpareBootstrapToken(successful->password); |
+#endif |
if (!sync_initialized() || |
GetAuthError().state() != GoogleServiceAuthError::NONE) { |
// Track the fact that we're still waiting for auth to complete. |