Chromium Code Reviews| Index: chrome/browser/extensions/sandboxed_extension_unpacker.cc |
| diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc |
| index 9d7e45b7c1c98cfc20b7b70053c4ee6d0ba0e70b..3da996e99b349994d96a132deef4de67a406c513 100644 |
| --- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc |
| +++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -12,12 +12,14 @@ |
| #include "base/file_util.h" |
| #include "base/file_util_proxy.h" |
| #include "base/message_loop.h" |
| +#include "base/path_service.h" |
| #include "base/scoped_handle.h" |
| #include "base/task.h" |
| #include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me. |
| #include "chrome/browser/browser_thread.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| +#include "chrome/common/chrome_paths.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/extensions/extension.h" |
| #include "chrome/common/extensions/extension_constants.h" |
| @@ -33,28 +35,45 @@ const char SandboxedExtensionUnpacker::kExtensionHeaderMagic[] = "Cr24"; |
| SandboxedExtensionUnpacker::SandboxedExtensionUnpacker( |
| const FilePath& crx_path, |
| - const FilePath& temp_path, |
| ResourceDispatcherHost* rdh, |
| SandboxedExtensionUnpackerClient* client) |
| - : crx_path_(crx_path), temp_path_(temp_path), |
| + : crx_path_(crx_path), |
| thread_identifier_(BrowserThread::ID_COUNT), |
| rdh_(rdh), client_(client), got_response_(false) { |
| } |
| -void SandboxedExtensionUnpacker::Start() { |
| - // We assume that we are started on the thread that the client wants us to do |
| - // file IO on. |
| +bool SandboxedExtensionUnpacker::CreateTempDirectory() { |
| CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_identifier_)); |
| - // Create a temporary directory to work in. |
| - if (!temp_dir_.CreateUniqueTempDirUnderPath(temp_path_)) { |
| - // Could not create temporary directory. |
| + FilePath user_data_temp_dir = extension_file_util::GetUserDataTempDir(); |
| + if (user_data_temp_dir.empty()) { |
| + // TODO(skerner): This should have its own string. |
| + // Using an existing string so that the change can be merged. |
| ReportFailure(l10n_util::GetStringFUTF8( |
|
Erik does not do reviews
2011/01/18 21:36:34
maybe we should also add a histogram straight into
Sam Kerner (Chrome)
2011/01/19 05:01:24
Added a histogram to count failures. Also added o
Erik does not do reviews
2011/01/19 05:14:17
yeah, an enum would be best, but I'm fine doing th
|
| IDS_EXTENSION_PACKAGE_INSTALL_ERROR, |
| ASCIIToUTF16("COULD_NOT_CREATE_TEMP_DIRECTORY"))); |
| - return; |
| + return false; |
| + } |
| + |
| + if (!temp_dir_.CreateUniqueTempDirUnderPath(user_data_temp_dir)) { |
| + ReportFailure(l10n_util::GetStringFUTF8( |
| + IDS_EXTENSION_PACKAGE_INSTALL_ERROR, |
| + ASCIIToUTF16("COULD_NOT_CREATE_TEMP_DIRECTORY"))); |
| + return false; |
| } |
| + return true; |
| +} |
| + |
| +void SandboxedExtensionUnpacker::Start() { |
| + // We assume that we are started on the thread that the client wants us to do |
| + // file IO on. |
| + CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_identifier_)); |
| + |
| + if (!CreateTempDirectory()) |
| + // ReportFailure() already called. |
|
Erik does not do reviews
2011/01/18 21:36:34
can this fit on the same line as the return?
Sam Kerner (Chrome)
2011/01/19 05:01:24
Done.
|
| + return; |
| + |
| // Initialize the path that will eventually contain the unpacked extension. |
| extension_root_ = temp_dir_.path().AppendASCII( |
| extension_filenames::kTempExtensionName); |