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/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 "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" |
10 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
11 #include "base/task.h" | 12 #include "base/task.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chrome_thread.h" | 15 #include "chrome/browser/chrome_thread.h" |
15 #include "chrome/browser/extensions/convert_user_script.h" | 16 #include "chrome/browser/extensions/convert_user_script.h" |
16 #include "chrome/browser/extensions/extension_error_reporter.h" | 17 #include "chrome/browser/extensions/extension_error_reporter.h" |
17 #include "chrome/browser/profile.h" | 18 #include "chrome/browser/profile.h" |
18 #include "chrome/browser/shell_integration.h" | 19 #include "chrome/browser/shell_integration.h" |
19 #include "chrome/browser/web_applications/web_app.h" | 20 #include "chrome/browser/web_applications/web_app.h" |
| 21 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/extensions/extension_file_util.h" | 22 #include "chrome/common/extensions/extension_file_util.h" |
21 #include "chrome/common/notification_service.h" | 23 #include "chrome/common/notification_service.h" |
22 #include "chrome/common/notification_type.h" | 24 #include "chrome/common/notification_type.h" |
23 #include "grit/browser_resources.h" | 25 #include "grit/browser_resources.h" |
24 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
25 #include "third_party/skia/include/core/SkBitmap.h" | 27 #include "third_party/skia/include/core/SkBitmap.h" |
26 | 28 |
27 namespace { | 29 namespace { |
28 // Helper function to delete files. This is used to avoid ugly casts which | 30 // Helper function to delete files. This is used to avoid ugly casts which |
29 // would be necessary with PostMessage since file_util::Delete is overloaded. | 31 // would be necessary with PostMessage since file_util::Delete is overloaded. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 65 } |
64 | 66 |
65 // Make sure the UI is deleted on the ui thread. | 67 // Make sure the UI is deleted on the ui thread. |
66 ChromeThread::DeleteSoon(ChromeThread::UI, FROM_HERE, client_); | 68 ChromeThread::DeleteSoon(ChromeThread::UI, FROM_HERE, client_); |
67 client_ = NULL; | 69 client_ = NULL; |
68 } | 70 } |
69 | 71 |
70 void CrxInstaller::InstallCrx(const FilePath& source_file) { | 72 void CrxInstaller::InstallCrx(const FilePath& source_file) { |
71 source_file_ = source_file; | 73 source_file_ = source_file; |
72 | 74 |
| 75 FilePath user_data_temp_dir; |
| 76 CHECK(PathService::Get(chrome::DIR_USER_DATA_TEMP, &user_data_temp_dir)); |
| 77 |
73 scoped_refptr<SandboxedExtensionUnpacker> unpacker( | 78 scoped_refptr<SandboxedExtensionUnpacker> unpacker( |
74 new SandboxedExtensionUnpacker( | 79 new SandboxedExtensionUnpacker( |
75 source_file, | 80 source_file, |
| 81 user_data_temp_dir, |
76 g_browser_process->resource_dispatcher_host(), | 82 g_browser_process->resource_dispatcher_host(), |
77 this)); | 83 this)); |
78 | 84 |
79 if (force_web_origin_to_download_url_ && original_url_.is_valid()) { | 85 if (force_web_origin_to_download_url_ && original_url_.is_valid()) { |
80 unpacker->set_web_origin(original_url_.GetOrigin()); | 86 unpacker->set_web_origin(original_url_.GetOrigin()); |
81 } | 87 } |
82 | 88 |
83 ChromeThread::PostTask( | 89 ChromeThread::PostTask( |
84 ChromeThread::FILE, FROM_HERE, | 90 ChromeThread::FILE, FROM_HERE, |
85 NewRunnableMethod( | 91 NewRunnableMethod( |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 client_->OnInstallSuccess(extension_.get()); | 332 client_->OnInstallSuccess(extension_.get()); |
327 | 333 |
328 // Tell the frontend about the installation and hand off ownership of | 334 // Tell the frontend about the installation and hand off ownership of |
329 // extension_ to it. | 335 // extension_ to it. |
330 frontend_->OnExtensionInstalled(extension_.release(), | 336 frontend_->OnExtensionInstalled(extension_.release(), |
331 allow_privilege_increase_); | 337 allow_privilege_increase_); |
332 | 338 |
333 // We're done. We don't post any more tasks to ourselves so we are deleted | 339 // We're done. We don't post any more tasks to ourselves so we are deleted |
334 // soon. | 340 // soon. |
335 } | 341 } |
OLD | NEW |