| 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/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/app_sync_data.h" | 8 #include "chrome/browser/extensions/app_sync_data.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/common/extensions/manifest_url_handler.h" | 10 #include "chrome/common/extensions/manifest_url_handler.h" |
| 11 #include "components/crx_file/id_util.h" |
| 11 #include "extensions/common/extension.h" | 12 #include "extensions/common/extension.h" |
| 12 #include "sync/api/sync_data.h" | 13 #include "sync/api/sync_data.h" |
| 13 #include "sync/protocol/extension_specifics.pb.h" | 14 #include "sync/protocol/extension_specifics.pb.h" |
| 14 #include "sync/protocol/sync.pb.h" | 15 #include "sync/protocol/sync.pb.h" |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 | 18 |
| 18 ExtensionSyncData::ExtensionSyncData() | 19 ExtensionSyncData::ExtensionSyncData() |
| 19 : uninstalled_(false), | 20 : uninstalled_(false), |
| 20 enabled_(false), | 21 enabled_(false), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return syncer::SyncData::CreateLocalData(id_, name_, specifics); | 68 return syncer::SyncData::CreateLocalData(id_, name_, specifics); |
| 68 } | 69 } |
| 69 | 70 |
| 70 syncer::SyncChange ExtensionSyncData::GetSyncChange( | 71 syncer::SyncChange ExtensionSyncData::GetSyncChange( |
| 71 syncer::SyncChange::SyncChangeType change_type) const { | 72 syncer::SyncChange::SyncChangeType change_type) const { |
| 72 return syncer::SyncChange(FROM_HERE, change_type, GetSyncData()); | 73 return syncer::SyncChange(FROM_HERE, change_type, GetSyncData()); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void ExtensionSyncData::PopulateExtensionSpecifics( | 76 void ExtensionSyncData::PopulateExtensionSpecifics( |
| 76 sync_pb::ExtensionSpecifics* specifics) const { | 77 sync_pb::ExtensionSpecifics* specifics) const { |
| 77 DCHECK(Extension::IdIsValid(id_)); | 78 DCHECK(crx_file::id_util::IdIsValid(id_)); |
| 78 specifics->set_id(id_); | 79 specifics->set_id(id_); |
| 79 specifics->set_update_url(update_url_.spec()); | 80 specifics->set_update_url(update_url_.spec()); |
| 80 specifics->set_version(version_.GetString()); | 81 specifics->set_version(version_.GetString()); |
| 81 specifics->set_enabled(enabled_); | 82 specifics->set_enabled(enabled_); |
| 82 specifics->set_incognito_enabled(incognito_enabled_); | 83 specifics->set_incognito_enabled(incognito_enabled_); |
| 83 specifics->set_remote_install(remote_install_); | 84 specifics->set_remote_install(remote_install_); |
| 84 specifics->set_installed_by_custodian(installed_by_custodian_); | 85 specifics->set_installed_by_custodian(installed_by_custodian_); |
| 85 specifics->set_name(name_); | 86 specifics->set_name(name_); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void ExtensionSyncData::PopulateFromExtensionSpecifics( | 89 void ExtensionSyncData::PopulateFromExtensionSpecifics( |
| 89 const sync_pb::ExtensionSpecifics& specifics) { | 90 const sync_pb::ExtensionSpecifics& specifics) { |
| 90 if (!Extension::IdIsValid(specifics.id())) { | 91 if (!crx_file::id_util::IdIsValid(specifics.id())) { |
| 91 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; | 92 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; |
| 92 } | 93 } |
| 93 | 94 |
| 94 Version specifics_version(specifics.version()); | 95 Version specifics_version(specifics.version()); |
| 95 if (!specifics_version.IsValid()) | 96 if (!specifics_version.IsValid()) |
| 96 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; | 97 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; |
| 97 | 98 |
| 98 // The update URL must be either empty or valid. | 99 // The update URL must be either empty or valid. |
| 99 GURL specifics_update_url(specifics.update_url()); | 100 GURL specifics_update_url(specifics.update_url()); |
| 100 if (!specifics_update_url.is_empty() && !specifics_update_url.is_valid()) { | 101 if (!specifics_update_url.is_empty() && !specifics_update_url.is_valid()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 120 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics(); | 121 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics(); |
| 121 | 122 |
| 122 if (entity_specifics.has_extension()) { | 123 if (entity_specifics.has_extension()) { |
| 123 PopulateFromExtensionSpecifics(entity_specifics.extension()); | 124 PopulateFromExtensionSpecifics(entity_specifics.extension()); |
| 124 } else { | 125 } else { |
| 125 LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; | 126 LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; |
| 126 } | 127 } |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // namespace extensions | 130 } // namespace extensions |
| OLD | NEW |