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

Unified Diff: chrome/common/extensions/extension.h

Issue 126014: Verify signed .crx extension installations (Closed)
Patch Set: final changes Created 11 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/common/extensions/extension.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.h
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 9a5bfbf2ca729c998acd840e469e210c5c965b22..658b57f443627035dab51b305f42c1856cd56aca 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_;
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/common/extensions/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698