OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/task.h" | 11 #include "base/task.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
14 #include "chrome/browser/net/gaia/token_service.h" | 14 #include "chrome/browser/net/gaia/token_service.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/sync/engine/syncapi.h" | 17 #include "chrome/browser/sync/engine/syncapi.h" |
18 #include "chrome/browser/sync/glue/autofill_model_associator.h" | |
19 #include "chrome/browser/sync/glue/autofill_profile_model_associator.h" | |
18 #include "chrome/browser/sync/glue/change_processor.h" | 20 #include "chrome/browser/sync/glue/change_processor.h" |
19 #include "chrome/browser/sync/glue/database_model_worker.h" | 21 #include "chrome/browser/sync/glue/database_model_worker.h" |
20 #include "chrome/browser/sync/glue/history_model_worker.h" | 22 #include "chrome/browser/sync/glue/history_model_worker.h" |
21 #include "chrome/browser/sync/glue/sync_backend_host.h" | 23 #include "chrome/browser/sync/glue/sync_backend_host.h" |
22 #include "chrome/browser/sync/glue/http_bridge.h" | 24 #include "chrome/browser/sync/glue/http_bridge.h" |
23 #include "chrome/browser/sync/glue/password_model_worker.h" | 25 #include "chrome/browser/sync/glue/password_model_worker.h" |
24 #include "chrome/browser/sync/sessions/session_state.h" | 26 #include "chrome/browser/sync/sessions/session_state.h" |
25 // TODO(tim): Remove this! We should have a syncapi pass-thru instead. | 27 // TODO(tim): Remove this! We should have a syncapi pass-thru instead. |
26 #include "chrome/browser/sync/syncable/directory_manager.h" // Cryptographer. | 28 #include "chrome/browser/sync/syncable/directory_manager.h" // Cryptographer. |
29 #include "chrome/browser/sync/syncable/model_type.h" | |
27 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/chrome_version_info.h" | 31 #include "chrome/common/chrome_version_info.h" |
29 #include "chrome/common/net/gaia/gaia_constants.h" | 32 #include "chrome/common/net/gaia/gaia_constants.h" |
30 #include "chrome/common/notification_service.h" | 33 #include "chrome/common/notification_service.h" |
31 #include "chrome/common/notification_type.h" | 34 #include "chrome/common/notification_type.h" |
32 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
33 #include "webkit/glue/webkit_glue.h" | 36 #include "webkit/glue/webkit_glue.h" |
34 | 37 |
35 static const int kSaveChangesIntervalSeconds = 10; | 38 static const int kSaveChangesIntervalSeconds = 10; |
36 static const FilePath::CharType kSyncDataFolderName[] = | 39 static const FilePath::CharType kSyncDataFolderName[] = |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 registrar_.workers[GROUP_PASSWORD] = NULL; | 247 registrar_.workers[GROUP_PASSWORD] = NULL; |
245 registrar_.workers.erase(GROUP_DB); | 248 registrar_.workers.erase(GROUP_DB); |
246 registrar_.workers.erase(GROUP_HISTORY); | 249 registrar_.workers.erase(GROUP_HISTORY); |
247 registrar_.workers.erase(GROUP_UI); | 250 registrar_.workers.erase(GROUP_UI); |
248 registrar_.workers.erase(GROUP_PASSIVE); | 251 registrar_.workers.erase(GROUP_PASSIVE); |
249 registrar_.workers.erase(GROUP_PASSWORD); | 252 registrar_.workers.erase(GROUP_PASSWORD); |
250 frontend_ = NULL; | 253 frontend_ = NULL; |
251 core_ = NULL; // Releases reference to core_. | 254 core_ = NULL; // Releases reference to core_. |
252 } | 255 } |
253 | 256 |
257 syncable::AutofillMigrationState | |
258 SyncBackendHost::GetAutofillMigrationState() { | |
259 return core_->syncapi()->GetAutofillMigrationState(); | |
260 } | |
261 | |
262 void SyncBackendHost::SetAutofillMigrationState( | |
263 syncable::AutofillMigrationState state) { | |
264 return core_->syncapi()->SetAutofillMigrationState(state); | |
265 } | |
266 | |
267 syncable::AutofillMigrationDebugInfo | |
268 SyncBackendHost::GetAutofillMigrationDebugInfo() { | |
269 return core_->syncapi()->GetAutofillMigrationDebugInfo(); | |
270 } | |
271 | |
272 void SyncBackendHost::SetAutofillMigrationDebugInfo( | |
273 syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set, | |
274 const syncable::AutofillMigrationDebugInfo& info) { | |
275 return core_->syncapi()->SetAutofillMigrationDebugInfo(property_to_set, info); | |
276 } | |
277 | |
278 void SyncBackendHost::ConfigureAutofillMigration() { | |
279 if (GetAutofillMigrationState() == syncable::NOT_DETERMINED) { | |
280 sync_api::ReadTransaction trans(GetUserShareHandle()); | |
281 sync_api::ReadNode autofil_root_node(&trans); | |
282 | |
283 // Check for the presence of autofill node. | |
284 if (!autofil_root_node.InitByTagLookup(browser_sync::kAutofillTag)) { | |
285 SetAutofillMigrationState(syncable::INSUFFICIENT_INFO_TO_DETERMINE); | |
286 return; | |
287 } | |
288 | |
289 // Check for children under autofill node. | |
290 if (autofil_root_node.GetFirstChildId() == static_cast<int64>(0)) { | |
291 SetAutofillMigrationState(syncable::INSUFFICIENT_INFO_TO_DETERMINE); | |
292 return; | |
293 } | |
294 | |
295 sync_api::ReadNode autofill_profile_root_node(&trans); | |
296 | |
297 // Check for the presence of autofill profile root node. | |
298 if (!autofill_profile_root_node.InitByTagLookup( | |
299 browser_sync::kAutofillProfileTag)) { | |
300 SetAutofillMigrationState(syncable::NOT_MIGRATED); | |
301 return; | |
302 } | |
303 | |
304 // If our state is not determined then we should not have the autofill | |
305 // profile node. | |
306 DCHECK(false); | |
307 | |
308 // just set it as not migrated. | |
309 SetAutofillMigrationState( | |
310 syncable::NOT_MIGRATED); | |
tim (not reviewing)
2010/12/15 20:11:42
nit - on previous line.
lipalani
2010/12/15 21:28:15
Done.
| |
311 return; | |
312 } | |
313 } | |
314 | |
254 void SyncBackendHost::ConfigureDataTypes(const syncable::ModelTypeSet& types, | 315 void SyncBackendHost::ConfigureDataTypes(const syncable::ModelTypeSet& types, |
255 CancelableTask* ready_task) { | 316 CancelableTask* ready_task) { |
256 // Only one configure is allowed at a time. | 317 // Only one configure is allowed at a time. |
257 DCHECK(!configure_ready_task_.get()); | 318 DCHECK(!configure_ready_task_.get()); |
258 DCHECK(syncapi_initialized_); | 319 DCHECK(syncapi_initialized_); |
259 | 320 |
321 if (types.count(syncable::AUTOFILL_PROFILE) != 0) { | |
322 ConfigureAutofillMigration(); | |
323 } | |
324 | |
260 bool deleted_type = false; | 325 bool deleted_type = false; |
261 | 326 |
262 { | 327 { |
263 AutoLock lock(registrar_lock_); | 328 AutoLock lock(registrar_lock_); |
264 for (DataTypeController::TypeMap::const_iterator it = | 329 for (DataTypeController::TypeMap::const_iterator it = |
265 data_type_controllers_.begin(); | 330 data_type_controllers_.begin(); |
266 it != data_type_controllers_.end(); ++it) { | 331 it != data_type_controllers_.end(); ++it) { |
267 syncable::ModelType type = (*it).first; | 332 syncable::ModelType type = (*it).first; |
268 | 333 |
269 // If a type is not specified, remove it from the routing_info. | 334 // If a type is not specified, remove it from the routing_info. |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
818 } | 883 } |
819 | 884 |
820 void SyncBackendHost::Core::DeleteSyncDataFolder() { | 885 void SyncBackendHost::Core::DeleteSyncDataFolder() { |
821 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { | 886 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { |
822 if (!file_util::Delete(host_->sync_data_folder_path(), true)) | 887 if (!file_util::Delete(host_->sync_data_folder_path(), true)) |
823 LOG(DFATAL) << "Could not delete the Sync Data folder."; | 888 LOG(DFATAL) << "Could not delete the Sync Data folder."; |
824 } | 889 } |
825 } | 890 } |
826 | 891 |
827 } // namespace browser_sync | 892 } // namespace browser_sync |
OLD | NEW |