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 "components/browser_sync/profile_sync_service.h" | 5 #include "components/browser_sync/profile_sync_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 if (HasUnrecoverableError()) { | 1127 if (HasUnrecoverableError()) { |
1128 // When unrecoverable error is detected we post a task to shutdown the | 1128 // When unrecoverable error is detected we post a task to shutdown the |
1129 // backend. The task might not have executed yet. | 1129 // backend. The task might not have executed yet. |
1130 return; | 1130 return; |
1131 } | 1131 } |
1132 | 1132 |
1133 DVLOG(1) << "Passphrase required with reason: " | 1133 DVLOG(1) << "Passphrase required with reason: " |
1134 << syncer::PassphraseRequiredReasonToString(reason); | 1134 << syncer::PassphraseRequiredReasonToString(reason); |
1135 passphrase_required_reason_ = reason; | 1135 passphrase_required_reason_ = reason; |
1136 | 1136 |
1137 // TODO(stanisc): http://crbug.com/351005: Does this support USS types? | |
1138 const syncer::ModelTypeSet types = GetPreferredDataTypes(); | 1137 const syncer::ModelTypeSet types = GetPreferredDataTypes(); |
1139 if (data_type_manager_) { | 1138 if (data_type_manager_) { |
1140 // Reconfigure without the encrypted types (excluded implicitly via the | 1139 // Reconfigure without the encrypted types (excluded implicitly via the |
1141 // failed datatypes handler). | 1140 // failed datatypes handler). |
1142 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO); | 1141 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO); |
1143 } | 1142 } |
1144 | 1143 |
1145 // Notify observers that the passphrase status may have changed. | 1144 // Notify observers that the passphrase status may have changed. |
1146 NotifyObservers(); | 1145 NotifyObservers(); |
1147 } | 1146 } |
1148 | 1147 |
1149 void ProfileSyncService::OnPassphraseAccepted() { | 1148 void ProfileSyncService::OnPassphraseAccepted() { |
1150 DVLOG(1) << "Received OnPassphraseAccepted."; | 1149 DVLOG(1) << "Received OnPassphraseAccepted."; |
1151 | 1150 |
1152 // If the pending keys were resolved via keystore, it's possible we never | 1151 // If the pending keys were resolved via keystore, it's possible we never |
1153 // consumed our cached passphrase. Clear it now. | 1152 // consumed our cached passphrase. Clear it now. |
1154 if (!cached_passphrase_.empty()) | 1153 if (!cached_passphrase_.empty()) |
1155 cached_passphrase_.clear(); | 1154 cached_passphrase_.clear(); |
1156 | 1155 |
1157 // Reset passphrase_required_reason_ since we know we no longer require the | 1156 // Reset passphrase_required_reason_ since we know we no longer require the |
1158 // passphrase. We do this here rather than down in ResolvePassphraseRequired() | 1157 // passphrase. We do this here rather than down in ResolvePassphraseRequired() |
1159 // because that can be called by OnPassphraseRequired() if no encrypted data | 1158 // because that can be called by OnPassphraseRequired() if no encrypted data |
1160 // types are enabled, and we don't want to clobber the true passphrase error. | 1159 // types are enabled, and we don't want to clobber the true passphrase error. |
1161 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; | 1160 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; |
1162 | 1161 |
1163 // Make sure the data types that depend on the passphrase are started at | 1162 // Make sure the data types that depend on the passphrase are started at |
1164 // this time. | 1163 // this time. |
1165 // TODO(stanisc): http://crbug.com/351005: Does this support USS types? | |
1166 const syncer::ModelTypeSet types = GetPreferredDataTypes(); | 1164 const syncer::ModelTypeSet types = GetPreferredDataTypes(); |
1167 if (data_type_manager_) { | 1165 if (data_type_manager_) { |
1168 // Re-enable any encrypted types if necessary. | 1166 // Re-enable any encrypted types if necessary. |
1169 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO); | 1167 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO); |
1170 } | 1168 } |
1171 | 1169 |
1172 NotifyObservers(); | 1170 NotifyObservers(); |
1173 } | 1171 } |
1174 | 1172 |
1175 void ProfileSyncService::OnEncryptedTypesChanged( | 1173 void ProfileSyncService::OnEncryptedTypesChanged( |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 if (awaiting_types_.Empty()) { | 2214 if (awaiting_types_.Empty()) { |
2217 callback_.Run(std::move(result_accumulator_)); | 2215 callback_.Run(std::move(result_accumulator_)); |
2218 callback_.Reset(); | 2216 callback_.Reset(); |
2219 } | 2217 } |
2220 } | 2218 } |
2221 | 2219 |
2222 } // namespace | 2220 } // namespace |
2223 | 2221 |
2224 void ProfileSyncService::GetAllNodes( | 2222 void ProfileSyncService::GetAllNodes( |
2225 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) { | 2223 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) { |
2226 // TODO(stanisc): crbug.com/328606: Make this work for USS datatypes. | |
2227 ModelTypeSet all_types = GetActiveDataTypes(); | 2224 ModelTypeSet all_types = GetActiveDataTypes(); |
2228 all_types.PutAll(syncer::ControlTypes()); | 2225 all_types.PutAll(syncer::ControlTypes()); |
2229 scoped_refptr<GetAllNodesRequestHelper> helper = | 2226 scoped_refptr<GetAllNodesRequestHelper> helper = |
2230 new GetAllNodesRequestHelper(all_types, callback); | 2227 new GetAllNodesRequestHelper(all_types, callback); |
2231 | 2228 |
2232 if (!backend_initialized_) { | 2229 if (!backend_initialized_) { |
2233 // If there's no backend available to fulfill the request, handle it here. | 2230 // If there's no backend available to fulfill the request, handle it here. |
2234 for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) { | 2231 for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) { |
2235 helper->OnReceivedNodesForType(it.Get(), | 2232 helper->OnReceivedNodesForType(it.Get(), |
2236 base::MakeUnique<base::ListValue>()); | 2233 base::MakeUnique<base::ListValue>()); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2498 | 2495 |
2499 DCHECK(startup_controller_->IsSetupInProgress()); | 2496 DCHECK(startup_controller_->IsSetupInProgress()); |
2500 startup_controller_->SetSetupInProgress(false); | 2497 startup_controller_->SetSetupInProgress(false); |
2501 | 2498 |
2502 if (IsBackendInitialized()) | 2499 if (IsBackendInitialized()) |
2503 ReconfigureDatatypeManager(); | 2500 ReconfigureDatatypeManager(); |
2504 NotifyObservers(); | 2501 NotifyObservers(); |
2505 } | 2502 } |
2506 | 2503 |
2507 } // namespace browser_sync | 2504 } // namespace browser_sync |
OLD | NEW |