OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/scoped_handle.h" | 13 #include "base/scoped_handle.h" |
14 #include "base/task.h" | 14 #include "base/task.h" |
| 15 #include "base/thread_restrictions.h" |
15 #include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me. | 16 #include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me. |
16 #include "chrome/browser/browser_thread.h" | 17 #include "chrome/browser/browser_thread.h" |
17 #include "chrome/browser/extensions/extensions_service.h" | 18 #include "chrome/browser/extensions/extensions_service.h" |
18 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 19 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
21 #include "chrome/common/extensions/extension_constants.h" | 22 #include "chrome/common/extensions/extension_constants.h" |
22 #include "chrome/common/extensions/extension_file_util.h" | 23 #include "chrome/common/extensions/extension_file_util.h" |
23 #include "chrome/common/extensions/extension_l10n_util.h" | 24 #include "chrome/common/extensions/extension_l10n_util.h" |
24 #include "chrome/common/extensions/extension_unpacker.h" | 25 #include "chrome/common/extensions/extension_unpacker.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 ExtensionUnpacker unpacker(temp_crx_path); | 110 ExtensionUnpacker unpacker(temp_crx_path); |
110 if (unpacker.Run() && unpacker.DumpImagesToFile() && | 111 if (unpacker.Run() && unpacker.DumpImagesToFile() && |
111 unpacker.DumpMessageCatalogsToFile()) { | 112 unpacker.DumpMessageCatalogsToFile()) { |
112 OnUnpackExtensionSucceeded(*unpacker.parsed_manifest()); | 113 OnUnpackExtensionSucceeded(*unpacker.parsed_manifest()); |
113 } else { | 114 } else { |
114 OnUnpackExtensionFailed(unpacker.error_message()); | 115 OnUnpackExtensionFailed(unpacker.error_message()); |
115 } | 116 } |
116 } | 117 } |
117 } | 118 } |
118 | 119 |
119 SandboxedExtensionUnpacker::~SandboxedExtensionUnpacker() {} | 120 SandboxedExtensionUnpacker::~SandboxedExtensionUnpacker() { |
| 121 // temp_dir_'s destructor will delete a directory on the file thread. Do |
| 122 // this on another thread to avoid slowing the UI thread. |
| 123 // http://crbug.com/61922 |
| 124 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 125 temp_dir_.Delete(); |
| 126 } |
120 | 127 |
121 void SandboxedExtensionUnpacker::StartProcessOnIOThread( | 128 void SandboxedExtensionUnpacker::StartProcessOnIOThread( |
122 const FilePath& temp_crx_path) { | 129 const FilePath& temp_crx_path) { |
123 UtilityProcessHost* host = new UtilityProcessHost( | 130 UtilityProcessHost* host = new UtilityProcessHost( |
124 rdh_, this, thread_identifier_); | 131 rdh_, this, thread_identifier_); |
125 host->StartExtensionUnpacker(temp_crx_path); | 132 host->StartExtensionUnpacker(temp_crx_path); |
126 } | 133 } |
127 | 134 |
128 void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded( | 135 void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded( |
129 const DictionaryValue& manifest) { | 136 const DictionaryValue& manifest) { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 if (!file_util::WriteFile(path, | 411 if (!file_util::WriteFile(path, |
405 catalog_json.c_str(), | 412 catalog_json.c_str(), |
406 catalog_json.size())) { | 413 catalog_json.size())) { |
407 ReportFailure("Error saving catalog."); | 414 ReportFailure("Error saving catalog."); |
408 return false; | 415 return false; |
409 } | 416 } |
410 } | 417 } |
411 | 418 |
412 return true; | 419 return true; |
413 } | 420 } |
OLD | NEW |