#include "chrome/common/extensions/sync_helper.h"
#include "base/logging.h"
#include "components/app_constants/constants.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_url_handlers.h"
namespace extensions {
namespace sync_helper {
bool IsSyncable(const Extension* extension) {
bool is_syncable =
(extension->location() == mojom::ManifestLocation::kInternal &&
!extension->was_installed_by_default());
if (!is_syncable && !IsSyncableComponentExtension(extension)) {
return false;
}
if (!ManifestURL::GetUpdateURL(extension).is_empty() &&
!ManifestURL::UpdatesFromGallery(extension)) {
return false;
}
switch (extension->GetType()) {
case Manifest::TYPE_EXTENSION:
case Manifest::TYPE_HOSTED_APP:
case Manifest::TYPE_LEGACY_PACKAGED_APP:
case Manifest::TYPE_PLATFORM_APP:
case Manifest::TYPE_THEME:
return true;
case Manifest::TYPE_USER_SCRIPT:
if (ManifestURL::UpdatesFromGallery(extension))
return true;
return false;
case Manifest::TYPE_UNKNOWN:
case Manifest::TYPE_SHARED_MODULE:
case Manifest::TYPE_LOGIN_SCREEN_EXTENSION:
case Manifest::TYPE_CHROMEOS_SYSTEM_EXTENSION:
return false;
case Manifest::NUM_LOAD_TYPES:
NOTREACHED();
}
NOTREACHED();
}
bool IsSyncableComponentExtension(const Extension* extension) {
if (!Manifest::IsComponentLocation(extension->location()))
return false;
return (extension->id() == extensions::kWebStoreAppId) ||
(extension->id() == app_constants::kChromeAppId);
}
}
}