| 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/extensions/extension_sync_data.h" | 5 #include "chrome/browser/extensions/extension_sync_data.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/sync/protocol/app_specifics.pb.h" | 9 #include "chrome/browser/sync/protocol/app_specifics.pb.h" |
| 10 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" | 10 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" |
| 11 #include "chrome/browser/sync/protocol/sync.pb.h" |
| 11 | 12 |
| 12 ExtensionSyncData::ExtensionSyncData() | 13 ExtensionSyncData::ExtensionSyncData() |
| 13 : uninstalled_(false), | 14 : uninstalled_(false), |
| 14 enabled_(false), | 15 enabled_(false), |
| 15 incognito_enabled_(false), | 16 incognito_enabled_(false), |
| 16 type_(Extension::SYNC_TYPE_NONE), | 17 type_(Extension::SYNC_TYPE_NONE), |
| 17 notifications_disabled_(false) { | 18 notifications_disabled_(false) { |
| 18 } | 19 } |
| 19 | 20 |
| 20 ExtensionSyncData::ExtensionSyncData(const SyncData& sync_data) | 21 ExtensionSyncData::ExtensionSyncData(const SyncData& sync_data) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 specifics->set_enabled(enabled_); | 86 specifics->set_enabled(enabled_); |
| 86 specifics->set_incognito_enabled(incognito_enabled_); | 87 specifics->set_incognito_enabled(incognito_enabled_); |
| 87 specifics->set_name(name_); | 88 specifics->set_name(name_); |
| 88 } | 89 } |
| 89 | 90 |
| 90 SyncData ExtensionSyncData::GetSyncData() const { | 91 SyncData ExtensionSyncData::GetSyncData() const { |
| 91 sync_pb::EntitySpecifics specifics; | 92 sync_pb::EntitySpecifics specifics; |
| 92 | 93 |
| 93 switch (type_) { | 94 switch (type_) { |
| 94 case Extension::SYNC_TYPE_EXTENSION: | 95 case Extension::SYNC_TYPE_EXTENSION: |
| 95 PopulateExtensionSpecifics(specifics.MutableExtension( | 96 PopulateExtensionSpecifics(specifics.mutable_extension()); |
| 96 sync_pb::extension)); | |
| 97 break; | 97 break; |
| 98 case Extension::SYNC_TYPE_APP: | 98 case Extension::SYNC_TYPE_APP: |
| 99 PopulateAppSpecifics(specifics.MutableExtension(sync_pb::app)); | 99 PopulateAppSpecifics(specifics.mutable_app()); |
| 100 break; | 100 break; |
| 101 default: | 101 default: |
| 102 LOG(FATAL) << "Attempt to get non-syncable data."; | 102 LOG(FATAL) << "Attempt to get non-syncable data."; |
| 103 } | 103 } |
| 104 | 104 |
| 105 return SyncData::CreateLocalData(id_, name_, specifics); | 105 return SyncData::CreateLocalData(id_, name_, specifics); |
| 106 } | 106 } |
| 107 | 107 |
| 108 SyncChange ExtensionSyncData::GetSyncChange( | 108 SyncChange ExtensionSyncData::GetSyncChange( |
| 109 SyncChange::SyncChangeType change_type) const { | 109 SyncChange::SyncChangeType change_type) const { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 update_url_ = specifics_update_url; | 149 update_url_ = specifics_update_url; |
| 150 version_ = specifics_version; | 150 version_ = specifics_version; |
| 151 enabled_ = specifics.enabled(); | 151 enabled_ = specifics.enabled(); |
| 152 incognito_enabled_ = specifics.incognito_enabled(); | 152 incognito_enabled_ = specifics.incognito_enabled(); |
| 153 name_ = specifics.name(); | 153 name_ = specifics.name(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void ExtensionSyncData::PopulateFromSyncData(const SyncData& sync_data) { | 156 void ExtensionSyncData::PopulateFromSyncData(const SyncData& sync_data) { |
| 157 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics(); | 157 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics(); |
| 158 | 158 |
| 159 if (entity_specifics.HasExtension(sync_pb::extension)) { | 159 if (entity_specifics.has_extension()) { |
| 160 PopulateFromExtensionSpecifics( | 160 PopulateFromExtensionSpecifics(entity_specifics.extension()); |
| 161 entity_specifics.GetExtension(sync_pb::extension)); | |
| 162 type_ = Extension::SYNC_TYPE_EXTENSION; | 161 type_ = Extension::SYNC_TYPE_EXTENSION; |
| 163 } else if (entity_specifics.HasExtension(sync_pb::app)) { | 162 } else if (entity_specifics.has_app()) { |
| 164 PopulateFromAppSpecifics( | 163 PopulateFromAppSpecifics(entity_specifics.app()); |
| 165 entity_specifics.GetExtension(sync_pb::app)); | |
| 166 type_ = Extension::SYNC_TYPE_APP; | 164 type_ = Extension::SYNC_TYPE_APP; |
| 167 } else { | 165 } else { |
| 168 LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; | 166 LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; |
| 169 } | 167 } |
| 170 } | 168 } |
| OLD | NEW |