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/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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/tracked.h" | 10 #include "base/tracked.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 << reader.GetErrorMessage(); | 65 << reader.GetErrorMessage(); |
66 return; | 66 return; |
67 } | 67 } |
68 | 68 |
69 // Merge the server value of this preference with the local value. | 69 // Merge the server value of this preference with the local value. |
70 scoped_ptr<Value> new_value(MergePreference(*pref, *value)); | 70 scoped_ptr<Value> new_value(MergePreference(*pref, *value)); |
71 | 71 |
72 // Update the local preference based on what we got from the | 72 // Update the local preference based on what we got from the |
73 // sync server. Note: this only updates the user value store, which is | 73 // sync server. Note: this only updates the user value store, which is |
74 // ignored if the preference is policy controlled. | 74 // ignored if the preference is policy controlled. |
75 if (new_value->IsType(Value::TYPE_NULL)) { | 75 if (new_value->IsNull()) { |
76 pref_service_->ClearPref(pref_name.c_str()); | 76 pref_service_->ClearPref(pref_name.c_str()); |
77 } else if (!new_value->IsType(pref->GetType())) { | 77 } else if (new_value->GetType() != pref->GetType()) { |
78 LOG(WARNING) << "Synced value for " << preference.name() | 78 LOG(WARNING) << "Synced value for " << preference.name() |
79 << " is of type " << new_value->GetType() | 79 << " is of type " << new_value->GetType() |
80 << " which doesn't match pref type " << pref->GetType(); | 80 << " which doesn't match pref type " << pref->GetType(); |
81 } else if (!pref->GetValue()->Equals(new_value.get())) { | 81 } else if (!pref->GetValue()->Equals(new_value.get())) { |
82 pref_service_->Set(pref_name.c_str(), *new_value); | 82 pref_service_->Set(pref_name.c_str(), *new_value); |
83 } | 83 } |
84 | 84 |
85 SendUpdateNotificationsIfNecessary(pref_name); | 85 SendUpdateNotificationsIfNecessary(pref_name); |
86 | 86 |
87 // If the merge resulted in an updated value, inform the syncer. | 87 // If the merge resulted in an updated value, inform the syncer. |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 return; | 441 return; |
442 } | 442 } |
443 changes.push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data)); | 443 changes.push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data)); |
444 } | 444 } |
445 | 445 |
446 SyncError error = | 446 SyncError error = |
447 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); | 447 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); |
448 if (error.IsSet()) | 448 if (error.IsSet()) |
449 StopSyncing(PREFERENCES); | 449 StopSyncing(PREFERENCES); |
450 } | 450 } |
OLD | NEW |