diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-31 23:53:28 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-31 23:53:28 +0000 |
commit | fc38935ac4b8feccfe596476c0624c81ba7f007b (patch) | |
tree | 8bcf1cd0664aabe7af775c433f216925f4010027 /chrome/browser/extensions | |
parent | 1af419c0f92c04b62ff997de1117309076f4eb17 (diff) | |
download | chromium_src-fc38935ac4b8feccfe596476c0624c81ba7f007b.zip chromium_src-fc38935ac4b8feccfe596476c0624c81ba7f007b.tar.gz chromium_src-fc38935ac4b8feccfe596476c0624c81ba7f007b.tar.bz2 |
Enable experimental permissions for extensions from the store.
BUG=100895
Review URL: http://codereview.chromium.org/8423003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108039 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
7 files changed, 36 insertions, 21 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index dfe55ea..cebc948 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -121,7 +121,6 @@ CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak, install_source_(Extension::INTERNAL), extensions_enabled_(frontend_weak->extensions_enabled()), delete_source_(false), - is_gallery_install_(false), create_app_shortcut_(false), page_index_(-1), frontend_weak_(frontend_weak), @@ -165,6 +164,7 @@ void CrxInstaller::InstallCrx(const FilePath& source_file) { new SandboxedExtensionUnpacker( source_file, g_browser_process->resource_dispatcher_host(), + install_source_, creation_flags_, this)); @@ -274,7 +274,7 @@ bool CrxInstaller::AllowInstall(const Extension* extension, // If the client_ is NULL, then the app is either being installed via // an internal mechanism like sync, external_extensions, or default apps. // In that case, we don't want to enforce things like the install origin. - if (!is_gallery_install_ && client_) { + if (!is_gallery_install() && client_) { // For apps with a gallery update URL, require that they be installed // from the gallery. // TODO(erikkay) Apply this rule for paid extensions and themes as well. @@ -405,7 +405,7 @@ void CrxInstaller::ConfirmInstall() { bool whitelisted = false; scoped_ptr<CrxInstaller::WhitelistEntry> entry( RemoveWhitelistEntry(extension_->id())); - if (is_gallery_install_ && entry.get() && original_manifest_.get()) { + if (is_gallery_install() && entry.get() && original_manifest_.get()) { if (!(original_manifest_->Equals(entry->parsed_manifest.get()))) { ReportFailureFromUIThread( l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID)); @@ -497,13 +497,10 @@ void CrxInstaller::CompleteInstall() { // TODO(aa): All paths to resources inside extensions should be created // lazily and based on the Extension's root path at that moment. std::string error; - int flags = extension_->creation_flags() | Extension::REQUIRE_KEY; - if (is_gallery_install()) - flags |= Extension::FROM_WEBSTORE; extension_ = extension_file_util::LoadExtension( version_dir, install_source_, - flags, + extension_->creation_flags() | Extension::REQUIRE_KEY, &error); CHECK(error.empty()) << error; diff --git a/chrome/browser/extensions/crx_installer.h b/chrome/browser/extensions/crx_installer.h index e83342d..4e0474e 100644 --- a/chrome/browser/extensions/crx_installer.h +++ b/chrome/browser/extensions/crx_installer.h @@ -137,8 +137,13 @@ class CrxInstaller bool allow_silent_install() const { return allow_silent_install_; } void set_allow_silent_install(bool val) { allow_silent_install_ = val; } - bool is_gallery_install() const { return is_gallery_install_; } - void set_is_gallery_install(bool val) { is_gallery_install_ = val; } + bool is_gallery_install() const { + return (creation_flags_ & Extension::FROM_WEBSTORE) > 0; + } + void set_is_gallery_install(bool val) { + if (val) creation_flags_ |= Extension::FROM_WEBSTORE; + else creation_flags_ &= ~Extension::FROM_WEBSTORE; + } // The original download URL should be set when the WebstoreInstaller is // tracking the installation. The WebstoreInstaller uses this URL to match @@ -247,9 +252,6 @@ class CrxInstaller // to false. bool delete_source_; - // Whether the install originated from the gallery. - bool is_gallery_install_; - // The download URL, before redirects, if this is a gallery install. GURL original_download_url_; diff --git a/chrome/browser/extensions/crx_installer_browsertest.cc b/chrome/browser/extensions/crx_installer_browsertest.cc index 9353aa1..d108c56 100644 --- a/chrome/browser/extensions/crx_installer_browsertest.cc +++ b/chrome/browser/extensions/crx_installer_browsertest.cc @@ -73,3 +73,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, Whitelisting) { "hdgllgikmikobbofgnabhfimcfoopgnd")); #endif // !defined(OS_CHROMEOS) } + +IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, + GalleryInstallGetsExperimental) { + InstallExtension(test_data_dir_.AppendASCII("experimental.crx"), 0); + InstallExtensionFromWebstore( + test_data_dir_.AppendASCII("experimental.crx"), 1); +} diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc index f96fd61..3c8a214 100644 --- a/chrome/browser/extensions/extension_browsertest.cc +++ b/chrome/browser/extensions/extension_browsertest.cc @@ -176,7 +176,8 @@ FilePath ExtensionBrowserTest::PackExtension(const FilePath& dir_path) { crx_path, FilePath(), // no existing pem, use empty path pem_path)) { - ADD_FAILURE() << "ExtensionCreator::Run() failed."; + ADD_FAILURE() << "ExtensionCreator::Run() failed: " + << creator->error_message(); return FilePath(); } diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc index 987eb8b..69dd6f9 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc +++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc @@ -20,7 +20,6 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_utility_messages.h" -#include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_file_util.h" #include "chrome/common/extensions/extension_l10n_util.h" @@ -112,12 +111,13 @@ void RecordSuccessfulUnpackTimeHistograms( SandboxedExtensionUnpacker::SandboxedExtensionUnpacker( const FilePath& crx_path, ResourceDispatcherHost* rdh, + Extension::Location location, int creation_flags, SandboxedExtensionUnpackerClient* client) : crx_path_(crx_path), thread_identifier_(BrowserThread::ID_COUNT), rdh_(rdh), client_(client), got_response_(false), - creation_flags_(creation_flags) { + location_(location), creation_flags_(creation_flags) { } bool SandboxedExtensionUnpacker::CreateTempDirectory() { @@ -214,7 +214,7 @@ void SandboxedExtensionUnpacker::Start() { link_free_crx_path)); } else { // Otherwise, unpack the extension in this process. - ExtensionUnpacker unpacker(temp_crx_path); + ExtensionUnpacker unpacker(temp_crx_path, location_, creation_flags_); if (unpacker.Run() && unpacker.DumpImagesToFile() && unpacker.DumpMessageCatalogsToFile()) { OnUnpackExtensionSucceeded(*unpacker.parsed_manifest()); @@ -262,7 +262,9 @@ void SandboxedExtensionUnpacker::StartProcessOnIOThread( // Grant the subprocess access to the entire subdir the extension file is // in, so that it can unpack to that dir. host->set_exposed_dir(temp_crx_path.DirName()); - host->Send(new ChromeUtilityMsg_UnpackExtension(temp_crx_path)); + host->Send( + new ChromeUtilityMsg_UnpackExtension( + temp_crx_path, location_, creation_flags_)); } void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded( @@ -296,7 +298,7 @@ void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded( extension_ = Extension::Create( extension_root_, - Extension::INTERNAL, + location_, *final_manifest, Extension::REQUIRE_KEY | creation_flags_, &error); diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.h b/chrome/browser/extensions/sandboxed_extension_unpacker.h index f8230bc..43907ef 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker.h +++ b/chrome/browser/extensions/sandboxed_extension_unpacker.h @@ -11,6 +11,7 @@ #include "base/file_path.h" #include "base/memory/ref_counted.h" #include "base/scoped_temp_dir.h" +#include "chrome/common/extensions/extension.h" #include "content/browser/utility_process_host.h" class Extension; @@ -101,6 +102,7 @@ class SandboxedExtensionUnpacker : public UtilityProcessHost::Client { // sandboxed subprocess. Otherwise, it is done in-process. SandboxedExtensionUnpacker(const FilePath& crx_path, ResourceDispatcherHost* rdh, + Extension::Location location, int creation_flags, SandboxedExtensionUnpackerClient* client); @@ -242,6 +244,9 @@ class SandboxedExtensionUnpacker : public UtilityProcessHost::Client { // Time at which unpacking started. Used to compute the time unpacking takes. base::TimeTicks unpack_start_time_; + // Location to use for the unpacked extension. + Extension::Location location_; + // Creation flags to use for the extension. These flags will be used // when calling Extenion::Create() by the crx installer. int creation_flags_; diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc index 3243e0a..e09d38e 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc +++ b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc @@ -90,7 +90,8 @@ class SandboxedExtensionUnpackerTest : public testing::Test { "Original path: " << original_path.value() << ", Crx path: " << crx_path.value(); - unpacker_.reset(new ExtensionUnpacker(crx_path)); + unpacker_.reset(new ExtensionUnpacker( + crx_path, Extension::INTERNAL, Extension::NO_FLAGS)); // Build a temp area where the extension will be unpacked. temp_path_ = @@ -98,8 +99,8 @@ class SandboxedExtensionUnpackerTest : public testing::Test { ASSERT_TRUE(file_util::CreateDirectory(temp_path_)); sandboxed_unpacker_ = - new SandboxedExtensionUnpacker(crx_path, NULL, Extension::NO_FLAGS, - client_); + new SandboxedExtensionUnpacker(crx_path, NULL, Extension::INTERNAL, + Extension::NO_FLAGS, client_); // Hack since SandboxedExtensionUnpacker gets its background thread id from // the Start call, but we don't call it here. |