| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 void CrxInstaller::Start(const FilePath& crx_path, | 31 void CrxInstaller::Start(const FilePath& crx_path, |
| 32 const FilePath& install_directory, | 32 const FilePath& install_directory, |
| 33 Extension::Location install_source, | 33 Extension::Location install_source, |
| 34 const std::string& expected_id, | 34 const std::string& expected_id, |
| 35 bool delete_source, | 35 bool delete_source, |
| 36 bool allow_privilege_increase, | 36 bool allow_privilege_increase, |
| 37 ExtensionsService* frontend, | 37 ExtensionsService* frontend, |
| 38 ExtensionInstallUI* client) { | 38 ExtensionInstallUI* client) { |
| 39 // Note: We don't keep a reference because this object manages its own | 39 // Note: This object manages its own lifetime. |
| 40 // lifetime. | 40 scoped_refptr<CrxInstaller> installer( |
| 41 CrxInstaller* installer = new CrxInstaller(crx_path, install_directory, | 41 new CrxInstaller(crx_path, install_directory, delete_source, frontend, |
| 42 delete_source, frontend, | 42 client)); |
| 43 client); | 43 |
| 44 installer->install_source_ = install_source; | 44 installer->install_source_ = install_source; |
| 45 installer->expected_id_ = expected_id; | 45 installer->expected_id_ = expected_id; |
| 46 installer->allow_privilege_increase_ = allow_privilege_increase; | 46 installer->allow_privilege_increase_ = allow_privilege_increase; |
| 47 | 47 |
| 48 scoped_refptr<SandboxedExtensionUnpacker> unpacker( | 48 scoped_refptr<SandboxedExtensionUnpacker> unpacker( |
| 49 new SandboxedExtensionUnpacker( | 49 new SandboxedExtensionUnpacker( |
| 50 installer->source_file_, | 50 installer->source_file_, |
| 51 g_browser_process->resource_dispatcher_host(), | 51 g_browser_process->resource_dispatcher_host(), |
| 52 installer)); | 52 installer.get())); |
| 53 | 53 |
| 54 ChromeThread::PostTask( | 54 ChromeThread::PostTask( |
| 55 ChromeThread::FILE, FROM_HERE, | 55 ChromeThread::FILE, FROM_HERE, |
| 56 NewRunnableMethod( | 56 NewRunnableMethod( |
| 57 unpacker.get(), &SandboxedExtensionUnpacker::Start)); | 57 unpacker.get(), &SandboxedExtensionUnpacker::Start)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void CrxInstaller::InstallUserScript(const FilePath& source_file, | 60 void CrxInstaller::InstallUserScript(const FilePath& source_file, |
| 61 const GURL& original_url, | 61 const GURL& original_url, |
| 62 const FilePath& install_directory, | 62 const FilePath& install_directory, |
| 63 bool delete_source, | 63 bool delete_source, |
| 64 ExtensionsService* frontend, | 64 ExtensionsService* frontend, |
| 65 ExtensionInstallUI* client) { | 65 ExtensionInstallUI* client) { |
| 66 CrxInstaller* installer = new CrxInstaller(source_file, install_directory, | 66 scoped_refptr<CrxInstaller> installer( |
| 67 delete_source, frontend, client); | 67 new CrxInstaller(source_file, install_directory, delete_source, frontend, |
| 68 client)); |
| 68 installer->original_url_ = original_url; | 69 installer->original_url_ = original_url; |
| 69 | 70 |
| 70 ChromeThread::PostTask( | 71 ChromeThread::PostTask( |
| 71 ChromeThread::FILE, FROM_HERE, | 72 ChromeThread::FILE, FROM_HERE, |
| 72 NewRunnableMethod(installer, &CrxInstaller::ConvertUserScriptOnFileThread)
); | 73 NewRunnableMethod(installer.get(), |
| 74 &CrxInstaller::ConvertUserScriptOnFileThread)); |
| 73 } | 75 } |
| 74 | 76 |
| 75 CrxInstaller::CrxInstaller(const FilePath& source_file, | 77 CrxInstaller::CrxInstaller(const FilePath& source_file, |
| 76 const FilePath& install_directory, | 78 const FilePath& install_directory, |
| 77 bool delete_source, | 79 bool delete_source, |
| 78 ExtensionsService* frontend, | 80 ExtensionsService* frontend, |
| 79 ExtensionInstallUI* client) | 81 ExtensionInstallUI* client) |
| 80 : source_file_(source_file), | 82 : source_file_(source_file), |
| 81 install_directory_(install_directory), | 83 install_directory_(install_directory), |
| 82 install_source_(Extension::INTERNAL), | 84 install_source_(Extension::INTERNAL), |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 client_->OnInstallSuccess(extension_.get()); | 345 client_->OnInstallSuccess(extension_.get()); |
| 344 | 346 |
| 345 // Tell the frontend about the installation and hand off ownership of | 347 // Tell the frontend about the installation and hand off ownership of |
| 346 // extension_ to it. | 348 // extension_ to it. |
| 347 frontend_->OnExtensionInstalled(extension_.release(), | 349 frontend_->OnExtensionInstalled(extension_.release(), |
| 348 allow_privilege_increase_); | 350 allow_privilege_increase_); |
| 349 | 351 |
| 350 // We're done. We don't post any more tasks to ourselves so we are deleted | 352 // We're done. We don't post any more tasks to ourselves so we are deleted |
| 351 // soon. | 353 // soon. |
| 352 } | 354 } |
| OLD | NEW |