Ignore non-active fullscreen windows for shelf state.
[chromium-blink-merge.git] / extensions / common / manifest_handlers / offline_enabled_info.cc
blob7cf1835d40195683acb5f2f89893b8332fbe5214
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/common/manifest_handlers/offline_enabled_info.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string16.h"
9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "base/values.h"
12 #include "extensions/common/manifest_constants.h"
14 namespace extensions {
16 namespace keys = manifest_keys;
18 OfflineEnabledInfo::OfflineEnabledInfo(bool is_offline_enabled)
19 : offline_enabled(is_offline_enabled) {
22 OfflineEnabledInfo::~OfflineEnabledInfo() {
25 // static
26 bool OfflineEnabledInfo::IsOfflineEnabled(const Extension* extension) {
27 OfflineEnabledInfo* info = static_cast<OfflineEnabledInfo*>(
28 extension->GetManifestData(keys::kOfflineEnabled));
29 return info ? info->offline_enabled : false;
32 OfflineEnabledHandler::OfflineEnabledHandler() {
35 OfflineEnabledHandler::~OfflineEnabledHandler() {
38 bool OfflineEnabledHandler::Parse(Extension* extension, string16* error) {
39 if (!extension->manifest()->HasKey(keys::kOfflineEnabled)) {
40 // Only platform apps default to being enabled offline, and we should only
41 // attempt parsing without a key present if it is a platform app.
42 DCHECK(extension->is_platform_app());
43 extension->SetManifestData(keys::kOfflineEnabled,
44 new OfflineEnabledInfo(true));
45 return true;
48 bool offline_enabled = false;
50 if (!extension->manifest()->GetBoolean(keys::kOfflineEnabled,
51 &offline_enabled)) {
52 *error = ASCIIToUTF16(manifest_errors::kInvalidOfflineEnabled);
53 return false;
56 extension->SetManifestData(keys::kOfflineEnabled,
57 new OfflineEnabledInfo(offline_enabled));
58 return true;
61 bool OfflineEnabledHandler::AlwaysParseForType(Manifest::Type type) const {
62 return type == Manifest::TYPE_PLATFORM_APP;
65 const std::vector<std::string> OfflineEnabledHandler::Keys() const {
66 return SingleKey(keys::kOfflineEnabled);
69 } // namespace extensions