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

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

Issue 1278003: Rework ordering in ExtensionsService::UninstallExtension() (Closed)
Patch Set: Updates. Created 10 years, 9 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
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extensions_service.h" 5 #include "chrome/browser/extensions/extensions_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 LoadExtension(path); 263 LoadExtension(path);
264 } 264 }
265 } 265 }
266 266
267 void ExtensionsService::UninstallExtension(const std::string& extension_id, 267 void ExtensionsService::UninstallExtension(const std::string& extension_id,
268 bool external_uninstall) { 268 bool external_uninstall) {
269 Extension* extension = GetExtensionByIdInternal(extension_id, true, true); 269 Extension* extension = GetExtensionByIdInternal(extension_id, true, true);
270 270
271 // Callers should not send us nonexistant extensions. 271 // Callers should not send us nonexistant extensions.
272 DCHECK(extension); 272 DCHECK(extension);
273
274 // Get hold of information we need after unloading, since the extension
275 // pointer will be invalid then.
273 GURL extension_url(extension->url()); 276 GURL extension_url(extension->url());
277 Extension::Location location(extension->location());
274 278
275 extension_prefs_->OnExtensionUninstalled(extension, external_uninstall); 279 // Also copy the extension identifier since the reference might have been
280 // obtained via Extension::id().
281 std::string extension_id_copy(extension_id);
282
283 // Unload before doing more cleanup to ensure that nothing is hanging on to
284 // any of these resources.
285 UnloadExtension(extension_id);
286
287 extension_prefs_->OnExtensionUninstalled(extension_id_copy, location,
288 external_uninstall);
276 289
277 // Tell the backend to start deleting installed extensions on the file thread. 290 // Tell the backend to start deleting installed extensions on the file thread.
278 if (Extension::LOAD != extension->location()) { 291 if (Extension::LOAD != location) {
279 ChromeThread::PostTask( 292 ChromeThread::PostTask(
280 ChromeThread::FILE, FROM_HERE, 293 ChromeThread::FILE, FROM_HERE,
281 NewRunnableFunction( 294 NewRunnableFunction(
282 &extension_file_util::UninstallExtension, extension_id, 295 &extension_file_util::UninstallExtension, extension_id_copy,
283 install_directory_)); 296 install_directory_));
284 } 297 }
285 298
286 ExtensionDOMUI::UnregisterChromeURLOverrides(profile_,
287 extension->GetChromeURLOverrides());
288
289 // TODO(mnissler, erikkay) Check whether we should really unload the extension
290 // first, so we we're sure it's not running while we clean up.
291 UnloadExtension(extension_id);
292
293 ClearExtensionData(extension_url); 299 ClearExtensionData(extension_url);
294 } 300 }
295 301
296 void ExtensionsService::ClearExtensionData(const GURL& extension_url) { 302 void ExtensionsService::ClearExtensionData(const GURL& extension_url) {
297 scoped_refptr<ExtensionDataDeleter> deleter( 303 scoped_refptr<ExtensionDataDeleter> deleter(
298 new ExtensionDataDeleter(profile_, extension_url)); 304 new ExtensionDataDeleter(profile_, extension_url));
299 deleter->StartDeleting(); 305 deleter->StartDeleting();
300 } 306 }
301 307
302 void ExtensionsService::EnableExtension(const std::string& extension_id) { 308 void ExtensionsService::EnableExtension(const std::string& extension_id) {
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 // Finish installing on UI thread. 1168 // Finish installing on UI thread.
1163 ChromeThread::PostTask( 1169 ChromeThread::PostTask(
1164 ChromeThread::UI, FROM_HERE, 1170 ChromeThread::UI, FROM_HERE,
1165 NewRunnableMethod( 1171 NewRunnableMethod(
1166 frontend_, 1172 frontend_,
1167 &ExtensionsService::ContinueLoadAllExtensions, 1173 &ExtensionsService::ContinueLoadAllExtensions,
1168 extensions_to_reload, 1174 extensions_to_reload,
1169 start_time, 1175 start_time,
1170 true)); 1176 true));
1171 } 1177 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698