Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Side by Side Diff: chrome/browser/extensions/crx_installer.cc

Issue 9150016: Move creation and ownership of ResourceDispatcherHost and PluginService to content. This gives a ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/extensions/default_apps_trial.h" 26 #include "chrome/browser/extensions/default_apps_trial.h"
27 #include "chrome/browser/extensions/extension_error_reporter.h" 27 #include "chrome/browser/extensions/extension_error_reporter.h"
28 #include "chrome/browser/extensions/extension_service.h" 28 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/extensions/permissions_updater.h" 29 #include "chrome/browser/extensions/permissions_updater.h"
30 #include "chrome/browser/shell_integration.h" 30 #include "chrome/browser/shell_integration.h"
31 #include "chrome/browser/web_applications/web_app.h" 31 #include "chrome/browser/web_applications/web_app.h"
32 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
33 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/extensions/extension_constants.h" 34 #include "chrome/common/extensions/extension_constants.h"
35 #include "chrome/common/extensions/extension_file_util.h" 35 #include "chrome/common/extensions/extension_file_util.h"
36 #include "content/browser/renderer_host/resource_dispatcher_host.h"
36 #include "content/public/browser/browser_thread.h" 37 #include "content/public/browser/browser_thread.h"
37 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/user_metrics.h" 39 #include "content/public/browser/user_metrics.h"
39 #include "grit/chromium_strings.h" 40 #include "grit/chromium_strings.h"
40 #include "grit/generated_resources.h" 41 #include "grit/generated_resources.h"
41 #include "grit/theme_resources.h" 42 #include "grit/theme_resources.h"
42 #include "third_party/skia/include/core/SkBitmap.h" 43 #include "third_party/skia/include/core/SkBitmap.h"
43 #include "ui/base/l10n/l10n_util.h" 44 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/base/resource/resource_bundle.h" 45 #include "ui/base/resource/resource_bundle.h"
45 46
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 install_source_(Extension::INTERNAL), 135 install_source_(Extension::INTERNAL),
135 extensions_enabled_(frontend_weak->extensions_enabled()), 136 extensions_enabled_(frontend_weak->extensions_enabled()),
136 delete_source_(false), 137 delete_source_(false),
137 create_app_shortcut_(false), 138 create_app_shortcut_(false),
138 frontend_weak_(frontend_weak), 139 frontend_weak_(frontend_weak),
139 profile_(frontend_weak->profile()), 140 profile_(frontend_weak->profile()),
140 client_(client), 141 client_(client),
141 apps_require_extension_mime_type_(false), 142 apps_require_extension_mime_type_(false),
142 allow_silent_install_(false), 143 allow_silent_install_(false),
143 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), 144 install_cause_(extension_misc::INSTALL_CAUSE_UNSET),
144 creation_flags_(Extension::NO_FLAGS) { 145 creation_flags_(Extension::NO_FLAGS),
146 use_utility_process_(true) {
145 } 147 }
146 148
147 CrxInstaller::~CrxInstaller() { 149 CrxInstaller::~CrxInstaller() {
148 // Delete the temp directory and crx file as necessary. Note that the 150 // Delete the temp directory and crx file as necessary. Note that the
149 // destructor might be called on any thread, so we post a task to the file 151 // destructor might be called on any thread, so we post a task to the file
150 // thread to make sure the delete happens there. This is a best effort 152 // thread to make sure the delete happens there. This is a best effort
151 // operation since the browser can be shutting down so there might not 153 // operation since the browser can be shutting down so there might not
152 // be a file thread to post to. 154 // be a file thread to post to.
153 if (!temp_dir_.value().empty()) { 155 if (!temp_dir_.value().empty()) {
154 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 156 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
155 base::Bind(&extension_file_util::DeleteFile, temp_dir_, true)); 157 base::Bind(&extension_file_util::DeleteFile, temp_dir_, true));
156 } 158 }
157 if (delete_source_) { 159 if (delete_source_) {
158 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 160 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
159 base::Bind(&extension_file_util::DeleteFile, source_file_, false)); 161 base::Bind(&extension_file_util::DeleteFile, source_file_, false));
160 } 162 }
161 // Make sure the UI is deleted on the ui thread. 163 // Make sure the UI is deleted on the ui thread.
162 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, client_); 164 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, client_);
163 client_ = NULL; 165 client_ = NULL;
164 } 166 }
165 167
166 void CrxInstaller::InstallCrx(const FilePath& source_file) { 168 void CrxInstaller::InstallCrx(const FilePath& source_file) {
167 source_file_ = source_file; 169 source_file_ = source_file;
168 170
169 scoped_refptr<SandboxedExtensionUnpacker> unpacker( 171 scoped_refptr<SandboxedExtensionUnpacker> unpacker(
170 new SandboxedExtensionUnpacker( 172 new SandboxedExtensionUnpacker(
171 source_file, 173 source_file,
172 g_browser_process->resource_dispatcher_host(),
173 install_source_, 174 install_source_,
174 creation_flags_, 175 creation_flags_,
175 this)); 176 this));
177 unpacker->set_use_utility_process(use_utility_process_);
176 178
177 if (!BrowserThread::PostTask( 179 if (!BrowserThread::PostTask(
178 BrowserThread::FILE, FROM_HERE, 180 BrowserThread::FILE, FROM_HERE,
179 base::Bind( 181 base::Bind(
180 &SandboxedExtensionUnpacker::Start, unpacker.get()))) 182 &SandboxedExtensionUnpacker::Start, unpacker.get())))
181 NOTREACHED(); 183 NOTREACHED();
182 } 184 }
183 185
184 void CrxInstaller::InstallUserScript(const FilePath& source_file, 186 void CrxInstaller::InstallUserScript(const FilePath& source_file,
185 const GURL& download_url) { 187 const GURL& download_url) {
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 // Some users (such as the download shelf) need to know when a 608 // Some users (such as the download shelf) need to know when a
607 // CRXInstaller is done. Listening for the EXTENSION_* events 609 // CRXInstaller is done. Listening for the EXTENSION_* events
608 // is problematic because they don't know anything about the 610 // is problematic because they don't know anything about the
609 // extension before it is unpacked, so they cannot filter based 611 // extension before it is unpacked, so they cannot filter based
610 // on the extension. 612 // on the extension.
611 content::NotificationService::current()->Notify( 613 content::NotificationService::current()->Notify(
612 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 614 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
613 content::Source<CrxInstaller>(this), 615 content::Source<CrxInstaller>(this),
614 content::Details<const Extension>(extension)); 616 content::Details<const Extension>(extension));
615 } 617 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698