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

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

Issue 1582022: Unpack extensions inside chrome's directory. (Closed)
Patch Set: Final rebase. Created 10 years, 7 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 "base/base64.h" 9 #include "base/base64.h"
10 #include "base/crypto/signature_verifier.h" 10 #include "base/crypto/signature_verifier.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/common/extensions/extension_file_util.h" 21 #include "chrome/common/extensions/extension_file_util.h"
22 #include "chrome/common/extensions/extension_l10n_util.h" 22 #include "chrome/common/extensions/extension_l10n_util.h"
23 #include "chrome/common/extensions/extension_unpacker.h" 23 #include "chrome/common/extensions/extension_unpacker.h"
24 #include "chrome/common/json_value_serializer.h" 24 #include "chrome/common/json_value_serializer.h"
25 #include "gfx/codec/png_codec.h" 25 #include "gfx/codec/png_codec.h"
26 #include "third_party/skia/include/core/SkBitmap.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
27 27
28 const char SandboxedExtensionUnpacker::kExtensionHeaderMagic[] = "Cr24"; 28 const char SandboxedExtensionUnpacker::kExtensionHeaderMagic[] = "Cr24";
29 29
30 SandboxedExtensionUnpacker::SandboxedExtensionUnpacker( 30 SandboxedExtensionUnpacker::SandboxedExtensionUnpacker(
31 const FilePath& crx_path, ResourceDispatcherHost* rdh, 31 const FilePath& crx_path,
32 const FilePath& temp_path,
33 ResourceDispatcherHost* rdh,
32 SandboxedExtensionUnpackerClient* client) 34 SandboxedExtensionUnpackerClient* client)
33 : crx_path_(crx_path), thread_identifier_(ChromeThread::ID_COUNT), 35 : crx_path_(crx_path), temp_path_(temp_path),
34 rdh_(rdh), client_(client), got_response_(false) { 36 thread_identifier_(ChromeThread::ID_COUNT),
37 rdh_(rdh), client_(client), got_response_(false) {
35 } 38 }
36 39
37 void SandboxedExtensionUnpacker::Start() { 40 void SandboxedExtensionUnpacker::Start() {
38 // We assume that we are started on the thread that the client wants us to do 41 // We assume that we are started on the thread that the client wants us to do
39 // file IO on. 42 // file IO on.
40 CHECK(ChromeThread::GetCurrentThreadIdentifier(&thread_identifier_)); 43 CHECK(ChromeThread::GetCurrentThreadIdentifier(&thread_identifier_));
41 44
42 // Create a temporary directory to work in. 45 // Create a temporary directory to work in.
43 if (!temp_dir_.CreateUniqueTempDir()) { 46 if (!temp_dir_.CreateUniqueTempDirUnderPath(temp_path_)) {
44 ReportFailure("Could not create temporary directory."); 47 ReportFailure("Could not create temporary directory.");
45 return; 48 return;
46 } 49 }
47 50
48 // Initialize the path that will eventually contain the unpacked extension. 51 // Initialize the path that will eventually contain the unpacked extension.
49 extension_root_ = temp_dir_.path().AppendASCII("TEMP_INSTALL"); 52 extension_root_ = temp_dir_.path().AppendASCII(
53 extension_filenames::kTempExtensionName);
50 54
51 // Extract the public key and validate the package. 55 // Extract the public key and validate the package.
52 if (!ValidateSignature()) 56 if (!ValidateSignature())
53 return; // ValidateSignature() already reported the error. 57 return; // ValidateSignature() already reported the error.
54 58
55 // Copy the crx file into our working directory. 59 // Copy the crx file into our working directory.
56 FilePath temp_crx_path = temp_dir_.path().Append(crx_path_.BaseName()); 60 FilePath temp_crx_path = temp_dir_.path().Append(crx_path_.BaseName());
57 if (!file_util::CopyFile(crx_path_, temp_crx_path)) { 61 if (!file_util::CopyFile(crx_path_, temp_crx_path)) {
58 ReportFailure("Failed to copy extension file to temporary directory."); 62 ReportFailure("Failed to copy extension file to temporary directory.");
59 return; 63 return;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 if (!file_util::WriteFile(path, 390 if (!file_util::WriteFile(path,
387 catalog_json.c_str(), 391 catalog_json.c_str(),
388 catalog_json.size())) { 392 catalog_json.size())) {
389 ReportFailure("Error saving catalog."); 393 ReportFailure("Error saving catalog.");
390 return false; 394 return false;
391 } 395 }
392 } 396 }
393 397
394 return true; 398 return true;
395 } 399 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698