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

Side by Side Diff: chrome/browser/extensions/sandboxed_extension_unpacker.cc

Issue 256049: Generate IDs for --load-extension by hashing the path instead (Closed)
Patch Set: Removed support for default Extension constructor Created 11 years, 2 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/browser/extensions/sandboxed_extension_unpacker.h" 5 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "app/gfx/codec/png_codec.h" 9 #include "app/gfx/codec/png_codec.h"
10 #include "base/crypto/signature_verifier.h" 10 #include "base/crypto/signature_verifier.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 FilePath manifest_path = 114 FilePath manifest_path =
115 extension_root_.AppendASCII(Extension::kManifestFilename); 115 extension_root_.AppendASCII(Extension::kManifestFilename);
116 if (!file_util::WriteFile(manifest_path, 116 if (!file_util::WriteFile(manifest_path,
117 manifest_json.data(), manifest_json.size())) { 117 manifest_json.data(), manifest_json.size())) {
118 ReportFailure("Error saving manifest.json."); 118 ReportFailure("Error saving manifest.json.");
119 return; 119 return;
120 } 120 }
121 121
122 // Delete any images that may be used by the browser. We're going to write 122 // Create an extension object that refers to the temporary location the
123 // out our own versions of the parsed images, and we want to make sure the 123 // extension was unpacked to. We use this until the extension is finally
124 // originals are gone for good. 124 // installed. For example, the install UI shows images from inside the
125 extension_.reset(new Extension); 125 // extension.
126 extension_.reset(new Extension(extension_root_));
127
126 std::string manifest_error; 128 std::string manifest_error;
127
128 // Update the path to refer to the temporary location. We do this because
129 // clients may want to use resources inside the extension before it is
130 // installed and they need the correct path. For example, the install UI shows
131 // one of the icons from the extension.
132 extension_->set_path(extension_root_);
133
134 if (!extension_->InitFromValue(*final_manifest, true, // require id 129 if (!extension_->InitFromValue(*final_manifest, true, // require id
135 &manifest_error)) { 130 &manifest_error)) {
136 ReportFailure(std::string("Manifest is invalid: ") + 131 ReportFailure(std::string("Manifest is invalid: ") +
137 manifest_error); 132 manifest_error);
138 return; 133 return;
139 } 134 }
140 135
136 // Delete any images that may be used by the browser. We're going to write
137 // out our own versions of the parsed images, and we want to make sure the
138 // originals are gone for good.
141 std::set<FilePath> image_paths = extension_->GetBrowserImages(); 139 std::set<FilePath> image_paths = extension_->GetBrowserImages();
142 if (image_paths.size() != images.size()) { 140 if (image_paths.size() != images.size()) {
143 ReportFailure("Decoded images don't match what's in the manifest."); 141 ReportFailure("Decoded images don't match what's in the manifest.");
144 return; 142 return;
145 } 143 }
146 144
147 for (std::set<FilePath>::iterator it = image_paths.begin(); 145 for (std::set<FilePath>::iterator it = image_paths.begin();
148 it != image_paths.end(); ++it) { 146 it != image_paths.end(); ++it) {
149 FilePath path = *it; 147 FilePath path = *it;
150 if (path.IsAbsolute() || path.ReferencesParent()) { 148 if (path.IsAbsolute() || path.ReferencesParent()) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 292
295 void SandboxedExtensionUnpacker::ReportFailure(const std::string& error) { 293 void SandboxedExtensionUnpacker::ReportFailure(const std::string& error) {
296 client_->OnUnpackFailure(error); 294 client_->OnUnpackFailure(error);
297 } 295 }
298 296
299 void SandboxedExtensionUnpacker::ReportSuccess() { 297 void SandboxedExtensionUnpacker::ReportSuccess() {
300 // Client takes ownership of temporary directory and extension. 298 // Client takes ownership of temporary directory and extension.
301 client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_, 299 client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_,
302 extension_.release()); 300 extension_.release());
303 } 301 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_service_unittest.cc ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698