| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 BrowserThread::GetMessageLoopProxyForThread(thread_identifier_), | 227 BrowserThread::GetMessageLoopProxyForThread(thread_identifier_), |
| 228 temp_dir_.Take(), | 228 temp_dir_.Take(), |
| 229 true, | 229 true, |
| 230 NULL); | 230 NULL); |
| 231 } | 231 } |
| 232 | 232 |
| 233 bool SandboxedExtensionUnpacker::OnMessageReceived( | 233 bool SandboxedExtensionUnpacker::OnMessageReceived( |
| 234 const IPC::Message& message) { | 234 const IPC::Message& message) { |
| 235 bool handled = true; | 235 bool handled = true; |
| 236 IPC_BEGIN_MESSAGE_MAP(SandboxedExtensionUnpacker, message) | 236 IPC_BEGIN_MESSAGE_MAP(SandboxedExtensionUnpacker, message) |
| 237 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackExtension_Succeeded, | 237 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnpackExtension_Succeeded, |
| 238 OnUnpackExtensionSucceeded) | 238 OnUnpackExtensionSucceeded) |
| 239 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackExtension_Failed, | 239 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnpackExtension_Failed, |
| 240 OnUnpackExtensionFailed) | 240 OnUnpackExtensionFailed) |
| 241 IPC_MESSAGE_UNHANDLED(handled = false) | 241 IPC_MESSAGE_UNHANDLED(handled = false) |
| 242 IPC_END_MESSAGE_MAP() | 242 IPC_END_MESSAGE_MAP() |
| 243 return handled; | 243 return handled; |
| 244 } | 244 } |
| 245 | 245 |
| 246 void SandboxedExtensionUnpacker::OnProcessCrashed(int exit_code) { | 246 void SandboxedExtensionUnpacker::OnProcessCrashed(int exit_code) { |
| 247 // Don't report crashes if they happen after we got a response. | 247 // Don't report crashes if they happen after we got a response. |
| 248 if (got_response_) | 248 if (got_response_) |
| 249 return; | 249 return; |
| 250 | 250 |
| 251 // Utility process crashed while trying to install. | 251 // Utility process crashed while trying to install. |
| 252 ReportFailure( | 252 ReportFailure( |
| 253 UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL, | 253 UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL, |
| 254 l10n_util::GetStringFUTF8( | 254 l10n_util::GetStringFUTF8( |
| 255 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 255 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, |
| 256 ASCIIToUTF16("UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL"))); | 256 ASCIIToUTF16("UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL"))); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void SandboxedExtensionUnpacker::StartProcessOnIOThread( | 259 void SandboxedExtensionUnpacker::StartProcessOnIOThread( |
| 260 const FilePath& temp_crx_path) { | 260 const FilePath& temp_crx_path) { |
| 261 UtilityProcessHost* host = new UtilityProcessHost(this, thread_identifier_); | 261 UtilityProcessHost* host = new UtilityProcessHost(this, thread_identifier_); |
| 262 // Grant the subprocess access to the entire subdir the extension file is | 262 // Grant the subprocess access to the entire subdir the extension file is |
| 263 // in, so that it can unpack to that dir. | 263 // in, so that it can unpack to that dir. |
| 264 host->set_exposed_dir(temp_crx_path.DirName()); | 264 host->set_exposed_dir(temp_crx_path.DirName()); |
| 265 host->Send(new UtilityMsg_UnpackExtension(temp_crx_path)); | 265 host->Send(new ChromeUtilityMsg_UnpackExtension(temp_crx_path)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded( | 268 void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded( |
| 269 const DictionaryValue& manifest) { | 269 const DictionaryValue& manifest) { |
| 270 // Skip check for unittests. | 270 // Skip check for unittests. |
| 271 if (thread_identifier_ != BrowserThread::ID_COUNT) | 271 if (thread_identifier_ != BrowserThread::ID_COUNT) |
| 272 CHECK(BrowserThread::CurrentlyOn(thread_identifier_)); | 272 CHECK(BrowserThread::CurrentlyOn(thread_identifier_)); |
| 273 got_response_ = true; | 273 got_response_ = true; |
| 274 | 274 |
| 275 scoped_ptr<DictionaryValue> final_manifest(RewriteManifestFile(manifest)); | 275 scoped_ptr<DictionaryValue> final_manifest(RewriteManifestFile(manifest)); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 ERROR_SAVING_CATALOG, | 709 ERROR_SAVING_CATALOG, |
| 710 l10n_util::GetStringFUTF8( | 710 l10n_util::GetStringFUTF8( |
| 711 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 711 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, |
| 712 ASCIIToUTF16("ERROR_SAVING_CATALOG"))); | 712 ASCIIToUTF16("ERROR_SAVING_CATALOG"))); |
| 713 return false; | 713 return false; |
| 714 } | 714 } |
| 715 } | 715 } |
| 716 | 716 |
| 717 return true; | 717 return true; |
| 718 } | 718 } |
| OLD | NEW |