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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 527003: Revert 35602 - Add a "minimum_chrome_version" key to the manifest.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
9 #include "base/base64.h" 8 #include "base/base64.h"
10 #include "base/basictypes.h" 9 #include "base/basictypes.h"
11 #include "base/command_line.h" 10 #include "base/command_line.h"
12 #include "base/file_path.h" 11 #include "base/file_path.h"
13 #include "base/file_util.h" 12 #include "base/file_util.h"
14 #include "base/file_version_info.h"
15 #include "base/logging.h" 13 #include "base/logging.h"
16 #include "base/string_util.h" 14 #include "base/string_util.h"
17 #include "base/stl_util-inl.h" 15 #include "base/stl_util-inl.h"
18 #include "base/third_party/nss/blapi.h" 16 #include "base/third_party/nss/blapi.h"
19 #include "base/third_party/nss/sha256.h" 17 #include "base/third_party/nss/sha256.h"
20 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/extensions/extension_constants.h" 20 #include "chrome/common/extensions/extension_constants.h"
23 #include "chrome/common/extensions/extension_error_reporter.h" 21 #include "chrome/common/extensions/extension_error_reporter.h"
24 #include "chrome/common/extensions/extension_error_utils.h" 22 #include "chrome/common/extensions/extension_error_utils.h"
25 #include "chrome/common/extensions/extension_l10n_util.h" 23 #include "chrome/common/extensions/extension_l10n_util.h"
26 #include "chrome/common/extensions/user_script.h" 24 #include "chrome/common/extensions/user_script.h"
27 #include "chrome/common/notification_service.h" 25 #include "chrome/common/notification_service.h"
28 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
29 #include "grit/chromium_strings.h"
30 #include "webkit/glue/image_decoder.h" 27 #include "webkit/glue/image_decoder.h"
31 28
32 #if defined(OS_WIN) 29 #if defined(OS_WIN)
33 #include "base/registry.h" 30 #include "base/registry.h"
34 #endif 31 #endif
35 32
36 namespace keys = extension_manifest_keys; 33 namespace keys = extension_manifest_keys;
37 namespace values = extension_manifest_values; 34 namespace values = extension_manifest_values;
38 namespace errors = extension_manifest_errors; 35 namespace errors = extension_manifest_errors;
39 36
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 return false; 750 return false;
754 } 751 }
755 update_url_ = GURL(tmp); 752 update_url_ = GURL(tmp);
756 if (!update_url_.is_valid() || update_url_.has_ref()) { 753 if (!update_url_.is_valid() || update_url_.has_ref()) {
757 *error = ExtensionErrorUtils::FormatErrorMessage( 754 *error = ExtensionErrorUtils::FormatErrorMessage(
758 errors::kInvalidUpdateURL, tmp); 755 errors::kInvalidUpdateURL, tmp);
759 return false; 756 return false;
760 } 757 }
761 } 758 }
762 759
763 // Validate minimum Chrome version (if present). We don't need to store this,
764 // since the extension is not valid if it is incorrect.
765 if (source.HasKey(keys::kMinimumChromeVersion)) {
766 std::string minimum_version_string;
767 if (!source.GetString(keys::kMinimumChromeVersion,
768 &minimum_version_string)) {
769 *error = errors::kInvalidMinimumChromeVersion;
770 return false;
771 }
772
773 scoped_ptr<Version> minimum_version(
774 Version::GetVersionFromString(minimum_version_string));
775 if (!minimum_version.get()) {
776 *error = errors::kInvalidMinimumChromeVersion;
777 return false;
778 }
779
780 scoped_ptr<FileVersionInfo> current_version_info(
781 FileVersionInfo::CreateFileVersionInfoForCurrentModule());
782 if (!current_version_info.get()) {
783 DCHECK(false);
784 return false;
785 }
786
787 scoped_ptr<Version> current_version(
788 Version::GetVersionFromString(current_version_info->file_version()));
789 if (!current_version.get()) {
790 DCHECK(false);
791 return false;
792 }
793
794 if (current_version->CompareTo(*minimum_version) < 0) {
795 *error = ExtensionErrorUtils::FormatErrorMessage(
796 errors::kChromeVersionTooLow,
797 l10n_util::GetStringUTF8(IDS_PRODUCT_NAME),
798 minimum_version_string);
799 return false;
800 }
801 }
802
803 // Initialize converted_from_user_script (if present) 760 // Initialize converted_from_user_script (if present)
804 source.GetBoolean(keys::kConvertedFromUserScript, 761 source.GetBoolean(keys::kConvertedFromUserScript,
805 &converted_from_user_script_); 762 &converted_from_user_script_);
806 763
807 // Initialize icons (if present). 764 // Initialize icons (if present).
808 if (source.HasKey(keys::kIcons)) { 765 if (source.HasKey(keys::kIcons)) {
809 DictionaryValue* icons_value = NULL; 766 DictionaryValue* icons_value = NULL;
810 if (!source.GetDictionary(keys::kIcons, &icons_value)) { 767 if (!source.GetDictionary(keys::kIcons, &icons_value)) {
811 *error = errors::kInvalidIcons; 768 *error = errors::kInvalidIcons;
812 return false; 769 return false;
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 UserScript::PatternList::const_iterator pattern = 1283 UserScript::PatternList::const_iterator pattern =
1327 content_script->url_patterns().begin(); 1284 content_script->url_patterns().begin();
1328 for (; pattern != content_script->url_patterns().end(); ++pattern) { 1285 for (; pattern != content_script->url_patterns().end(); ++pattern) {
1329 if (pattern->match_subdomains() && pattern->host().empty()) 1286 if (pattern->match_subdomains() && pattern->host().empty())
1330 return true; 1287 return true;
1331 } 1288 }
1332 } 1289 }
1333 1290
1334 return false; 1291 return false;
1335 } 1292 }
OLDNEW
« 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