This source file includes following definitions.
- IsOfflineEnabled
- Parse
- AlwaysParseForType
- Keys
#include "extensions/common/manifest_handlers/offline_enabled_info.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/api_permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
namespace extensions {
namespace keys = manifest_keys;
OfflineEnabledInfo::OfflineEnabledInfo(bool is_offline_enabled)
: offline_enabled(is_offline_enabled) {
}
OfflineEnabledInfo::~OfflineEnabledInfo() {
}
bool OfflineEnabledInfo::IsOfflineEnabled(const Extension* extension) {
OfflineEnabledInfo* info = static_cast<OfflineEnabledInfo*>(
extension->GetManifestData(keys::kOfflineEnabled));
return info ? info->offline_enabled : false;
}
OfflineEnabledHandler::OfflineEnabledHandler() {
}
OfflineEnabledHandler::~OfflineEnabledHandler() {
}
bool OfflineEnabledHandler::Parse(Extension* extension, base::string16* error) {
if (!extension->manifest()->HasKey(keys::kOfflineEnabled)) {
DCHECK(extension->is_platform_app());
const bool has_webview_permission =
!!PermissionsData::GetInitialAPIPermissions(extension)
->count(APIPermission::kWebView);
extension->SetManifestData(keys::kOfflineEnabled,
new OfflineEnabledInfo(!has_webview_permission));
return true;
}
bool offline_enabled = false;
if (!extension->manifest()->GetBoolean(keys::kOfflineEnabled,
&offline_enabled)) {
*error = base::ASCIIToUTF16(manifest_errors::kInvalidOfflineEnabled);
return false;
}
extension->SetManifestData(keys::kOfflineEnabled,
new OfflineEnabledInfo(offline_enabled));
return true;
}
bool OfflineEnabledHandler::AlwaysParseForType(Manifest::Type type) const {
return type == Manifest::TYPE_PLATFORM_APP;
}
const std::vector<std::string> OfflineEnabledHandler::Keys() const {
return SingleKey(keys::kOfflineEnabled);
}
}