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

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

Issue 10912041: Disallow packing or loading unpacked manifest v1 extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blarh Created 8 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <ostream> 7 #include <ostream>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 namespace switch_utils = extensions::switch_utils; 66 namespace switch_utils = extensions::switch_utils;
67 67
68 using extensions::csp_validator::ContentSecurityPolicyIsLegal; 68 using extensions::csp_validator::ContentSecurityPolicyIsLegal;
69 using extensions::csp_validator::ContentSecurityPolicyIsSandboxed; 69 using extensions::csp_validator::ContentSecurityPolicyIsSandboxed;
70 using extensions::csp_validator::ContentSecurityPolicyIsSecure; 70 using extensions::csp_validator::ContentSecurityPolicyIsSecure;
71 71
72 namespace extensions { 72 namespace extensions {
73 73
74 namespace { 74 namespace {
75 75
76 const int kModernManifestVersion = 1; 76 const int kModernManifestVersion = 2;
77 const int kPEMOutputColumns = 65; 77 const int kPEMOutputColumns = 65;
78 78
79 const char kOverrideExtentUrlPatternFormat[] = "chrome://%s/*"; 79 const char kOverrideExtentUrlPatternFormat[] = "chrome://%s/*";
80 80
81 // The maximum number of commands (including page action/browser actions) an 81 // The maximum number of commands (including page action/browser actions) an
82 // extension can have. 82 // extension can have.
83 const size_t kMaxCommandsPerExtension = 4; 83 const size_t kMaxCommandsPerExtension = 4;
84 84
85 // KEY MARKERS 85 // KEY MARKERS
86 const char kKeyBeginHeaderMarker[] = "-----BEGIN"; 86 const char kKeyBeginHeaderMarker[] = "-----BEGIN";
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 *error = ASCIIToUTF16(errors::kInvalidManifestVersion); 1351 *error = ASCIIToUTF16(errors::kInvalidManifestVersion);
1352 return false; 1352 return false;
1353 } 1353 }
1354 } 1354 }
1355 1355
1356 manifest_version_ = manifest_->GetManifestVersion(); 1356 manifest_version_ = manifest_->GetManifestVersion();
1357 if (creation_flags_ & REQUIRE_MODERN_MANIFEST_VERSION && 1357 if (creation_flags_ & REQUIRE_MODERN_MANIFEST_VERSION &&
1358 manifest_version_ < kModernManifestVersion && 1358 manifest_version_ < kModernManifestVersion &&
1359 !CommandLine::ForCurrentProcess()->HasSwitch( 1359 !CommandLine::ForCurrentProcess()->HasSwitch(
1360 switches::kAllowLegacyExtensionManifests)) { 1360 switches::kAllowLegacyExtensionManifests)) {
1361 *error = ASCIIToUTF16(errors::kInvalidManifestVersion); 1361 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
1362 return false; 1362 errors::kInvalidManifestVersionOld,
1363 } 1363 base::IntToString(kModernManifestVersion));
1364 1364 return false;
1365 if (location() == LOAD && manifest_version_ == 1) {
1366 install_warnings_.push_back(Extension::InstallWarning(
1367 Extension::InstallWarning::FORMAT_HTML,
1368 l10n_util::GetStringFUTF8(
1369 IDS_EXTENSION_MANIFEST_VERSION_OLD,
1370 ASCIIToUTF16("<a href='http://code.google.com/chrome/extensions/"
1371 "manifestVersion.html' target='_blank'>"),
1372 ASCIIToUTF16("</a>"))));
1373 } 1365 }
1374 1366
1375 return true; 1367 return true;
1376 } 1368 }
1377 1369
1378 bool Extension::LoadHomepageURL(string16* error) { 1370 bool Extension::LoadHomepageURL(string16* error) {
1379 if (!manifest_->HasKey(keys::kHomepageURL)) 1371 if (!manifest_->HasKey(keys::kHomepageURL))
1380 return true; 1372 return true;
1381 std::string tmp; 1373 std::string tmp;
1382 if (!manifest_->GetString(keys::kHomepageURL, &tmp)) { 1374 if (!manifest_->GetString(keys::kHomepageURL, &tmp)) {
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after
3949 3941
3950 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3942 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3951 const Extension* extension, 3943 const Extension* extension,
3952 const PermissionSet* permissions, 3944 const PermissionSet* permissions,
3953 Reason reason) 3945 Reason reason)
3954 : reason(reason), 3946 : reason(reason),
3955 extension(extension), 3947 extension(extension),
3956 permissions(permissions) {} 3948 permissions(permissions) {}
3957 3949
3958 } // namespace extensions 3950 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/unpacked_installer.cc ('k') | chrome/common/extensions/extension_manifest_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698