summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/manifest.h
diff options
context:
space:
mode:
authorkalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 04:20:27 +0000
committerkalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 04:20:27 +0000
commitd41e215af7fc197cc18699c06106380766d939be (patch)
tree295470ef247c4cdd0ce46556f0f9add5c904a40c /chrome/common/extensions/manifest.h
parentb77226e27cab2828e1638a978864442dd336a73e (diff)
downloadchromium_src-d41e215af7fc197cc18699c06106380766d939be.zip
chromium_src-d41e215af7fc197cc18699c06106380766d939be.tar.gz
chromium_src-d41e215af7fc197cc18699c06106380766d939be.tar.bz2
Introduce ManifestFeatureProvider.
Re-impement manifest feature requirements using a more general framework that we will also use for permissions and APIs in the future. Original patch from aa@chromium.org, review URL http://codereview.chromium.org/9415004/ TBR=aa@chromium.org,jstritar@chromium.org BUG= TEST= Review URL: http://codereview.chromium.org/9425056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/manifest.h')
-rw-r--r--chrome/common/extensions/manifest.h72
1 files changed, 32 insertions, 40 deletions
diff --git a/chrome/common/extensions/manifest.h b/chrome/common/extensions/manifest.h
index 45c5d97..9645589 100644
--- a/chrome/common/extensions/manifest.h
+++ b/chrome/common/extensions/manifest.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,58 +12,37 @@
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
-
-namespace base {
-class DictionaryValue;
-class ListValue;
-class Value;
-}
+#include "base/values.h"
+#include "chrome/common/extensions/extension.h"
namespace extensions {
-// Lightweight wrapper around a DictionaryValue representing an extension's
-// manifest. Currently enforces access to properties of the manifest based
-// on manifest type.
-//
-// TODO(aa): Move more smarts about mmanifest into this class over time.
+// Wraps the DictionaryValue form of extension's manifest. Enforces access to
+// properties of the manifest using ManifestFeatureProvider.
class Manifest {
public:
- // Flags for matching types of extension manifests.
- enum Type {
- kTypeNone = 0,
-
- // Extension::TYPE_EXTENSION and Extension::TYPE_USER_SCRIPT
- kTypeExtension = 1 << 0,
-
- // Extension::TYPE_THEME
- kTypeTheme = 1 << 1,
-
- // Extension::TYPE_HOSTED_APP
- kTypeHostedApp = 1 << 2,
-
- // Extension::TYPE_PACKAGED_APP
- kTypePackagedApp = 1 << 3,
-
- // Extension::TYPE_PLATFORM_APP
- kTypePlatformApp = 1 << 4,
-
- // All types
- kTypeAll = (1 << 5) - 1,
- };
+ explicit Manifest(Extension::Location location,
+ scoped_ptr<DictionaryValue> value);
+ virtual ~Manifest();
- // Returns all known keys (this is used for testing).
- static std::set<std::string> GetAllKnownKeys();
+ const std::string& extension_id() const { return extension_id_; }
+ void set_extension_id(const std::string& id) { extension_id_ = id; }
- // Takes over ownership of |value|.
- explicit Manifest(base::DictionaryValue* value);
- virtual ~Manifest();
+ Extension::Location location() const { return location_; }
+ void set_location(Extension::Location location) { location_ = location; }
// Returns true if all keys in the manifest can be specified by
// the extension type.
bool ValidateManifest(string16* error) const;
+ // The version of this extension's manifest. We increase the manifest
+ // version when making breaking changes to the extension system. If the
+ // manifest contains no explicit manifest version, this returns the current
+ // system default.
+ int GetManifestVersion() const;
+
// Returns the manifest type.
- Type GetType() const;
+ Extension::Type GetType() const;
// Returns true if the manifest represents an Extension::TYPE_THEME.
bool IsTheme() const;
@@ -103,8 +82,21 @@ class Manifest {
private:
// Returns true if the extension can specify the given |path|.
bool CanAccessPath(const std::string& path) const;
+ bool CanAccessKey(const std::string& key, bool* was_known) const;
+ // A persistent, globally unique ID. An extension's ID is used in things
+ // like directory structures and URLs, and is expected to not change across
+ // versions. It is generated as a SHA-256 hash of the extension's public
+ // key, or as a hash of the path in the case of unpacked extensions.
+ std::string extension_id_;
+
+ // The location the extension was loaded from.
+ Extension::Location location_;
+
+ // The underlying dictionary representation of the manifest.
scoped_ptr<base::DictionaryValue> value_;
+
+ DISALLOW_COPY_AND_ASSIGN(Manifest);
};
} // namespace extensions