| 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 "chrome/browser/prefs/pref_model_associator.h" | 5 #include "chrome/browser/prefs/pref_model_associator.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Push updates to sync. | 159 // Push updates to sync. |
| 160 syncer::SyncError error = | 160 syncer::SyncError error = |
| 161 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); | 161 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); |
| 162 if (error.IsSet()) { | 162 if (error.IsSet()) { |
| 163 return error; | 163 return error; |
| 164 } | 164 } |
| 165 | 165 |
| 166 models_associated_ = true; | 166 models_associated_ = true; |
| 167 pref_service_->HasSyncedChanged(); |
| 167 return syncer::SyncError(); | 168 return syncer::SyncError(); |
| 168 } | 169 } |
| 169 | 170 |
| 170 void PrefModelAssociator::StopSyncing(syncer::ModelType type) { | 171 void PrefModelAssociator::StopSyncing(syncer::ModelType type) { |
| 171 DCHECK_EQ(type, PREFERENCES); | 172 DCHECK_EQ(type, PREFERENCES); |
| 172 models_associated_ = false; | 173 models_associated_ = false; |
| 173 sync_processor_.reset(); | 174 sync_processor_.reset(); |
| 174 sync_error_factory_.reset(); | 175 sync_error_factory_.reset(); |
| 176 pref_service_->HasSyncedChanged(); |
| 175 } | 177 } |
| 176 | 178 |
| 177 Value* PrefModelAssociator::MergePreference( | 179 Value* PrefModelAssociator::MergePreference( |
| 178 const PrefService::Preference& local_pref, | 180 const PrefService::Preference& local_pref, |
| 179 const Value& server_value) { | 181 const Value& server_value) { |
| 180 const std::string& name(local_pref.name()); | 182 const std::string& name(local_pref.name()); |
| 181 if (name == prefs::kURLsToRestoreOnStartup || | 183 if (name == prefs::kURLsToRestoreOnStartup || |
| 182 name == prefs::kDesktopNotificationAllowedOrigins || | 184 name == prefs::kDesktopNotificationAllowedOrigins || |
| 183 name == prefs::kDesktopNotificationDeniedOrigins) { | 185 name == prefs::kDesktopNotificationDeniedOrigins) { |
| 184 return MergeListValues(*local_pref.GetValue(), server_value); | 186 return MergeListValues(*local_pref.GetValue(), server_value); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 440 } |
| 439 | 441 |
| 440 syncer::SyncError error = | 442 syncer::SyncError error = |
| 441 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); | 443 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); |
| 442 } | 444 } |
| 443 | 445 |
| 444 void PrefModelAssociator::SetPrefService(PrefService* pref_service) { | 446 void PrefModelAssociator::SetPrefService(PrefService* pref_service) { |
| 445 DCHECK(pref_service_ == NULL); | 447 DCHECK(pref_service_ == NULL); |
| 446 pref_service_ = pref_service; | 448 pref_service_ = pref_service; |
| 447 } | 449 } |
| OLD | NEW |