summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/extensions_service.cc37
-rw-r--r--chrome/browser/utility_process_host.h6
2 files changed, 34 insertions, 9 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index bf38f97..0a495dfd 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -144,8 +144,8 @@ class ExtensionsServiceBackend::UnpackerClient
// in a unit test and run the unpacker directly in-process.
ExtensionUnpacker unpacker(temp_extension_path_);
if (unpacker.Run()) {
- OnUnpackExtensionSucceeded(*unpacker.parsed_manifest(),
- unpacker.decoded_images());
+ OnUnpackExtensionSucceededImpl(*unpacker.parsed_manifest(),
+ unpacker.decoded_images());
} else {
OnUnpackExtensionFailed(unpacker.error_message());
}
@@ -162,9 +162,19 @@ class ExtensionsServiceBackend::UnpackerClient
OnUnpackExtensionFailed("Chrome crashed while trying to install.");
}
- virtual void OnUnpackExtensionSucceeded(
+ virtual void OnUnpackExtensionSucceeded(const DictionaryValue& manifest) {
+ ExtensionUnpacker::DecodedImages images;
+ if (!ExtensionUnpacker::ReadImagesFromFile(temp_extension_path_,
+ &images)) {
+ OnUnpackExtensionFailed("Couldn't read image data from disk.");
+ } else {
+ OnUnpackExtensionSucceededImpl(manifest, images);
+ }
+ }
+
+ void OnUnpackExtensionSucceededImpl(
const DictionaryValue& manifest,
- const std::vector< Tuple2<SkBitmap, FilePath> >& images) {
+ const ExtensionUnpacker::DecodedImages& images) {
// The extension was unpacked to the temp dir inside our unpacking dir.
FilePath extension_dir = temp_extension_path_.DirName().AppendASCII(
ExtensionsServiceBackend::kTempExtensionName);
@@ -965,6 +975,25 @@ void ExtensionsServiceBackend::OnExtensionUnpacked(
return;
}
+ // Delete any images that may be used by the browser. We're going to write
+ // out our own versions of the parsed images, and we want to make sure the
+ // originals are gone for good.
+ std::set<FilePath> image_paths = extension.GetBrowserImages();
+ if (image_paths.size() != images.size()) {
+ ReportExtensionInstallError(extension_path,
+ "Decoded images don't match what's in the manifest.");
+ return;
+ }
+
+ for (std::set<FilePath>::iterator it = image_paths.begin();
+ it != image_paths.end(); ++it) {
+ if (!file_util::Delete(temp_extension_dir.Append(*it), false)) {
+ ReportExtensionInstallError(extension_path,
+ "Error removing old image file.");
+ return;
+ }
+ }
+
// Write our parsed images back to disk as well.
for (size_t i = 0; i < images.size(); ++i) {
const SkBitmap& image = images[i].a;
diff --git a/chrome/browser/utility_process_host.h b/chrome/browser/utility_process_host.h
index 0efaa56..03d98c8 100644
--- a/chrome/browser/utility_process_host.h
+++ b/chrome/browser/utility_process_host.h
@@ -6,7 +6,6 @@
#define CHROME_BROWSER_UTILITY_PROCESS_HOST_H_
#include <string>
-#include <vector>
#include "base/basictypes.h"
#include "base/ref_counted.h"
@@ -17,7 +16,6 @@
class CommandLine;
class DictionaryValue;
class MessageLoop;
-class SkBitmap;
// This class acts as the browser-side host to a utility child process. A
// utility process is a short-lived sandboxed process that is created to run
@@ -38,9 +36,7 @@ class UtilityProcessHost : public ChildProcessHost {
// Called when the extension has unpacked successfully. |manifest| is the
// parsed manifest.json file. |images| contains a list of decoded images
// and the associated paths where those images live on disk.
- virtual void OnUnpackExtensionSucceeded(
- const DictionaryValue& manifest,
- const std::vector< Tuple2<SkBitmap, FilePath> >& images) {}
+ virtual void OnUnpackExtensionSucceeded(const DictionaryValue& manifest) {}
// Called when an error occurred while unpacking the extension.
// |error_message| contains a description of the problem.