diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 07:52:33 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 07:52:33 +0000 |
commit | 7713d63d41fad819b4031c2f30422489469ead95 (patch) | |
tree | 21bc0fe37980b49e1a2b03ca6726b695bd587f91 /chrome/browser/extensions/extension.h | |
parent | 527c739c43984bc49da5d0de4989e1d81d4a74d5 (diff) | |
download | chromium_src-7713d63d41fad819b4031c2f30422489469ead95.zip chromium_src-7713d63d41fad819b4031c2f30422489469ead95.tar.gz chromium_src-7713d63d41fad819b4031c2f30422489469ead95.tar.bz2 |
Introduce Extension class that can serializer and deserialize from Value
instances.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6211 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension.h')
-rw-r--r-- | chrome/browser/extensions/extension.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension.h b/chrome/browser/extensions/extension.h new file mode 100644 index 0000000..16260e0 --- /dev/null +++ b/chrome/browser/extensions/extension.h @@ -0,0 +1,71 @@ +// Copyright (c) 2006-2008 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. + +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_H__ +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_H__ + +#include <string> +#include <vector> + +#include "base/string16.h" +#include "base/values.h" + +// Represents a Chromium extension. +class Extension { + public: + Extension(){}; + + // The format for extension manifests that this code understands. + static const int kExpectedFormatVersion = 1; + + // Keys used in JSON representation of extensions. + static const std::wstring kFormatVersionKey; + static const std::wstring kIdKey; + static const std::wstring kNameKey; + static const std::wstring kDescriptionKey; + static const std::wstring kContentScriptsKey; + + // Error messages returned from InitFromValue(). + static const std::wstring kInvalidFormatVersionError; + static const std::wstring kInvalidIdError; + static const std::wstring kInvalidNameError; + static const std::wstring kInvalidDescriptionError; + static const std::wstring kInvalidContentScriptsListError; + static const std::wstring kInvalidContentScriptError; + + // A human-readable ID for the extension. The convention is to use something + // like 'com.example.myextension', but this is not currently enforced. An + // extension's ID is used in things like directory structures and URLs, and + // is expected to not change across versions. In the case of conflicts, + // updates will only be allowed if the extension can be validated using the + // previous version's update key. + const std::wstring& id() const { return id_; } + + // A human-readable name of the extension. + const std::wstring& name() const { return name_; } + + // An optional longer description of the extension. + const std::wstring& description() const { return description_; } + + // Paths to the content scripts that the extension contains. + const std::vector<std::wstring>& content_scripts() const { + return content_scripts_; + } + + // Initialize the extension from a parsed manifest. + bool InitFromValue(const DictionaryValue& value, std::wstring* error); + + // Serialize the extension to a DictionaryValue. + void CopyToValue(DictionaryValue* value); + + private: + std::wstring id_; + std::wstring name_; + std::wstring description_; + std::vector<std::wstring> content_scripts_; + + DISALLOW_COPY_AND_ASSIGN(Extension); +}; + +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_H__ |