| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/zipfile_installer.h" | 5 #include "chrome/browser/extensions/zipfile_installer.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/browser/extensions/extension_error_reporter.h" | 9 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/unpacked_installer.h" | 11 #include "chrome/browser/extensions/unpacked_installer.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 13 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" |
| 14 #include "chrome/grit/generated_resources.h" |
| 14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/utility_process_host.h" | 16 #include "content/public/browser/utility_process_host.h" |
| 17 #include "ui/base/l10n/l10n_util.h" |
| 16 | 18 |
| 17 using content::BrowserThread; | 19 using content::BrowserThread; |
| 18 using content::UtilityProcessHost; | 20 using content::UtilityProcessHost; |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| 21 | 23 |
| 22 const char kExtensionHandlerTempDirError[] = | 24 const char kExtensionHandlerTempDirError[] = |
| 23 "Could not create temporary directory for zipped extension."; | 25 "Could not create temporary directory for zipped extension."; |
| 24 | 26 |
| 25 } // namespace | 27 } // namespace |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 ExtensionService* extension_service) { | 68 ExtensionService* extension_service) { |
| 67 DCHECK(extension_service); | 69 DCHECK(extension_service); |
| 68 return scoped_refptr<ZipFileInstaller>( | 70 return scoped_refptr<ZipFileInstaller>( |
| 69 new ZipFileInstaller(extension_service)); | 71 new ZipFileInstaller(extension_service)); |
| 70 } | 72 } |
| 71 | 73 |
| 72 void ZipFileInstaller::StartWorkOnIOThread(const base::FilePath& temp_dir) { | 74 void ZipFileInstaller::StartWorkOnIOThread(const base::FilePath& temp_dir) { |
| 73 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 75 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 74 UtilityProcessHost* host = | 76 UtilityProcessHost* host = |
| 75 UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get()); | 77 UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get()); |
| 78 host->SetName(l10n_util::GetStringUTF16( |
| 79 IDS_UTILITY_PROCESS_ZIP_FILE_INSTALLER_NAME)); |
| 76 host->SetExposedDir(temp_dir); | 80 host->SetExposedDir(temp_dir); |
| 77 host->Send(new ChromeUtilityMsg_UnzipToDir(zip_path_, temp_dir)); | 81 host->Send(new ChromeUtilityMsg_UnzipToDir(zip_path_, temp_dir)); |
| 78 } | 82 } |
| 79 | 83 |
| 80 void ZipFileInstaller::ReportSuccessOnUIThread( | 84 void ZipFileInstaller::ReportSuccessOnUIThread( |
| 81 const base::FilePath& unzipped_path) { | 85 const base::FilePath& unzipped_path) { |
| 82 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 86 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 83 if (extension_service_weak_.get()) | 87 if (extension_service_weak_.get()) |
| 84 UnpackedInstaller::Create(extension_service_weak_.get()) | 88 UnpackedInstaller::Create(extension_service_weak_.get()) |
| 85 ->Load(unzipped_path); | 89 ->Load(unzipped_path); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 IPC_BEGIN_MESSAGE_MAP(ZipFileInstaller, message) | 122 IPC_BEGIN_MESSAGE_MAP(ZipFileInstaller, message) |
| 119 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnzipToDir_Succeeded, | 123 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnzipToDir_Succeeded, |
| 120 OnUnzipSucceeded) | 124 OnUnzipSucceeded) |
| 121 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnzipToDir_Failed, OnUnzipFailed) | 125 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnzipToDir_Failed, OnUnzipFailed) |
| 122 IPC_MESSAGE_UNHANDLED(handled = false) | 126 IPC_MESSAGE_UNHANDLED(handled = false) |
| 123 IPC_END_MESSAGE_MAP() | 127 IPC_END_MESSAGE_MAP() |
| 124 return handled; | 128 return handled; |
| 125 } | 129 } |
| 126 | 130 |
| 127 } // namespace extensions | 131 } // namespace extensions |
| OLD | NEW |