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 "sync/internal_api/sync_manager_impl.h" | 5 #include "sync/internal_api/sync_manager_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 observing_ip_address_changes_ = true; | 468 observing_ip_address_changes_ = true; |
469 | 469 |
470 UpdateCredentials(credentials); | 470 UpdateCredentials(credentials); |
471 | 471 |
472 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 472 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
473 OnInitializationComplete( | 473 OnInitializationComplete( |
474 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), | 474 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), |
475 true, InitialSyncEndedTypes())); | 475 true, InitialSyncEndedTypes())); |
476 } | 476 } |
477 | 477 |
478 void SyncManagerImpl::UpdateSessionNameCallback( | |
479 const std::string& chrome_version, | |
480 const std::string& session_name) { | |
481 WriteTransaction trans(FROM_HERE, GetUserShare()); | |
482 WriteNode node(&trans); | |
483 // TODO(rlarocque): switch to device info node. | |
484 if (node.InitByTagLookup(syncer::kNigoriTag) != syncer::BaseNode::INIT_OK) { | |
485 return; | |
486 } | |
487 | |
488 sync_pb::NigoriSpecifics nigori(node.GetNigoriSpecifics()); | |
489 // Add or update device information. | |
490 bool contains_this_device = false; | |
491 for (int i = 0; i < nigori.device_information_size(); ++i) { | |
492 const sync_pb::DeviceInformation& device_information = | |
493 nigori.device_information(i); | |
494 if (device_information.cache_guid() == directory()->cache_guid()) { | |
495 // Update the version number in case it changed due to an update. | |
496 if (device_information.chrome_version() != chrome_version) { | |
497 sync_pb::DeviceInformation* mutable_device_information = | |
498 nigori.mutable_device_information(i); | |
499 mutable_device_information->set_chrome_version( | |
500 chrome_version); | |
501 } | |
502 contains_this_device = true; | |
503 } | |
504 } | |
505 | |
506 if (!contains_this_device) { | |
507 sync_pb::DeviceInformation* device_information = | |
508 nigori.add_device_information(); | |
509 device_information->set_cache_guid(directory()->cache_guid()); | |
510 #if defined(OS_CHROMEOS) | |
511 device_information->set_platform("ChromeOS"); | |
512 #elif defined(OS_LINUX) | |
513 device_information->set_platform("Linux"); | |
514 #elif defined(OS_MACOSX) | |
515 device_information->set_platform("Mac"); | |
516 #elif defined(OS_WIN) | |
517 device_information->set_platform("Windows"); | |
518 #endif | |
519 device_information->set_name(session_name); | |
520 device_information->set_chrome_version(chrome_version); | |
521 } | |
522 node.SetNigoriSpecifics(nigori); | |
523 } | |
524 | |
525 | |
526 void SyncManagerImpl::OnPassphraseRequired( | 478 void SyncManagerImpl::OnPassphraseRequired( |
527 PassphraseRequiredReason reason, | 479 PassphraseRequiredReason reason, |
528 const sync_pb::EncryptedData& pending_keys) { | 480 const sync_pb::EncryptedData& pending_keys) { |
529 // Does nothing. | 481 // Does nothing. |
530 } | 482 } |
531 | 483 |
532 void SyncManagerImpl::OnPassphraseAccepted() { | 484 void SyncManagerImpl::OnPassphraseAccepted() { |
533 // Does nothing. | 485 // Does nothing. |
534 } | 486 } |
535 | 487 |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1310 int SyncManagerImpl::GetDefaultNudgeDelay() { |
1359 return kDefaultNudgeDelayMilliseconds; | 1311 return kDefaultNudgeDelayMilliseconds; |
1360 } | 1312 } |
1361 | 1313 |
1362 // static. | 1314 // static. |
1363 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1315 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
1364 return kPreferencesNudgeDelayMilliseconds; | 1316 return kPreferencesNudgeDelayMilliseconds; |
1365 } | 1317 } |
1366 | 1318 |
1367 } // namespace syncer | 1319 } // namespace syncer |
OLD | NEW |