blob: 691a0b7329d0b220a80153d5dfc5789736fef7d6 [file] [log] [blame]
[email protected]7713d632008-12-02 07:52:331// Copyright (c) 2006-2008 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.
4
[email protected]6014d672008-12-05 00:38:255#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_H_
6#define CHROME_BROWSER_EXTENSIONS_EXTENSION_H_
[email protected]7713d632008-12-02 07:52:337
8#include <string>
9#include <vector>
10
[email protected]6014d672008-12-05 00:38:2511#include "base/file_path.h"
[email protected]7713d632008-12-02 07:52:3312#include "base/string16.h"
13#include "base/values.h"
14
15// Represents a Chromium extension.
16class Extension {
17 public:
18 Extension(){};
19
20 // The format for extension manifests that this code understands.
21 static const int kExpectedFormatVersion = 1;
22
[email protected]6014d672008-12-05 00:38:2523 // The name of the manifest inside an extension.
24 static const FilePath::CharType* kManifestFilename;
25
[email protected]7713d632008-12-02 07:52:3326 // Keys used in JSON representation of extensions.
[email protected]6014d672008-12-05 00:38:2527 static const wchar_t* kFormatVersionKey;
28 static const wchar_t* kIdKey;
29 static const wchar_t* kNameKey;
30 static const wchar_t* kDescriptionKey;
31 static const wchar_t* kContentScriptsKey;
[email protected]7713d632008-12-02 07:52:3332
33 // Error messages returned from InitFromValue().
[email protected]3acbd422008-12-08 18:25:0034 static const char* kInvalidFormatVersionError;
35 static const char* kInvalidManifestError;
36 static const char* kInvalidIdError;
37 static const char* kInvalidNameError;
38 static const char* kInvalidDescriptionError;
39 static const char* kInvalidContentScriptsListError;
40 static const char* kInvalidContentScriptError;
[email protected]7713d632008-12-02 07:52:3341
42 // A human-readable ID for the extension. The convention is to use something
43 // like 'com.example.myextension', but this is not currently enforced. An
44 // extension's ID is used in things like directory structures and URLs, and
45 // is expected to not change across versions. In the case of conflicts,
46 // updates will only be allowed if the extension can be validated using the
47 // previous version's update key.
[email protected]e1cec06c2008-12-18 01:22:2348 const std::string& id() const { return id_; }
[email protected]7713d632008-12-02 07:52:3349
50 // A human-readable name of the extension.
[email protected]e1cec06c2008-12-18 01:22:2351 const std::string& name() const { return name_; }
[email protected]7713d632008-12-02 07:52:3352
53 // An optional longer description of the extension.
[email protected]e1cec06c2008-12-18 01:22:2354 const std::string& description() const { return description_; }
[email protected]7713d632008-12-02 07:52:3355
56 // Paths to the content scripts that the extension contains.
[email protected]e1cec06c2008-12-18 01:22:2357 const std::vector<std::string>& content_scripts() const {
[email protected]7713d632008-12-02 07:52:3358 return content_scripts_;
59 }
60
61 // Initialize the extension from a parsed manifest.
[email protected]3acbd422008-12-08 18:25:0062 bool InitFromValue(const DictionaryValue& value, std::string* error);
[email protected]7713d632008-12-02 07:52:3363
64 // Serialize the extension to a DictionaryValue.
65 void CopyToValue(DictionaryValue* value);
66
67 private:
[email protected]e1cec06c2008-12-18 01:22:2368 std::string id_;
69 std::string name_;
70 std::string description_;
71 std::vector<std::string> content_scripts_;
[email protected]7713d632008-12-02 07:52:3372
73 DISALLOW_COPY_AND_ASSIGN(Extension);
74};
75
[email protected]6014d672008-12-05 00:38:2576#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_H_