diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-12 20:45:45 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-12 20:45:45 +0000 |
commit | fbcc4030655802213aab5b731f1180062d232f2d (patch) | |
tree | 41da9d881467d61d9ecde52306f5aacebdcf9d33 /chrome/common/extensions/extension.h | |
parent | cdb4266b62202b44eb1fb36877398c2cb5504917 (diff) | |
download | chromium_src-fbcc4030655802213aab5b731f1180062d232f2d.zip chromium_src-fbcc4030655802213aab5b731f1180062d232f2d.tar.gz chromium_src-fbcc4030655802213aab5b731f1180062d232f2d.tar.bz2 |
Verify signed .crx extension installations
This is second try of:
http://codereview.chromium.org/115682
that was comitted in in 18189 and reverted.
BUG=12114
R=erikkay,wtc,aa
Review URL: http://codereview.chromium.org/126014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18316 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension.h')
-rw-r--r-- | chrome/common/extensions/extension.h | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 9a5bfbf..658b57f 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -38,6 +38,13 @@ class Extension { KILLBIT, // Don't install/upgrade (applies to external extensions only). }; + enum InstallType { + DOWNGRADE, + REINSTALL, + UPGRADE, + NEW_INSTALL + }; + // An NPAPI plugin included in the extension. struct PluginInfo { FilePath path; // Path to the plugin. @@ -53,10 +60,10 @@ class Extension { static const wchar_t* kCssKey; static const wchar_t* kDescriptionKey; static const wchar_t* kIconPathKey; - static const wchar_t* kIdKey; static const wchar_t* kJsKey; static const wchar_t* kMatchesKey; static const wchar_t* kNameKey; + static const wchar_t* kPageActionIdKey; static const wchar_t* kPageActionsKey; static const wchar_t* kPermissionsKey; static const wchar_t* kPluginsKey; @@ -87,9 +94,9 @@ class Extension { static const char* kInvalidCssError; static const char* kInvalidCssListError; static const char* kInvalidDescriptionError; - static const char* kInvalidIdError; static const char* kInvalidJsError; static const char* kInvalidJsListError; + static const char* kInvalidKeyError; static const char* kInvalidManifestError; static const char* kInvalidMatchCountError; static const char* kInvalidMatchError; @@ -101,12 +108,14 @@ class Extension { static const char* kInvalidBackgroundError; static const char* kInvalidRunAtError; + static const char* kInvalidSignatureError; static const char* kInvalidToolstripError; static const char* kInvalidToolstripsError; static const char* kInvalidVersionError; static const char* kInvalidPageActionError; static const char* kInvalidPageActionsListError; static const char* kInvalidPageActionIconPathError; + static const char* kInvalidPageActionIdError; static const char* kInvalidPageActionTooltipError; static const char* kInvalidPageActionTypeValueError; static const char* kInvalidPermissionsError; @@ -133,6 +142,11 @@ class Extension { explicit Extension(const FilePath& path); virtual ~Extension(); + // Resets the id counter. This is only useful for unit tests. + static void ResetGeneratedIdCounter() { + id_counter_ = 0; + } + // Checks to see if the extension has a valid ID. static bool IdIsValid(const std::string& id); @@ -173,6 +187,11 @@ class Extension { // Does a simple base64 encoding of |input| into |output|. static bool ProducePEM(const std::string& input, std::string* output); + // Note: The result is coverted to lower-case because the browser enforces + // hosts to be lower-case in omni-bar. + static bool GenerateIdFromPublicKey(const std::string& input, + std::string* output); + // Expects base64 encoded |input| and formats into |output| including // the appropriate header & footer. static bool FormatPEMForFileOutput(const std::string input, @@ -193,6 +212,7 @@ class Extension { // String representation of the version number. const std::string VersionString() const; const std::string& name() const { return name_; } + const std::string& public_key() const { return public_key_; } const std::string& description() const { return description_; } const UserScriptList& content_scripts() const { return content_scripts_; } const PageActionMap& page_actions() const { return page_actions_; } @@ -222,6 +242,14 @@ class Extension { std::set<FilePath> GetBrowserImages(); private: + // Counter used to assign ids to extensions that are loaded using + // --load-extension. + static int id_counter_; + + // Returns the next counter id. Intentionally post-incrementing so that first + // value is 0. + static int NextGeneratedId() { return id_counter_++; } + // Helper method that loads a UserScript object from a // dictionary in the content_script list of the manifest. bool LoadUserScriptHelper(const DictionaryValue* content_script, @@ -281,10 +309,9 @@ class Extension { // Paths to HTML files to be displayed in the toolbar. std::vector<std::string> toolstrips_; - // A SHA1 hash of the contents of the zip file. Note that this key is only - // present in the manifest that's prepended to the zip. The inner manifest - // will not have this key. - std::string zip_hash_; + // The public key ('key' in the manifest) used to sign the contents of the + // crx package ('signature' in the manifest) + std::string public_key_; // A map of resource id's to relative file paths. scoped_ptr<DictionaryValue> theme_images_; |