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

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

Issue 521036: Add a "minimum_chrome_version" key to the manifest. (Closed)
Patch Set: Removed extraneous change, added new test, added docs Created 10 years, 11 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/common/extensions/docs/static/manifest.html ('k') | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 909708676e93d2433ede8f456d69f52ce2a1ee3c..5dfdf1c1c4328a097ecb843642d485de54fc869c 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -4,12 +4,14 @@
#include "chrome/common/extensions/extension.h"
+#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/base64.h"
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/file_version_info.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/stl_util-inl.h"
@@ -24,6 +26,7 @@
#include "chrome/common/extensions/user_script.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/url_constants.h"
+#include "grit/chromium_strings.h"
#include "webkit/glue/image_decoder.h"
#if defined(OS_WIN)
@@ -757,6 +760,46 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
}
}
+ // Validate minimum Chrome version (if present). We don't need to store this,
+ // since the extension is not valid if it is incorrect.
+ if (source.HasKey(keys::kMinimumChromeVersion)) {
+ std::string minimum_version_string;
+ if (!source.GetString(keys::kMinimumChromeVersion,
+ &minimum_version_string)) {
+ *error = errors::kInvalidMinimumChromeVersion;
+ return false;
+ }
+
+ scoped_ptr<Version> minimum_version(
+ Version::GetVersionFromString(minimum_version_string));
+ if (!minimum_version.get()) {
+ *error = errors::kInvalidMinimumChromeVersion;
+ return false;
+ }
+
+ scoped_ptr<FileVersionInfo> current_version_info(
+ FileVersionInfo::CreateFileVersionInfoForCurrentModule());
+ if (!current_version_info.get()) {
+ DCHECK(false);
+ return false;
+ }
+
+ scoped_ptr<Version> current_version(
+ Version::GetVersionFromString(current_version_info->file_version()));
+ if (!current_version.get()) {
+ DCHECK(false);
+ return false;
+ }
+
+ if (current_version->CompareTo(*minimum_version) < 0) {
+ *error = ExtensionErrorUtils::FormatErrorMessage(
+ errors::kChromeVersionTooLow,
+ l10n_util::GetStringUTF8(IDS_PRODUCT_NAME),
+ minimum_version_string);
+ return false;
+ }
+ }
+
// Initialize converted_from_user_script (if present)
source.GetBoolean(keys::kConvertedFromUserScript,
&converted_from_user_script_);
« no previous file with comments | « chrome/common/extensions/docs/static/manifest.html ('k') | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698