diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 23:37:25 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 23:37:25 +0000 |
commit | 3d8eb9f9e98db390212cb3eb8d2f9bebea264a58 (patch) | |
tree | d8878ee7a07accacaaf8dd1802d5c1de40847320 /chrome/browser/extensions | |
parent | 2978cabdfcedc467fe79c318e1151d0ba42cbb7a (diff) | |
download | chromium_src-3d8eb9f9e98db390212cb3eb8d2f9bebea264a58.zip chromium_src-3d8eb9f9e98db390212cb3eb8d2f9bebea264a58.tar.gz chromium_src-3d8eb9f9e98db390212cb3eb8d2f9bebea264a58.tar.bz2 |
Remove call to image decoding from chrome\browser. This last call was during extensions install, and the browser already gets the decoded images.
BUG=237249
R=mpcomplete@chromium.org
Review URL: https://codereview.chromium.org/5671933811097600
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211250 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/crx_installer.cc | 19 | ||||
-rw-r--r-- | chrome/browser/extensions/crx_installer.h | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/sandboxed_unpacker.cc | 21 | ||||
-rw-r--r-- | chrome/browser/extensions/sandboxed_unpacker.h | 12 | ||||
-rw-r--r-- | chrome/browser/extensions/sandboxed_unpacker_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/startup_helper.cc | 3 |
6 files changed, 39 insertions, 22 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index c8535aa..322dbe0 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -39,7 +39,6 @@ #include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/feature_switch.h" #include "chrome/common/extensions/manifest.h" -#include "chrome/common/extensions/manifest_handlers/icons_handler.h" #include "chrome/common/extensions/manifest_handlers/shared_module_info.h" #include "chrome/common/extensions/manifest_url_handler.h" #include "chrome/common/extensions/user_script.h" @@ -184,7 +183,8 @@ void CrxInstaller::ConvertUserScriptOnFileThread() { return; } - OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get()); + OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get(), + SkBitmap()); } void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { @@ -211,7 +211,8 @@ void CrxInstaller::ConvertWebAppOnFileThread( // TODO(aa): conversion data gets lost here :( - OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get()); + OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get(), + SkBitmap()); } CrxInstallerError CrxInstaller::AllowInstall(const Extension* extension) { @@ -359,7 +360,8 @@ void CrxInstaller::OnUnpackFailure(const string16& error_message) { void CrxInstaller::OnUnpackSuccess(const base::FilePath& temp_dir, const base::FilePath& extension_dir, const DictionaryValue* original_manifest, - const Extension* extension) { + const Extension* extension, + const SkBitmap& install_icon) { DCHECK(installer_task_runner_->RunsTasksOnCurrentThread()); UMA_HISTOGRAM_ENUMERATION("Extensions.UnpackSuccessInstallSource", @@ -372,6 +374,8 @@ void CrxInstaller::OnUnpackSuccess(const base::FilePath& temp_dir, installer_.set_extension(extension); temp_dir_ = temp_dir; + if (!install_icon.empty()) + install_icon_.reset(new SkBitmap(install_icon)); if (original_manifest) original_manifest_.reset(new Manifest( @@ -388,13 +392,6 @@ void CrxInstaller::OnUnpackSuccess(const base::FilePath& temp_dir, return; } - if (client_) { - IconsInfo::DecodeIcon(installer_.extension().get(), - extension_misc::EXTENSION_ICON_LARGE, - ExtensionIconSet::MATCH_BIGGER, - &install_icon_); - } - if (!BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&CrxInstaller::CheckImportsAndRequirements, this))) diff --git a/chrome/browser/extensions/crx_installer.h b/chrome/browser/extensions/crx_installer.h index 5de41a9..dd2e9216 100644 --- a/chrome/browser/extensions/crx_installer.h +++ b/chrome/browser/extensions/crx_installer.h @@ -222,7 +222,8 @@ class CrxInstaller virtual void OnUnpackSuccess(const base::FilePath& temp_dir, const base::FilePath& extension_dir, const base::DictionaryValue* original_manifest, - const Extension* extension) OVERRIDE; + const Extension* extension, + const SkBitmap& install_icon) OVERRIDE; // Called on the UI thread to start the requirements check on the extension. void CheckImportsAndRequirements(); diff --git a/chrome/browser/extensions/sandboxed_unpacker.cc b/chrome/browser/extensions/sandboxed_unpacker.cc index bff9bfb..8b41583b 100644 --- a/chrome/browser/extensions/sandboxed_unpacker.cc +++ b/chrome/browser/extensions/sandboxed_unpacker.cc @@ -29,6 +29,7 @@ #include "chrome/common/extensions/extension_l10n_util.h" #include "chrome/common/extensions/extension_manifest_constants.h" #include "chrome/common/extensions/extension_manifest_constants.h" +#include "chrome/common/extensions/manifest_handlers/icons_handler.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/utility_process_host.h" #include "content/public/common/common_param_traits.h" @@ -395,13 +396,14 @@ void SandboxedUnpacker::OnUnpackExtensionSucceeded( return; } - if (!RewriteImageFiles()) + SkBitmap install_icon; + if (!RewriteImageFiles(&install_icon)) return; if (!RewriteCatalogFiles()) return; - ReportSuccess(manifest); + ReportSuccess(manifest, install_icon); } void SandboxedUnpacker::OnUnpackExtensionFailed(const string16& error) { @@ -587,7 +589,8 @@ void SandboxedUnpacker::ReportFailure(FailureReason reason, } void SandboxedUnpacker::ReportSuccess( - const DictionaryValue& original_manifest) { + const DictionaryValue& original_manifest, + const SkBitmap& install_icon) { UMA_HISTOGRAM_COUNTS("Extensions.SandboxUnpackSuccess", 1); RecordSuccessfulUnpackTimeHistograms( @@ -595,7 +598,8 @@ void SandboxedUnpacker::ReportSuccess( // Client takes ownership of temporary directory and extension. client_->OnUnpackSuccess( - temp_dir_.Take(), extension_root_, &original_manifest, extension_.get()); + temp_dir_.Take(), extension_root_, &original_manifest, extension_.get(), + install_icon); extension_ = NULL; } @@ -636,7 +640,7 @@ DictionaryValue* SandboxedUnpacker::RewriteManifestFile( return final_manifest.release(); } -bool SandboxedUnpacker::RewriteImageFiles() { +bool SandboxedUnpacker::RewriteImageFiles(SkBitmap* install_icon) { DecodedImages images; if (!ReadImagesFromFile(temp_dir_.path(), &images)) { // Couldn't read image data from disk. @@ -686,6 +690,10 @@ bool SandboxedUnpacker::RewriteImageFiles() { } } + std::string install_icon_path = IconsInfo::GetIcons(extension_).Get( + extension_misc::EXTENSION_ICON_LARGE, + ExtensionIconSet::MATCH_BIGGER); + // Write our parsed images back to disk as well. for (size_t i = 0; i < images.size(); ++i) { if (BrowserThread::GetBlockingPool()->IsShutdownInProgress()) { @@ -700,6 +708,9 @@ bool SandboxedUnpacker::RewriteImageFiles() { const SkBitmap& image = images[i].a; base::FilePath path_suffix = images[i].b; + if (path_suffix.MaybeAsASCII() == install_icon_path) + *install_icon = image; + if (path_suffix.IsAbsolute() || path_suffix.ReferencesParent()) { // Invalid path for bitmap image. ReportFailure( diff --git a/chrome/browser/extensions/sandboxed_unpacker.h b/chrome/browser/extensions/sandboxed_unpacker.h index bf76257..07031da 100644 --- a/chrome/browser/extensions/sandboxed_unpacker.h +++ b/chrome/browser/extensions/sandboxed_unpacker.h @@ -14,6 +14,8 @@ #include "chrome/common/extensions/manifest.h" #include "content/public/browser/utility_process_host_client.h" +class SkBitmap; + namespace base { class DictionaryValue; class SequencedTaskRunner; @@ -35,10 +37,13 @@ class SandboxedUnpackerClient // // extension - The extension that was unpacked. The client is responsible // for deleting this memory. + // + // install_icon - The icon we will display in the installation UI, if any. virtual void OnUnpackSuccess(const base::FilePath& temp_dir, const base::FilePath& extension_root, const base::DictionaryValue* original_manifest, - const Extension* extension) = 0; + const Extension* extension, + const SkBitmap& install_icon) = 0; virtual void OnUnpackFailure(const string16& error) = 0; protected: @@ -177,7 +182,8 @@ class SandboxedUnpacker : public content::UtilityProcessHostClient { void OnUnpackExtensionFailed(const string16& error_message); void ReportFailure(FailureReason reason, const string16& message); - void ReportSuccess(const base::DictionaryValue& original_manifest); + void ReportSuccess(const base::DictionaryValue& original_manifest, + const SkBitmap& install_icon); // Overwrites original manifest with safe result from utility process. // Returns NULL on error. Caller owns the returned object. @@ -186,7 +192,7 @@ class SandboxedUnpacker : public content::UtilityProcessHostClient { // Overwrites original files with safe results from utility process. // Reports error and returns false if it fails. - bool RewriteImageFiles(); + bool RewriteImageFiles(SkBitmap* install_icon); bool RewriteCatalogFiles(); // Cleans up temp directory artifacts. diff --git a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_unpacker_unittest.cc index 7e0477f..55fe555 100644 --- a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc +++ b/chrome/browser/extensions/sandboxed_unpacker_unittest.cc @@ -40,7 +40,8 @@ class MockSandboxedUnpackerClient : public SandboxedUnpackerClient { virtual void OnUnpackSuccess(const base::FilePath& temp_dir, const base::FilePath& extension_root, const base::DictionaryValue* original_manifest, - const Extension* extension) OVERRIDE { + const Extension* extension, + const SkBitmap& install_icon) OVERRIDE { temp_dir_ = temp_dir; quit_closure_.Run(); diff --git a/chrome/browser/extensions/startup_helper.cc b/chrome/browser/extensions/startup_helper.cc index 0858da3..7bc9524 100644 --- a/chrome/browser/extensions/startup_helper.cc +++ b/chrome/browser/extensions/startup_helper.cc @@ -107,7 +107,8 @@ class ValidateCrxHelper : public SandboxedUnpackerClient { virtual void OnUnpackSuccess(const base::FilePath& temp_dir, const base::FilePath& extension_root, const base::DictionaryValue* original_manifest, - const Extension* extension) OVERRIDE { + const Extension* extension, + const SkBitmap& install_icon) OVERRIDE { finished_ = true; success_ = true; BrowserThread::PostTask(BrowserThread::UI, |