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

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

Issue 2409443002: Make GlobalErrorService's ownership model slightly less insane. (Closed)
Patch Set: windows, ownership Created 4 years, 2 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
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/extension_disabled_ui.h" 5 #include "chrome/browser/extensions/extension_disabled_ui.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 424 }
425 425
426 void ExtensionDisabledGlobalError::OnShutdown( 426 void ExtensionDisabledGlobalError::OnShutdown(
427 extensions::ExtensionRegistry* registry) { 427 extensions::ExtensionRegistry* registry) {
428 DCHECK_EQ(extensions::ExtensionRegistry::Get(service_->profile()), registry); 428 DCHECK_EQ(extensions::ExtensionRegistry::Get(service_->profile()), registry);
429 registry_observer_.RemoveAll(); 429 registry_observer_.RemoveAll();
430 } 430 }
431 431
432 void ExtensionDisabledGlobalError::RemoveGlobalError() { 432 void ExtensionDisabledGlobalError::RemoveGlobalError() {
433 GlobalErrorServiceFactory::GetForProfile(service_->profile()) 433 GlobalErrorServiceFactory::GetForProfile(service_->profile())
434 ->RemoveGlobalError(this); 434 ->RemoveOwnedGlobalError(this).release();
Nico 2016/10/10 14:03:37 Hm, I think this'd be nicer if it stored the resul
Avi (use Gerrit) 2016/10/10 16:52:36 Done.
435 registrar_.RemoveAll(); 435 registrar_.RemoveAll();
436 registry_observer_.RemoveAll(); 436 registry_observer_.RemoveAll();
437 // Delete this object after any running tasks, so that the extension dialog 437 // Delete this object after any running tasks, so that the extension dialog
438 // still has it as a delegate to finish the current tasks. 438 // still has it as a delegate to finish the current tasks.
439 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 439 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
440 } 440 }
441 441
442 // Globals -------------------------------------------------------------------- 442 // Globals --------------------------------------------------------------------
443 443
444 namespace extensions { 444 namespace extensions {
445 445
446 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, 446 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service,
447 const std::string& extension_id, 447 const std::string& extension_id,
448 bool is_remote_install, 448 bool is_remote_install,
449 const gfx::Image& icon) { 449 const gfx::Image& icon) {
450 if (!service.get()) 450 if (!service.get())
451 return; 451 return;
452 const Extension* extension = service->GetInstalledExtension(extension_id); 452 const Extension* extension = service->GetInstalledExtension(extension_id);
453 if (extension) { 453 if (extension) {
454 GlobalErrorServiceFactory::GetForProfile(service->profile()) 454 GlobalErrorServiceFactory::GetForProfile(service->profile())
455 ->AddGlobalError(new ExtensionDisabledGlobalError( 455 ->AddOwnedGlobalError(base::MakeUnique<ExtensionDisabledGlobalError>(
456 service.get(), extension, is_remote_install, icon)); 456 service.get(), extension, is_remote_install, icon));
457 } 457 }
458 } 458 }
459 459
460 void AddExtensionDisabledError(ExtensionService* service, 460 void AddExtensionDisabledError(ExtensionService* service,
461 const Extension* extension, 461 const Extension* extension,
462 bool is_remote_install) { 462 bool is_remote_install) {
463 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource( 463 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource(
464 extension, kIconSize, ExtensionIconSet::MATCH_BIGGER); 464 extension, kIconSize, ExtensionIconSet::MATCH_BIGGER);
465 gfx::Size size(kIconSize, kIconSize); 465 gfx::Size size(kIconSize, kIconSize);
(...skipping 11 matching lines...) Expand all
477 content::WebContents* web_contents, 477 content::WebContents* web_contents,
478 const Extension* extension) { 478 const Extension* extension) {
479 std::unique_ptr<ExtensionInstallPrompt> install_ui( 479 std::unique_ptr<ExtensionInstallPrompt> install_ui(
480 new ExtensionInstallPrompt(web_contents)); 480 new ExtensionInstallPrompt(web_contents));
481 // This object manages its own lifetime. 481 // This object manages its own lifetime.
482 new ExtensionDisabledDialogDelegate(service, std::move(install_ui), 482 new ExtensionDisabledDialogDelegate(service, std::move(install_ui),
483 extension); 483 extension);
484 } 484 }
485 485
486 } // namespace extensions 486 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698