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/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 15 matching lines...) Expand all Loading... | |
26 #include "chrome/browser/defaults.h" | 26 #include "chrome/browser/defaults.h" |
27 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 27 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/signin/signin_manager.h" | 29 #include "chrome/browser/signin/signin_manager.h" |
30 #include "chrome/browser/signin/signin_manager_factory.h" | 30 #include "chrome/browser/signin/signin_manager_factory.h" |
31 #include "chrome/browser/signin/token_service.h" | 31 #include "chrome/browser/signin/token_service.h" |
32 #include "chrome/browser/signin/token_service_factory.h" | 32 #include "chrome/browser/signin/token_service_factory.h" |
33 #include "chrome/browser/sync/api/sync_error.h" | 33 #include "chrome/browser/sync/api/sync_error.h" |
34 #include "chrome/browser/sync/backend_migrator.h" | 34 #include "chrome/browser/sync/backend_migrator.h" |
35 #include "chrome/browser/sync/glue/change_processor.h" | 35 #include "chrome/browser/sync/glue/change_processor.h" |
36 #include "chrome/browser/sync/glue/chrome_encryptor.h" | |
36 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" | 37 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" |
37 #include "chrome/browser/sync/glue/data_type_controller.h" | 38 #include "chrome/browser/sync/glue/data_type_controller.h" |
38 #include "chrome/browser/sync/glue/session_data_type_controller.h" | 39 #include "chrome/browser/sync/glue/session_data_type_controller.h" |
39 #include "chrome/browser/sync/glue/session_model_associator.h" | 40 #include "chrome/browser/sync/glue/session_model_associator.h" |
40 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" | 41 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" |
41 #include "chrome/browser/sync/internal_api/configure_reason.h" | 42 #include "chrome/browser/sync/internal_api/configure_reason.h" |
42 #include "chrome/browser/sync/internal_api/sync_manager.h" | 43 #include "chrome/browser/sync/internal_api/sync_manager.h" |
43 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 44 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
44 #include "chrome/browser/sync/sync_global_error.h" | 45 #include "chrome/browser/sync/sync_global_error.h" |
45 #include "chrome/browser/sync/user_selectable_sync_type.h" | 46 #include "chrome/browser/sync/user_selectable_sync_type.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 // Don't start up multiple times. | 391 // Don't start up multiple times. |
391 if (backend_.get()) { | 392 if (backend_.get()) { |
392 DVLOG(1) << "Skipping bringing up backend host."; | 393 DVLOG(1) << "Skipping bringing up backend host."; |
393 return; | 394 return; |
394 } | 395 } |
395 | 396 |
396 DCHECK(AreCredentialsAvailable()); | 397 DCHECK(AreCredentialsAvailable()); |
397 | 398 |
398 last_synced_time_ = sync_prefs_.GetLastSyncedTime(); | 399 last_synced_time_ = sync_prefs_.GetLastSyncedTime(); |
399 | 400 |
401 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.
| |
402 if (bootstrap_token.empty()) { | |
403 sync_prefs_.SetEncryptionBootstrapToken( | |
404 sync_prefs_.GetSpareBootstrapToken()); | |
405 } | |
400 CreateBackend(); | 406 CreateBackend(); |
401 | 407 |
402 // Initialize the backend. Every time we start up a new SyncBackendHost, | 408 // Initialize the backend. Every time we start up a new SyncBackendHost, |
403 // we'll want to start from a fresh SyncDB, so delete any old one that might | 409 // we'll want to start from a fresh SyncDB, so delete any old one that might |
404 // be there. | 410 // be there. |
405 InitializeBackend(!HasSyncSetupCompleted()); | 411 InitializeBackend(!HasSyncSetupCompleted()); |
406 | 412 |
407 if (!sync_global_error_.get()) { | 413 if (!sync_global_error_.get()) { |
408 sync_global_error_.reset(new SyncGlobalError(this)); | 414 sync_global_error_.reset(new SyncGlobalError(this)); |
409 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | 415 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1064 // Selected type has changed - log it. | 1070 // Selected type has changed - log it. |
1065 UMA_HISTOGRAM_ENUMERATION( | 1071 UMA_HISTOGRAM_ENUMERATION( |
1066 "Sync.CustomSync", | 1072 "Sync.CustomSync", |
1067 user_selectable_types[i], | 1073 user_selectable_types[i], |
1068 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); | 1074 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); |
1069 } | 1075 } |
1070 } | 1076 } |
1071 } | 1077 } |
1072 } | 1078 } |
1073 | 1079 |
1080 void ProfileSyncService::RefreshSpareBootstrapToken( | |
1081 const std::string& passphrase) { | |
1082 browser_sync::ChromeEncryptor encryptor; | |
1083 browser_sync::Cryptographer temp_cryptographer(&encryptor); | |
1084 browser_sync::KeyParams key_params = {"localhost", "dummy", passphrase}; | |
1085 | |
1086 std::string bootstrap_token; | |
1087 if (!temp_cryptographer.AddKey(key_params)) { | |
1088 NOTREACHED() << "Failed to add key to cryptographer."; | |
1089 } | |
1090 temp_cryptographer.GetBootstrapToken(&bootstrap_token); | |
1091 sync_prefs_.SetSpareBootstrapToken(bootstrap_token); | |
1092 } | |
1093 | |
1074 void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything, | 1094 void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything, |
1075 syncable::ModelTypeSet chosen_types) { | 1095 syncable::ModelTypeSet chosen_types) { |
1076 if (!backend_.get() && | 1096 if (!backend_.get() && |
1077 unrecoverable_error_detected_ == false) { | 1097 unrecoverable_error_detected_ == false) { |
1078 NOTREACHED(); | 1098 NOTREACHED(); |
1079 return; | 1099 return; |
1080 } | 1100 } |
1081 | 1101 |
1082 UpdateSelectedTypesHistogram(sync_everything, chosen_types); | 1102 UpdateSelectedTypesHistogram(sync_everything, chosen_types); |
1083 sync_prefs_.SetKeepEverythingSynced(sync_everything); | 1103 sync_prefs_.SetKeepEverythingSynced(sync_everything); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1422 content::Details<const GoogleServiceSigninSuccessDetails>( | 1442 content::Details<const GoogleServiceSigninSuccessDetails>( |
1423 details).ptr(); | 1443 details).ptr(); |
1424 DCHECK(!successful->password.empty()); | 1444 DCHECK(!successful->password.empty()); |
1425 if (!sync_prefs_.IsStartSuppressed()) { | 1445 if (!sync_prefs_.IsStartSuppressed()) { |
1426 cached_passphrase_ = successful->password; | 1446 cached_passphrase_ = successful->password; |
1427 // Try to consume the passphrase we just cached. If the sync backend | 1447 // Try to consume the passphrase we just cached. If the sync backend |
1428 // is not running yet, the passphrase will remain cached until the | 1448 // is not running yet, the passphrase will remain cached until the |
1429 // backend starts up. | 1449 // backend starts up. |
1430 ConsumeCachedPassphraseIfPossible(); | 1450 ConsumeCachedPassphraseIfPossible(); |
1431 } | 1451 } |
1452 #if defined(OS_CHROMEOS) | |
1453 RefreshSpareBootstrapToken(successful->password); | |
1454 #endif | |
1432 if (!sync_initialized() || | 1455 if (!sync_initialized() || |
1433 GetAuthError().state() != GoogleServiceAuthError::NONE) { | 1456 GetAuthError().state() != GoogleServiceAuthError::NONE) { |
1434 // Track the fact that we're still waiting for auth to complete. | 1457 // Track the fact that we're still waiting for auth to complete. |
1435 is_auth_in_progress_ = true; | 1458 is_auth_in_progress_ = true; |
1436 } | 1459 } |
1437 break; | 1460 break; |
1438 } | 1461 } |
1439 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { | 1462 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { |
1440 const TokenService::TokenRequestFailedDetails& token_details = | 1463 const TokenService::TokenRequestFailedDetails& token_details = |
1441 *(content::Details<const TokenService::TokenRequestFailedDetails>( | 1464 *(content::Details<const TokenService::TokenRequestFailedDetails>( |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1586 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. | 1609 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. |
1587 ProfileSyncService* old_this = this; | 1610 ProfileSyncService* old_this = this; |
1588 this->~ProfileSyncService(); | 1611 this->~ProfileSyncService(); |
1589 new(old_this) ProfileSyncService( | 1612 new(old_this) ProfileSyncService( |
1590 new ProfileSyncComponentsFactoryImpl(profile, | 1613 new ProfileSyncComponentsFactoryImpl(profile, |
1591 CommandLine::ForCurrentProcess()), | 1614 CommandLine::ForCurrentProcess()), |
1592 profile, | 1615 profile, |
1593 signin, | 1616 signin, |
1594 behavior); | 1617 behavior); |
1595 } | 1618 } |
OLD | NEW |