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

Unified Diff: chrome/browser/extensions/unpacked_installer.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/unpacked_installer.h ('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/browser/extensions/unpacked_installer.cc
diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc
index f314c4b4ebf9daa12ee79ae6e5cdab2e131b42fe..00b7c4699a8082fde1e10b8265832a2f5008c745 100644
--- a/chrome/browser/extensions/unpacked_installer.cc
+++ b/chrome/browser/extensions/unpacked_installer.cc
@@ -89,7 +89,8 @@ scoped_refptr<UnpackedInstaller> UnpackedInstaller::Create(
UnpackedInstaller::UnpackedInstaller(ExtensionService* extension_service)
: service_weak_(extension_service->AsWeakPtr()),
- prompt_for_plugins_(true) {
+ prompt_for_plugins_(true),
+ require_modern_manifest_version_(true) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
@@ -119,21 +120,11 @@ void UnpackedInstaller::LoadFromCommandLine(const FilePath& path_in) {
return;
}
- std::string id = Extension::GenerateIdForPath(extension_path_);
- bool allow_file_access =
- Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD);
- if (service_weak_->extension_prefs()->HasAllowFileAccessSetting(id))
- allow_file_access = service_weak_->extension_prefs()->AllowFileAccess(id);
-
- int flags = Extension::REQUIRE_MODERN_MANIFEST_VERSION;
- if (allow_file_access)
- flags |= Extension::ALLOW_FILE_ACCESS;
-
std::string error;
scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
extension_path_,
Extension::LOAD,
- flags | Extension::FOLLOW_SYMLINKS_ANYWHERE,
+ GetFlags(),
&error));
if (!extension) {
@@ -144,6 +135,22 @@ void UnpackedInstaller::LoadFromCommandLine(const FilePath& path_in) {
OnLoaded(extension);
}
+int UnpackedInstaller::GetFlags() {
+ std::string id = Extension::GenerateIdForPath(extension_path_);
+ bool allow_file_access =
+ Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD);
+ if (service_weak_->extension_prefs()->HasAllowFileAccessSetting(id))
+ allow_file_access = service_weak_->extension_prefs()->AllowFileAccess(id);
+
+ int result = Extension::FOLLOW_SYMLINKS_ANYWHERE;
+ if (allow_file_access)
+ result |= Extension::ALLOW_FILE_ACCESS;
+ if (require_modern_manifest_version_)
+ result |= Extension::REQUIRE_MODERN_MANIFEST_VERSION;
+
+ return result;
+}
+
bool UnpackedInstaller::IsLoadingUnpackedAllowed() const {
if (!service_weak_)
return true;
@@ -171,30 +178,19 @@ void UnpackedInstaller::CheckExtensionFileAccess() {
return;
}
- std::string id = Extension::GenerateIdForPath(extension_path_);
- // Unpacked extensions default to allowing file access, but if that has been
- // overridden, don't reset the value.
- bool allow_file_access =
- Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD);
- if (service_weak_->extension_prefs()->HasAllowFileAccessSetting(id))
- allow_file_access = service_weak_->extension_prefs()->AllowFileAccess(id);
-
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
base::Bind(
- &UnpackedInstaller::LoadWithFileAccess,
- this, allow_file_access));
+ &UnpackedInstaller::LoadWithFileAccess, this, GetFlags()));
}
-void UnpackedInstaller::LoadWithFileAccess(bool allow_file_access) {
+void UnpackedInstaller::LoadWithFileAccess(int flags) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- int flags = Extension::REQUIRE_MODERN_MANIFEST_VERSION;
- if (allow_file_access)
- flags |= Extension::ALLOW_FILE_ACCESS;
+
std::string error;
scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
extension_path_,
Extension::LOAD,
- flags | Extension::FOLLOW_SYMLINKS_ANYWHERE,
+ flags,
&error));
if (!extension) {
« no previous file with comments | « chrome/browser/extensions/unpacked_installer.h ('k') | chrome/common/extensions/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698