| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 using browser_sync::ChangeProcessor; | 64 using browser_sync::ChangeProcessor; |
| 65 using browser_sync::DataTypeController; | 65 using browser_sync::DataTypeController; |
| 66 using browser_sync::DataTypeManager; | 66 using browser_sync::DataTypeManager; |
| 67 using browser_sync::JsBackend; | 67 using browser_sync::JsBackend; |
| 68 using browser_sync::JsController; | 68 using browser_sync::JsController; |
| 69 using browser_sync::JsEventDetails; | 69 using browser_sync::JsEventDetails; |
| 70 using browser_sync::JsEventHandler; | 70 using browser_sync::JsEventHandler; |
| 71 using browser_sync::SyncBackendHost; | 71 using browser_sync::SyncBackendHost; |
| 72 using browser_sync::WeakHandle; | 72 using browser_sync::WeakHandle; |
| 73 using browser_sync::SyncProtocolError; | 73 using browser_sync::SyncOperationResult; |
| 74 using sync_api::SyncCredentials; | 74 using sync_api::SyncCredentials; |
| 75 | 75 |
| 76 typedef GoogleServiceAuthError AuthError; | 76 typedef GoogleServiceAuthError AuthError; |
| 77 | 77 |
| 78 const char* ProfileSyncService::kSyncServerUrl = | 78 const char* ProfileSyncService::kSyncServerUrl = |
| 79 "https://clients4.google.com/chrome-sync"; | 79 "https://clients4.google.com/chrome-sync"; |
| 80 | 80 |
| 81 const char* ProfileSyncService::kDevServerUrl = | 81 const char* ProfileSyncService::kDevServerUrl = |
| 82 "https://clients4.google.com/chrome-sync/dev"; | 82 "https://clients4.google.com/chrome-sync/dev"; |
| 83 | 83 |
| 84 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. | 84 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. |
| 85 | 85 |
| 86 | 86 |
| 87 bool ShouldShowActionOnUI( | 87 bool ShouldShowActionOnUI( |
| 88 const browser_sync::SyncProtocolError& error) { | 88 const browser_sync::SyncOperationResult& error) { |
| 89 return (error.action != browser_sync::UNKNOWN_ACTION && | 89 return (error.action != browser_sync::UNKNOWN_ACTION && |
| 90 error.action != browser_sync::DISABLE_SYNC_ON_CLIENT); | 90 error.action != browser_sync::DISABLE_SYNC_ON_CLIENT); |
| 91 } | 91 } |
| 92 | 92 |
| 93 ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory, | 93 ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory, |
| 94 Profile* profile, | 94 Profile* profile, |
| 95 SigninManager* signin_manager, | 95 SigninManager* signin_manager, |
| 96 const std::string& cros_user) | 96 const std::string& cros_user) |
| 97 : last_auth_error_(AuthError::None()), | 97 : last_auth_error_(AuthError::None()), |
| 98 passphrase_required_reason_(sync_api::REASON_PASSPHRASE_NOT_REQUIRED), | 98 passphrase_required_reason_(sync_api::REASON_PASSPHRASE_NOT_REQUIRED), |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 // TODO(akalin): Make an Observer subclass that listens and does the | 559 // TODO(akalin): Make an Observer subclass that listens and does the |
| 560 // event routing. | 560 // event routing. |
| 561 sync_js_controller_.HandleJsEvent( | 561 sync_js_controller_.HandleJsEvent( |
| 562 "onServiceStateChanged", JsEventDetails()); | 562 "onServiceStateChanged", JsEventDetails()); |
| 563 } | 563 } |
| 564 | 564 |
| 565 void ProfileSyncService::ClearStaleErrors() { | 565 void ProfileSyncService::ClearStaleErrors() { |
| 566 unrecoverable_error_detected_ = false; | 566 unrecoverable_error_detected_ = false; |
| 567 unrecoverable_error_message_.clear(); | 567 unrecoverable_error_message_.clear(); |
| 568 unrecoverable_error_location_ = tracked_objects::Location(); | 568 unrecoverable_error_location_ = tracked_objects::Location(); |
| 569 last_actionable_error_ = SyncProtocolError(); | 569 last_actionable_error_ = SyncOperationResult(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 // static | 572 // static |
| 573 const char* ProfileSyncService::GetPrefNameForDataType( | 573 const char* ProfileSyncService::GetPrefNameForDataType( |
| 574 syncable::ModelType data_type) { | 574 syncable::ModelType data_type) { |
| 575 switch (data_type) { | 575 switch (data_type) { |
| 576 case syncable::BOOKMARKS: | 576 case syncable::BOOKMARKS: |
| 577 return prefs::kSyncBookmarks; | 577 return prefs::kSyncBookmarks; |
| 578 case syncable::PASSWORDS: | 578 case syncable::PASSWORDS: |
| 579 return prefs::kSyncPasswords; | 579 return prefs::kSyncPasswords; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 void ProfileSyncService::OnMigrationNeededForTypes( | 949 void ProfileSyncService::OnMigrationNeededForTypes( |
| 950 const syncable::ModelTypeSet& types) { | 950 const syncable::ModelTypeSet& types) { |
| 951 DCHECK(backend_initialized_); | 951 DCHECK(backend_initialized_); |
| 952 DCHECK(data_type_manager_.get()); | 952 DCHECK(data_type_manager_.get()); |
| 953 | 953 |
| 954 // Migrator must be valid, because we don't sync until it is created and this | 954 // Migrator must be valid, because we don't sync until it is created and this |
| 955 // callback originates from a sync cycle. | 955 // callback originates from a sync cycle. |
| 956 migrator_->MigrateTypes(types); | 956 migrator_->MigrateTypes(types); |
| 957 } | 957 } |
| 958 | 958 |
| 959 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { | 959 void ProfileSyncService::OnActionableError(const SyncOperationResult& error) { |
| 960 last_actionable_error_ = error; | 960 last_actionable_error_ = error; |
| 961 DCHECK_NE(last_actionable_error_.action, | 961 DCHECK_NE(last_actionable_error_.action, |
| 962 browser_sync::UNKNOWN_ACTION); | 962 browser_sync::UNKNOWN_ACTION); |
| 963 switch (error.action) { | 963 switch (error.action) { |
| 964 case browser_sync::UPGRADE_CLIENT: | 964 case browser_sync::UPGRADE_CLIENT: |
| 965 case browser_sync::CLEAR_USER_DATA_AND_RESYNC: | 965 case browser_sync::CLEAR_USER_DATA_AND_RESYNC: |
| 966 case browser_sync::ENABLE_SYNC_ON_ACCOUNT: | 966 case browser_sync::ENABLE_SYNC_ON_ACCOUNT: |
| 967 case browser_sync::STOP_AND_RESTART_SYNC: | 967 case browser_sync::STOP_AND_RESTART_SYNC: |
| 968 // TODO(lipalani) : if setup in progress we want to display these | 968 // TODO(lipalani) : if setup in progress we want to display these |
| 969 // actions in the popup. The current experience might not be optimal for | 969 // actions in the popup. The current experience might not be optimal for |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 syncable::ModelTypeBitSetFromValue( | 1650 syncable::ModelTypeBitSetFromValue( |
| 1651 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); | 1651 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); |
| 1652 syncable::ModelTypeSet registered; | 1652 syncable::ModelTypeSet registered; |
| 1653 GetRegisteredDataTypes(®istered); | 1653 GetRegisteredDataTypes(®istered); |
| 1654 syncable::ModelTypeBitSet registered_bit_set = | 1654 syncable::ModelTypeBitSet registered_bit_set = |
| 1655 syncable::ModelTypeBitSetFromSet(registered); | 1655 syncable::ModelTypeBitSetFromSet(registered); |
| 1656 unacknowledged = registered_bit_set & ~acknowledged; | 1656 unacknowledged = registered_bit_set & ~acknowledged; |
| 1657 } | 1657 } |
| 1658 return unacknowledged; | 1658 return unacknowledged; |
| 1659 } | 1659 } |
| OLD | NEW |