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() | |
280 == syncable::NOT_DETERMINED) { | |
tim (not reviewing)
2010/12/13 19:24:33
== should go on previous line, and then indent her
lipalani
2010/12/14 21:05:57
Done.
| |
281 sync_api::ReadTransaction trans(GetUserShareHandle()); | |
282 sync_api::ReadNode autofil_root_node(&trans); | |
283 | |
284 // Check for the presence of autofill node. | |
285 if (!autofil_root_node.InitByTagLookup(browser_sync::kAutofillTag)) { | |
tim (not reviewing)
2010/12/13 19:24:33
typo: autofill
lipalani
2010/12/14 21:05:57
Done.
| |
286 SetAutofillMigrationState( | |
287 syncable::INSUFFICIENT_INFO_TO_DETERMINE); | |
288 return; | |
289 } | |
290 | |
291 // Check for children under autofill node. | |
292 if (autofil_root_node.GetFirstChildId() == static_cast<int64>(0)) { | |
293 SetAutofillMigrationState( | |
294 syncable::INSUFFICIENT_INFO_TO_DETERMINE); | |
tim (not reviewing)
2010/12/13 19:24:33
fits on prev line? maybe?
lipalani
2010/12/14 21:05:57
Done.
| |
295 return; | |
296 } | |
297 | |
298 sync_api::ReadNode autofill_profile_root_node(&trans); | |
299 | |
300 // Check for the presence of autofill profile root node. | |
301 if (!autofill_profile_root_node.InitByTagLookup( | |
302 browser_sync::kAutofillProfileTag)) { | |
303 SetAutofillMigrationState( | |
304 syncable::NOT_MIGRATED); | |
305 return; | |
306 } | |
307 | |
308 // If our state is not determined then we should not have the autofill | |
309 // profile node. | |
310 DCHECK(false); | |
311 | |
312 // just set it as not migrated. | |
313 SetAutofillMigrationState( | |
314 syncable::NOT_MIGRATED); | |
tim (not reviewing)
2010/12/13 19:24:33
fits on prev line.
lipalani
2010/12/14 21:05:57
Done.
| |
315 return; | |
316 } | |
317 } | |
318 | |
254 void SyncBackendHost::ConfigureDataTypes(const syncable::ModelTypeSet& types, | 319 void SyncBackendHost::ConfigureDataTypes(const syncable::ModelTypeSet& types, |
255 CancelableTask* ready_task) { | 320 CancelableTask* ready_task) { |
256 // Only one configure is allowed at a time. | 321 // Only one configure is allowed at a time. |
257 DCHECK(!configure_ready_task_.get()); | 322 DCHECK(!configure_ready_task_.get()); |
258 DCHECK(syncapi_initialized_); | 323 DCHECK(syncapi_initialized_); |
259 | 324 |
325 if (types.count(syncable::AUTOFILL_PROFILE) != 0) { | |
326 ConfigureAutofillMigration(); | |
327 } | |
328 | |
260 bool deleted_type = false; | 329 bool deleted_type = false; |
261 | 330 |
262 { | 331 { |
263 AutoLock lock(registrar_lock_); | 332 AutoLock lock(registrar_lock_); |
264 for (DataTypeController::TypeMap::const_iterator it = | 333 for (DataTypeController::TypeMap::const_iterator it = |
265 data_type_controllers_.begin(); | 334 data_type_controllers_.begin(); |
266 it != data_type_controllers_.end(); ++it) { | 335 it != data_type_controllers_.end(); ++it) { |
267 syncable::ModelType type = (*it).first; | 336 syncable::ModelType type = (*it).first; |
268 | 337 |
269 // If a type is not specified, remove it from the routing_info. | 338 // 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 } | 887 } |
819 | 888 |
820 void SyncBackendHost::Core::DeleteSyncDataFolder() { | 889 void SyncBackendHost::Core::DeleteSyncDataFolder() { |
821 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { | 890 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { |
822 if (!file_util::Delete(host_->sync_data_folder_path(), true)) | 891 if (!file_util::Delete(host_->sync_data_folder_path(), true)) |
823 LOG(DFATAL) << "Could not delete the Sync Data folder."; | 892 LOG(DFATAL) << "Could not delete the Sync Data folder."; |
824 } | 893 } |
825 } | 894 } |
826 | 895 |
827 } // namespace browser_sync | 896 } // namespace browser_sync |
OLD | NEW |