OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_unpacker.h" | 5 #include "chrome/browser/extensions/sandboxed_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/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/files/file_util_proxy.h" | 13 #include "base/files/file_util_proxy.h" |
| 14 #include "base/files/scoped_file.h" |
14 #include "base/json/json_string_value_serializer.h" | 15 #include "base/json/json_string_value_serializer.h" |
15 #include "base/memory/scoped_handle.h" | |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/numerics/safe_conversions.h" | 18 #include "base/numerics/safe_conversions.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/sequenced_task_runner.h" | 20 #include "base/sequenced_task_runner.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 CHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); | 413 CHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); |
414 got_response_ = true; | 414 got_response_ = true; |
415 ReportFailure( | 415 ReportFailure( |
416 UNPACKER_CLIENT_FAILED, | 416 UNPACKER_CLIENT_FAILED, |
417 l10n_util::GetStringFUTF16( | 417 l10n_util::GetStringFUTF16( |
418 IDS_EXTENSION_PACKAGE_ERROR_MESSAGE, | 418 IDS_EXTENSION_PACKAGE_ERROR_MESSAGE, |
419 error)); | 419 error)); |
420 } | 420 } |
421 | 421 |
422 bool SandboxedUnpacker::ValidateSignature() { | 422 bool SandboxedUnpacker::ValidateSignature() { |
423 ScopedStdioHandle file(base::OpenFile(crx_path_, "rb")); | 423 base::ScopedFILE file(base::OpenFile(crx_path_, "rb")); |
424 | 424 |
425 if (!file.get()) { | 425 if (!file.get()) { |
426 // Could not open crx file for reading. | 426 // Could not open crx file for reading. |
427 #if defined (OS_WIN) | 427 #if defined (OS_WIN) |
428 // On windows, get the error code. | 428 // On windows, get the error code. |
429 uint32 error_code = ::GetLastError(); | 429 uint32 error_code = ::GetLastError(); |
430 // TODO(skerner): Use this histogram to understand why so many | 430 // TODO(skerner): Use this histogram to understand why so many |
431 // windows users hit this error. crbug.com/69693 | 431 // windows users hit this error. crbug.com/69693 |
432 | 432 |
433 // Windows errors are unit32s, but all of likely errors are in | 433 // Windows errors are unit32s, but all of likely errors are in |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 | 828 |
829 void SandboxedUnpacker::Cleanup() { | 829 void SandboxedUnpacker::Cleanup() { |
830 DCHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); | 830 DCHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); |
831 if (!temp_dir_.Delete()) { | 831 if (!temp_dir_.Delete()) { |
832 LOG(WARNING) << "Can not delete temp directory at " | 832 LOG(WARNING) << "Can not delete temp directory at " |
833 << temp_dir_.path().value(); | 833 << temp_dir_.path().value(); |
834 } | 834 } |
835 } | 835 } |
836 | 836 |
837 } // namespace extensions | 837 } // namespace extensions |
OLD | NEW |