This source file includes following definitions.
- GetSyncType
- IsSyncable
- IsSyncableExtension
- IsSyncableApp
#include "chrome/common/extensions/sync_helper.h"
#include "base/logging.h"
#include "chrome/common/extensions/api/plugins/plugins_handler.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
namespace extensions {
namespace sync_helper {
namespace {
enum SyncType {
SYNC_TYPE_NONE = 0,
SYNC_TYPE_EXTENSION,
SYNC_TYPE_APP
};
SyncType GetSyncType(const Extension* extension) {
if (!IsSyncable(extension)) {
return SYNC_TYPE_NONE;
}
if (!ManifestURL::GetUpdateURL(extension).is_empty() &&
!ManifestURL::UpdatesFromGallery(extension)) {
return SYNC_TYPE_NONE;
}
if (PluginInfo::HasPlugins(extension) ||
extension->HasAPIPermission(APIPermission::kPlugin)) {
return SYNC_TYPE_NONE;
}
switch (extension->GetType()) {
case Manifest::TYPE_EXTENSION:
return SYNC_TYPE_EXTENSION;
case Manifest::TYPE_USER_SCRIPT:
if (ManifestURL::UpdatesFromGallery(extension))
return SYNC_TYPE_EXTENSION;
return SYNC_TYPE_NONE;
case Manifest::TYPE_HOSTED_APP:
case Manifest::TYPE_LEGACY_PACKAGED_APP:
case Manifest::TYPE_PLATFORM_APP:
return SYNC_TYPE_APP;
case Manifest::TYPE_UNKNOWN:
case Manifest::TYPE_THEME:
case Manifest::TYPE_SHARED_MODULE:
return SYNC_TYPE_NONE;
}
NOTREACHED();
return SYNC_TYPE_NONE;
}
}
bool IsSyncable(const Extension* extension) {
bool is_syncable = (extension->location() == Manifest::INTERNAL &&
!extension->was_installed_by_default() &&
!extension->is_ephemeral());
is_syncable |= (extension->id() == extension_misc::kWebStoreAppId);
is_syncable |= (extension->id() == extension_misc::kChromeAppId);
return is_syncable;
}
bool IsSyncableExtension(const Extension* extension) {
return GetSyncType(extension) == SYNC_TYPE_EXTENSION;
}
bool IsSyncableApp(const Extension* extension) {
return GetSyncType(extension) == SYNC_TYPE_APP;
}
}
}