| 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/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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 browser_sync::SyncServiceName()); | 299 browser_sync::SyncServiceName()); |
| 300 return credentials; | 300 return credentials; |
| 301 } | 301 } |
| 302 | 302 |
| 303 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { | 303 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { |
| 304 if (!backend_.get()) { | 304 if (!backend_.get()) { |
| 305 NOTREACHED(); | 305 NOTREACHED(); |
| 306 return; | 306 return; |
| 307 } | 307 } |
| 308 | 308 |
| 309 syncable::ModelEnumSet initial_types; | 309 syncable::ModelTypeSet initial_types; |
| 310 // If sync setup hasn't finished, we don't want to initialize routing info | 310 // If sync setup hasn't finished, we don't want to initialize routing info |
| 311 // for any data types so that we don't download updates for types that the | 311 // for any data types so that we don't download updates for types that the |
| 312 // user chooses not to sync on the first DownloadUpdatesCommand. | 312 // user chooses not to sync on the first DownloadUpdatesCommand. |
| 313 if (HasSyncSetupCompleted()) { | 313 if (HasSyncSetupCompleted()) { |
| 314 initial_types = GetPreferredDataTypes(); | 314 initial_types = GetPreferredDataTypes(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 SyncCredentials credentials = GetCredentials(); | 317 SyncCredentials credentials = GetCredentials(); |
| 318 | 318 |
| 319 scoped_refptr<net::URLRequestContextGetter> request_context_getter( | 319 scoped_refptr<net::URLRequestContextGetter> request_context_getter( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 333 | 333 |
| 334 void ProfileSyncService::CreateBackend() { | 334 void ProfileSyncService::CreateBackend() { |
| 335 backend_.reset( | 335 backend_.reset( |
| 336 new SyncBackendHost(profile_->GetDebugName(), | 336 new SyncBackendHost(profile_->GetDebugName(), |
| 337 profile_, sync_prefs_.AsWeakPtr())); | 337 profile_, sync_prefs_.AsWeakPtr())); |
| 338 } | 338 } |
| 339 | 339 |
| 340 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { | 340 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { |
| 341 if (encryption_pending()) | 341 if (encryption_pending()) |
| 342 return true; | 342 return true; |
| 343 const syncable::ModelEnumSet preferred_types = GetPreferredDataTypes(); | 343 const syncable::ModelTypeSet preferred_types = GetPreferredDataTypes(); |
| 344 const syncable::ModelEnumSet encrypted_types = GetEncryptedDataTypes(); | 344 const syncable::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); |
| 345 DCHECK(encrypted_types.Has(syncable::PASSWORDS)); | 345 DCHECK(encrypted_types.Has(syncable::PASSWORDS)); |
| 346 return !Intersection(preferred_types, encrypted_types).Empty(); | 346 return !Intersection(preferred_types, encrypted_types).Empty(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void ProfileSyncService::OnSyncConfigureDone( | 349 void ProfileSyncService::OnSyncConfigureDone( |
| 350 DataTypeManager::ConfigureResult result) { | 350 DataTypeManager::ConfigureResult result) { |
| 351 if (failed_datatypes_handler_.UpdateFailedDatatypes(result)) { | 351 if (failed_datatypes_handler_.UpdateFailedDatatypes(result)) { |
| 352 ReconfigureDatatypeManager(); | 352 ReconfigureDatatypeManager(); |
| 353 } | 353 } |
| 354 } | 354 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 MessageLoop::current()->PostTask(FROM_HERE, | 623 MessageLoop::current()->PostTask(FROM_HERE, |
| 624 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, | 624 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, |
| 625 GetSessionModelAssociator()->AsWeakPtr())); | 625 GetSessionModelAssociator()->AsWeakPtr())); |
| 626 } | 626 } |
| 627 DVLOG(2) << "Notifying observers sync cycle completed"; | 627 DVLOG(2) << "Notifying observers sync cycle completed"; |
| 628 NotifyObservers(); | 628 NotifyObservers(); |
| 629 } | 629 } |
| 630 | 630 |
| 631 // TODO(sync): eventually support removing datatypes too. | 631 // TODO(sync): eventually support removing datatypes too. |
| 632 void ProfileSyncService::OnDataTypesChanged( | 632 void ProfileSyncService::OnDataTypesChanged( |
| 633 syncable::ModelEnumSet to_add) { | 633 syncable::ModelTypeSet to_add) { |
| 634 // If this is a first time sync for a client, this will be called before | 634 // If this is a first time sync for a client, this will be called before |
| 635 // OnBackendInitialized() to ensure the new datatypes are available at sync | 635 // OnBackendInitialized() to ensure the new datatypes are available at sync |
| 636 // setup. As a result, the migrator won't exist yet. This is fine because for | 636 // setup. As a result, the migrator won't exist yet. This is fine because for |
| 637 // first time sync cases we're only concerned with making the datatype | 637 // first time sync cases we're only concerned with making the datatype |
| 638 // available. | 638 // available. |
| 639 if (migrator_.get() && | 639 if (migrator_.get() && |
| 640 migrator_->state() != browser_sync::BackendMigrator::IDLE) { | 640 migrator_->state() != browser_sync::BackendMigrator::IDLE) { |
| 641 DVLOG(1) << "Dropping OnDataTypesChanged due to migrator busy."; | 641 DVLOG(1) << "Dropping OnDataTypesChanged due to migrator busy."; |
| 642 return; | 642 return; |
| 643 } | 643 } |
| 644 | 644 |
| 645 DVLOG(2) << "OnDataTypesChanged called with types: " | 645 DVLOG(2) << "OnDataTypesChanged called with types: " |
| 646 << syncable::ModelEnumSetToString(to_add); | 646 << syncable::ModelTypeSetToString(to_add); |
| 647 | 647 |
| 648 const syncable::ModelEnumSet registered_types = GetRegisteredDataTypes(); | 648 const syncable::ModelTypeSet registered_types = GetRegisteredDataTypes(); |
| 649 | 649 |
| 650 const syncable::ModelEnumSet to_register = | 650 const syncable::ModelTypeSet to_register = |
| 651 Difference(to_add, registered_types); | 651 Difference(to_add, registered_types); |
| 652 | 652 |
| 653 DVLOG(2) << "Enabling types: " << syncable::ModelEnumSetToString(to_register); | 653 DVLOG(2) << "Enabling types: " << syncable::ModelTypeSetToString(to_register); |
| 654 | 654 |
| 655 for (syncable::ModelEnumSet::Iterator it = to_register.First(); | 655 for (syncable::ModelTypeSet::Iterator it = to_register.First(); |
| 656 it.Good(); it.Inc()) { | 656 it.Good(); it.Inc()) { |
| 657 // Received notice to enable experimental type. Check if the type is | 657 // Received notice to enable experimental type. Check if the type is |
| 658 // registered, and if not register a new datatype controller. | 658 // registered, and if not register a new datatype controller. |
| 659 RegisterNewDataType(it.Get()); | 659 RegisterNewDataType(it.Get()); |
| 660 // Enable the about:flags switch for the experimental type so we don't have | 660 // Enable the about:flags switch for the experimental type so we don't have |
| 661 // to always perform this reconfiguration. Once we set this, the type will | 661 // to always perform this reconfiguration. Once we set this, the type will |
| 662 // remain registered on restart, so we will no longer go down this code | 662 // remain registered on restart, so we will no longer go down this code |
| 663 // path. | 663 // path. |
| 664 std::string experiment_name = GetExperimentNameForDataType(it.Get()); | 664 std::string experiment_name = GetExperimentNameForDataType(it.Get()); |
| 665 if (experiment_name.empty()) | 665 if (experiment_name.empty()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 676 // covers the case where we're already in the process of reconfiguring | 676 // covers the case where we're already in the process of reconfiguring |
| 677 // to turn an experimental type on. | 677 // to turn an experimental type on. |
| 678 if (sync_prefs_.HasKeepEverythingSynced()) { | 678 if (sync_prefs_.HasKeepEverythingSynced()) { |
| 679 // Mark all data types as preferred. | 679 // Mark all data types as preferred. |
| 680 sync_prefs_.SetPreferredDataTypes(registered_types, registered_types); | 680 sync_prefs_.SetPreferredDataTypes(registered_types, registered_types); |
| 681 | 681 |
| 682 // Only automatically turn on types if we have already finished set up. | 682 // Only automatically turn on types if we have already finished set up. |
| 683 // Otherwise, just leave the experimental types on by default. | 683 // Otherwise, just leave the experimental types on by default. |
| 684 if (!to_register.Empty() && HasSyncSetupCompleted() && migrator_.get()) { | 684 if (!to_register.Empty() && HasSyncSetupCompleted() && migrator_.get()) { |
| 685 DVLOG(1) << "Dynamically enabling new datatypes: " | 685 DVLOG(1) << "Dynamically enabling new datatypes: " |
| 686 << syncable::ModelEnumSetToString(to_register); | 686 << syncable::ModelTypeSetToString(to_register); |
| 687 OnMigrationNeededForTypes(to_register); | 687 OnMigrationNeededForTypes(to_register); |
| 688 } | 688 } |
| 689 } | 689 } |
| 690 } | 690 } |
| 691 | 691 |
| 692 void ProfileSyncService::UpdateAuthErrorState( | 692 void ProfileSyncService::UpdateAuthErrorState( |
| 693 const GoogleServiceAuthError& error) { | 693 const GoogleServiceAuthError& error) { |
| 694 last_auth_error_ = error; | 694 last_auth_error_ = error; |
| 695 // Protect against the in-your-face dialogs that pop out of nowhere. | 695 // Protect against the in-your-face dialogs that pop out of nowhere. |
| 696 // Require the user to click somewhere to run the setup wizard in the case | 696 // Require the user to click somewhere to run the setup wizard in the case |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 void ProfileSyncService::OnPassphraseAccepted() { | 818 void ProfileSyncService::OnPassphraseAccepted() { |
| 819 DVLOG(1) << "Received OnPassphraseAccepted."; | 819 DVLOG(1) << "Received OnPassphraseAccepted."; |
| 820 // Reset passphrase_required_reason_ since we know we no longer require the | 820 // Reset passphrase_required_reason_ since we know we no longer require the |
| 821 // passphrase. We do this here rather than down in ResolvePassphraseRequired() | 821 // passphrase. We do this here rather than down in ResolvePassphraseRequired() |
| 822 // because that can be called by OnPassphraseRequired() if no encrypted data | 822 // because that can be called by OnPassphraseRequired() if no encrypted data |
| 823 // types are enabled, and we don't want to clobber the true passphrase error. | 823 // types are enabled, and we don't want to clobber the true passphrase error. |
| 824 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; | 824 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; |
| 825 | 825 |
| 826 // Make sure the data types that depend on the passphrase are started at | 826 // Make sure the data types that depend on the passphrase are started at |
| 827 // this time. | 827 // this time. |
| 828 const syncable::ModelEnumSet types = GetPreferredDataTypes(); | 828 const syncable::ModelTypeSet types = GetPreferredDataTypes(); |
| 829 | 829 |
| 830 if (data_type_manager_.get()) { | 830 if (data_type_manager_.get()) { |
| 831 // Unblock the data type manager if necessary. | 831 // Unblock the data type manager if necessary. |
| 832 data_type_manager_->Configure(types, | 832 data_type_manager_->Configure(types, |
| 833 sync_api::CONFIGURE_REASON_RECONFIGURATION); | 833 sync_api::CONFIGURE_REASON_RECONFIGURATION); |
| 834 } | 834 } |
| 835 | 835 |
| 836 ResolvePassphraseRequired(); | 836 ResolvePassphraseRequired(); |
| 837 } | 837 } |
| 838 | 838 |
| 839 void ProfileSyncService::ResolvePassphraseRequired() { | 839 void ProfileSyncService::ResolvePassphraseRequired() { |
| 840 DCHECK(!IsPassphraseRequiredForDecryption()); | 840 DCHECK(!IsPassphraseRequiredForDecryption()); |
| 841 // Don't hold on to a passphrase in raw form longer than needed. | 841 // Don't hold on to a passphrase in raw form longer than needed. |
| 842 cached_passphrases_ = CachedPassphrases(); | 842 cached_passphrases_ = CachedPassphrases(); |
| 843 | 843 |
| 844 // If No encryption is pending and our passphrase has been accepted, tell the | 844 // If No encryption is pending and our passphrase has been accepted, tell the |
| 845 // wizard we're done (no need to hang around waiting for the sync to | 845 // wizard we're done (no need to hang around waiting for the sync to |
| 846 // complete). If encryption is pending, its successful completion will trigger | 846 // complete). If encryption is pending, its successful completion will trigger |
| 847 // the done step. | 847 // the done step. |
| 848 if (WizardIsVisible() && !encryption_pending()) | 848 if (WizardIsVisible() && !encryption_pending()) |
| 849 wizard_.Step(SyncSetupWizard::DONE); | 849 wizard_.Step(SyncSetupWizard::DONE); |
| 850 | 850 |
| 851 NotifyObservers(); | 851 NotifyObservers(); |
| 852 } | 852 } |
| 853 | 853 |
| 854 void ProfileSyncService::OnEncryptedTypesChanged( | 854 void ProfileSyncService::OnEncryptedTypesChanged( |
| 855 syncable::ModelEnumSet encrypted_types, | 855 syncable::ModelTypeSet encrypted_types, |
| 856 bool encrypt_everything) { | 856 bool encrypt_everything) { |
| 857 encrypted_types_ = encrypted_types; | 857 encrypted_types_ = encrypted_types; |
| 858 encrypt_everything_ = encrypt_everything; | 858 encrypt_everything_ = encrypt_everything; |
| 859 DVLOG(1) << "Encrypted types changed to " | 859 DVLOG(1) << "Encrypted types changed to " |
| 860 << syncable::ModelEnumSetToString(encrypted_types_) | 860 << syncable::ModelTypeSetToString(encrypted_types_) |
| 861 << " (encrypt everything is set to " | 861 << " (encrypt everything is set to " |
| 862 << (encrypt_everything_ ? "true" : "false") << ")"; | 862 << (encrypt_everything_ ? "true" : "false") << ")"; |
| 863 DCHECK(encrypted_types_.Has(syncable::PASSWORDS)); | 863 DCHECK(encrypted_types_.Has(syncable::PASSWORDS)); |
| 864 } | 864 } |
| 865 | 865 |
| 866 void ProfileSyncService::OnEncryptionComplete() { | 866 void ProfileSyncService::OnEncryptionComplete() { |
| 867 DVLOG(1) << "Encryption complete"; | 867 DVLOG(1) << "Encryption complete"; |
| 868 if (encryption_pending_ && encrypt_everything_) { | 868 if (encryption_pending_ && encrypt_everything_) { |
| 869 encryption_pending_ = false; | 869 encryption_pending_ = false; |
| 870 // The user had chosen to encrypt datatypes. This is the last thing to | 870 // The user had chosen to encrypt datatypes. This is the last thing to |
| 871 // complete, so now that we're done notify the UI. | 871 // complete, so now that we're done notify the UI. |
| 872 wizard_.Step(SyncSetupWizard::DONE); | 872 wizard_.Step(SyncSetupWizard::DONE); |
| 873 // This is to nudge the integration tests when encryption is | 873 // This is to nudge the integration tests when encryption is |
| 874 // finished. | 874 // finished. |
| 875 NotifyObservers(); | 875 NotifyObservers(); |
| 876 } | 876 } |
| 877 } | 877 } |
| 878 | 878 |
| 879 void ProfileSyncService::OnMigrationNeededForTypes( | 879 void ProfileSyncService::OnMigrationNeededForTypes( |
| 880 syncable::ModelEnumSet types) { | 880 syncable::ModelTypeSet types) { |
| 881 DCHECK(backend_initialized_); | 881 DCHECK(backend_initialized_); |
| 882 DCHECK(data_type_manager_.get()); | 882 DCHECK(data_type_manager_.get()); |
| 883 | 883 |
| 884 // Migrator must be valid, because we don't sync until it is created and this | 884 // Migrator must be valid, because we don't sync until it is created and this |
| 885 // callback originates from a sync cycle. | 885 // callback originates from a sync cycle. |
| 886 migrator_->MigrateTypes(types); | 886 migrator_->MigrateTypes(types); |
| 887 } | 887 } |
| 888 | 888 |
| 889 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { | 889 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { |
| 890 last_actionable_error_ = error; | 890 last_actionable_error_ = error; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 is_auth_in_progress_ = true; | 1090 is_auth_in_progress_ = true; |
| 1091 | 1091 |
| 1092 // The user has submitted credentials, which indicates they don't | 1092 // The user has submitted credentials, which indicates they don't |
| 1093 // want to suppress start up anymore. | 1093 // want to suppress start up anymore. |
| 1094 sync_prefs_.SetStartSuppressed(false); | 1094 sync_prefs_.SetStartSuppressed(false); |
| 1095 | 1095 |
| 1096 signin_->StartOAuthSignIn(oauth1_request_token); | 1096 signin_->StartOAuthSignIn(oauth1_request_token); |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything, | 1099 void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything, |
| 1100 syncable::ModelEnumSet chosen_types) { | 1100 syncable::ModelTypeSet chosen_types) { |
| 1101 if (!backend_.get() && | 1101 if (!backend_.get() && |
| 1102 unrecoverable_error_detected_ == false) { | 1102 unrecoverable_error_detected_ == false) { |
| 1103 NOTREACHED(); | 1103 NOTREACHED(); |
| 1104 return; | 1104 return; |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 sync_prefs_.SetKeepEverythingSynced(sync_everything); | 1107 sync_prefs_.SetKeepEverythingSynced(sync_everything); |
| 1108 | 1108 |
| 1109 failed_datatypes_handler_.OnUserChoseDatatypes(); | 1109 failed_datatypes_handler_.OnUserChoseDatatypes(); |
| 1110 ChangePreferredDataTypes(chosen_types); | 1110 ChangePreferredDataTypes(chosen_types); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1130 // succeeds, calling OnAuthError(NONE), or b) the user clicks the button, | 1130 // succeeds, calling OnAuthError(NONE), or b) the user clicks the button, |
| 1131 // and tries to re-authenticate. (b) is a little awkward as this second | 1131 // and tries to re-authenticate. (b) is a little awkward as this second |
| 1132 // request will get queued behind the first and could wind up "undoing" the | 1132 // request will get queued behind the first and could wind up "undoing" the |
| 1133 // good if invalid creds were provided, but it's an edge case and the user | 1133 // good if invalid creds were provided, but it's an edge case and the user |
| 1134 // can of course get themselves out of it. | 1134 // can of course get themselves out of it. |
| 1135 is_auth_in_progress_ = false; | 1135 is_auth_in_progress_ = false; |
| 1136 NotifyObservers(); | 1136 NotifyObservers(); |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 void ProfileSyncService::ChangePreferredDataTypes( | 1139 void ProfileSyncService::ChangePreferredDataTypes( |
| 1140 syncable::ModelEnumSet preferred_types) { | 1140 syncable::ModelTypeSet preferred_types) { |
| 1141 | 1141 |
| 1142 DVLOG(1) << "ChangePreferredDataTypes invoked"; | 1142 DVLOG(1) << "ChangePreferredDataTypes invoked"; |
| 1143 const syncable::ModelEnumSet registered_types = GetRegisteredDataTypes(); | 1143 const syncable::ModelTypeSet registered_types = GetRegisteredDataTypes(); |
| 1144 const syncable::ModelEnumSet registered_preferred_types = | 1144 const syncable::ModelTypeSet registered_preferred_types = |
| 1145 Intersection(registered_types, preferred_types); | 1145 Intersection(registered_types, preferred_types); |
| 1146 sync_prefs_.SetPreferredDataTypes(registered_types, | 1146 sync_prefs_.SetPreferredDataTypes(registered_types, |
| 1147 registered_preferred_types); | 1147 registered_preferred_types); |
| 1148 | 1148 |
| 1149 // Now reconfigure the DTM. | 1149 // Now reconfigure the DTM. |
| 1150 ReconfigureDatatypeManager(); | 1150 ReconfigureDatatypeManager(); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 syncable::ModelEnumSet ProfileSyncService::GetPreferredDataTypes() const { | 1153 syncable::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const { |
| 1154 const syncable::ModelEnumSet registered_types = GetRegisteredDataTypes(); | 1154 const syncable::ModelTypeSet registered_types = GetRegisteredDataTypes(); |
| 1155 const syncable::ModelEnumSet preferred_types = | 1155 const syncable::ModelTypeSet preferred_types = |
| 1156 sync_prefs_.GetPreferredDataTypes(registered_types); | 1156 sync_prefs_.GetPreferredDataTypes(registered_types); |
| 1157 const syncable::ModelEnumSet failed_types = | 1157 const syncable::ModelTypeSet failed_types = |
| 1158 failed_datatypes_handler_.GetFailedTypes(); | 1158 failed_datatypes_handler_.GetFailedTypes(); |
| 1159 return Difference(preferred_types, failed_types); | 1159 return Difference(preferred_types, failed_types); |
| 1160 } | 1160 } |
| 1161 | 1161 |
| 1162 syncable::ModelEnumSet ProfileSyncService::GetRegisteredDataTypes() const { | 1162 syncable::ModelTypeSet ProfileSyncService::GetRegisteredDataTypes() const { |
| 1163 syncable::ModelEnumSet registered_types; | 1163 syncable::ModelTypeSet registered_types; |
| 1164 // The data_type_controllers_ are determined by command-line flags; that's | 1164 // The data_type_controllers_ are determined by command-line flags; that's |
| 1165 // effectively what controls the values returned here. | 1165 // effectively what controls the values returned here. |
| 1166 for (DataTypeController::TypeMap::const_iterator it = | 1166 for (DataTypeController::TypeMap::const_iterator it = |
| 1167 data_type_controllers_.begin(); | 1167 data_type_controllers_.begin(); |
| 1168 it != data_type_controllers_.end(); ++it) { | 1168 it != data_type_controllers_.end(); ++it) { |
| 1169 registered_types.Put(it->first); | 1169 registered_types.Put(it->first); |
| 1170 } | 1170 } |
| 1171 return registered_types; | 1171 return registered_types; |
| 1172 } | 1172 } |
| 1173 | 1173 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, | 1208 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, |
| 1209 content::Source<DataTypeManager>(data_type_manager_.get())); | 1209 content::Source<DataTypeManager>(data_type_manager_.get())); |
| 1210 | 1210 |
| 1211 // We create the migrator at the same time. | 1211 // We create the migrator at the same time. |
| 1212 migrator_.reset( | 1212 migrator_.reset( |
| 1213 new browser_sync::BackendMigrator( | 1213 new browser_sync::BackendMigrator( |
| 1214 profile_->GetDebugName(), GetUserShare(), | 1214 profile_->GetDebugName(), GetUserShare(), |
| 1215 this, data_type_manager_.get())); | 1215 this, data_type_manager_.get())); |
| 1216 } | 1216 } |
| 1217 | 1217 |
| 1218 const syncable::ModelEnumSet types = GetPreferredDataTypes(); | 1218 const syncable::ModelTypeSet types = GetPreferredDataTypes(); |
| 1219 if (IsPassphraseRequiredForDecryption()) { | 1219 if (IsPassphraseRequiredForDecryption()) { |
| 1220 // We need a passphrase still. We don't bother to attempt to configure | 1220 // We need a passphrase still. We don't bother to attempt to configure |
| 1221 // until we receive an OnPassphraseAccepted (which triggers a configure). | 1221 // until we receive an OnPassphraseAccepted (which triggers a configure). |
| 1222 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " | 1222 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " |
| 1223 << "because a passphrase required"; | 1223 << "because a passphrase required"; |
| 1224 return; | 1224 return; |
| 1225 } | 1225 } |
| 1226 sync_api::ConfigureReason reason = sync_api::CONFIGURE_REASON_UNKNOWN; | 1226 sync_api::ConfigureReason reason = sync_api::CONFIGURE_REASON_UNKNOWN; |
| 1227 if (!HasSyncSetupCompleted()) { | 1227 if (!HasSyncSetupCompleted()) { |
| 1228 reason = sync_api::CONFIGURE_REASON_NEW_CLIENT; | 1228 reason = sync_api::CONFIGURE_REASON_NEW_CLIENT; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 // initialized (via IsEncryptedDatatypeEnabled and | 1322 // initialized (via IsEncryptedDatatypeEnabled and |
| 1323 // IsPassphraseRequiredForDecryption). | 1323 // IsPassphraseRequiredForDecryption). |
| 1324 return encryption_pending_; | 1324 return encryption_pending_; |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 bool ProfileSyncService::EncryptEverythingEnabled() const { | 1327 bool ProfileSyncService::EncryptEverythingEnabled() const { |
| 1328 DCHECK(backend_initialized_); | 1328 DCHECK(backend_initialized_); |
| 1329 return encrypt_everything_; | 1329 return encrypt_everything_; |
| 1330 } | 1330 } |
| 1331 | 1331 |
| 1332 syncable::ModelEnumSet ProfileSyncService::GetEncryptedDataTypes() const { | 1332 syncable::ModelTypeSet ProfileSyncService::GetEncryptedDataTypes() const { |
| 1333 DCHECK(encrypted_types_.Has(syncable::PASSWORDS)); | 1333 DCHECK(encrypted_types_.Has(syncable::PASSWORDS)); |
| 1334 // We may be called during the setup process before we're | 1334 // We may be called during the setup process before we're |
| 1335 // initialized. In this case, we default to the sensitive types. | 1335 // initialized. In this case, we default to the sensitive types. |
| 1336 return encrypted_types_; | 1336 return encrypted_types_; |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 void ProfileSyncService::OnSyncManagedPrefChange(bool is_sync_managed) { | 1339 void ProfileSyncService::OnSyncManagedPrefChange(bool is_sync_managed) { |
| 1340 NotifyObservers(); | 1340 NotifyObservers(); |
| 1341 if (is_sync_managed) { | 1341 if (is_sync_managed) { |
| 1342 DisableForUser(); | 1342 DisableForUser(); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 << "Unrecoverable error."; | 1565 << "Unrecoverable error."; |
| 1566 } else { | 1566 } else { |
| 1567 DVLOG(0) << "ConfigureDataTypeManager not invoked because backend is not " | 1567 DVLOG(0) << "ConfigureDataTypeManager not invoked because backend is not " |
| 1568 << "initialized"; | 1568 << "initialized"; |
| 1569 } | 1569 } |
| 1570 } | 1570 } |
| 1571 | 1571 |
| 1572 const FailedDatatypesHandler& ProfileSyncService::failed_datatypes_handler() { | 1572 const FailedDatatypesHandler& ProfileSyncService::failed_datatypes_handler() { |
| 1573 return failed_datatypes_handler_; | 1573 return failed_datatypes_handler_; |
| 1574 } | 1574 } |
| OLD | NEW |