Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chrome/browser/extensions/extension.h

Issue 15010: Implement extension:// protocol. (Closed)
Patch Set: add missing unit test Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 14
15 // Represents a Chromium extension. 15 // Represents a Chromium extension.
16 class Extension { 16 class Extension {
17 public: 17 public:
18 Extension(){}; 18 Extension(){};
19 Extension(const FilePath& path) : path_(path) {};
19 20
20 // The format for extension manifests that this code understands. 21 // The format for extension manifests that this code understands.
21 static const int kExpectedFormatVersion = 1; 22 static const int kExpectedFormatVersion = 1;
22 23
23 // The name of the manifest inside an extension. 24 // The name of the manifest inside an extension.
24 static const FilePath::CharType* kManifestFilename; 25 static const FilePath::CharType* kManifestFilename;
25 26
26 // Keys used in JSON representation of extensions. 27 // Keys used in JSON representation of extensions.
27 static const wchar_t* kFormatVersionKey; 28 static const wchar_t* kFormatVersionKey;
28 static const wchar_t* kIdKey; 29 static const wchar_t* kIdKey;
29 static const wchar_t* kNameKey; 30 static const wchar_t* kNameKey;
30 static const wchar_t* kDescriptionKey; 31 static const wchar_t* kDescriptionKey;
31 static const wchar_t* kContentScriptsKey; 32 static const wchar_t* kContentScriptsKey;
32 33
33 // Error messages returned from InitFromValue(). 34 // Error messages returned from InitFromValue().
34 static const char* kInvalidFormatVersionError; 35 static const char* kInvalidFormatVersionError;
35 static const char* kInvalidManifestError; 36 static const char* kInvalidManifestError;
36 static const char* kInvalidIdError; 37 static const char* kInvalidIdError;
37 static const char* kInvalidNameError; 38 static const char* kInvalidNameError;
38 static const char* kInvalidDescriptionError; 39 static const char* kInvalidDescriptionError;
39 static const char* kInvalidContentScriptsListError; 40 static const char* kInvalidContentScriptsListError;
40 static const char* kInvalidContentScriptError; 41 static const char* kInvalidContentScriptError;
41 42
43 // The path to the folder the extension is stored in.
44 const FilePath& path() const { return path_; }
45
42 // A human-readable ID for the extension. The convention is to use something 46 // 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 47 // 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 48 // 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, 49 // 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 50 // updates will only be allowed if the extension can be validated using the
47 // previous version's update key. 51 // previous version's update key.
48 const std::string& id() const { return id_; } 52 const std::string& id() const { return id_; }
49 53
50 // A human-readable name of the extension. 54 // A human-readable name of the extension.
51 const std::string& name() const { return name_; } 55 const std::string& name() const { return name_; }
52 56
53 // An optional longer description of the extension. 57 // An optional longer description of the extension.
54 const std::string& description() const { return description_; } 58 const std::string& description() const { return description_; }
55 59
56 // Paths to the content scripts that the extension contains. 60 // Paths to the content scripts that the extension contains.
57 const std::vector<std::string>& content_scripts() const { 61 const std::vector<std::string>& content_scripts() const {
58 return content_scripts_; 62 return content_scripts_;
59 } 63 }
60 64
61 // Initialize the extension from a parsed manifest. 65 // Initialize the extension from a parsed manifest.
62 bool InitFromValue(const DictionaryValue& value, std::string* error); 66 bool InitFromValue(const DictionaryValue& value, std::string* error);
63 67
64 // Serialize the extension to a DictionaryValue. 68 // Serialize the extension to a DictionaryValue.
65 void CopyToValue(DictionaryValue* value); 69 void CopyToValue(DictionaryValue* value);
66 70
67 private: 71 private:
72 // The path to the directory the extension is stored in.
73 FilePath path_;
74
75 // The extension's ID.
68 std::string id_; 76 std::string id_;
77
78 // The extension's human-readable name.
69 std::string name_; 79 std::string name_;
80
81 // An optional description for the extension.
70 std::string description_; 82 std::string description_;
83
84 // Paths to the content scripts the extension contains.
71 std::vector<std::string> content_scripts_; 85 std::vector<std::string> content_scripts_;
72 86
73 DISALLOW_COPY_AND_ASSIGN(Extension); 87 DISALLOW_COPY_AND_ASSIGN(Extension);
74 }; 88 };
75 89
76 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_H_ 90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_H_
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/chrome_url_data_manager.cc ('k') | chrome/browser/extensions/extension_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698