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

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

Issue 2409443002: Make GlobalErrorService's ownership model slightly less insane. (Closed)
Patch Set: less 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 RemoveGlobalError(); 423 RemoveGlobalError();
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 std::unique_ptr<GlobalError> ptr =
434 ->RemoveGlobalError(this); 434 GlobalErrorServiceFactory::GetForProfile(service_->profile())
435 ->RemoveOwnedGlobalError(this);
435 registrar_.RemoveAll(); 436 registrar_.RemoveAll();
436 registry_observer_.RemoveAll(); 437 registry_observer_.RemoveAll();
437 // Delete this object after any running tasks, so that the extension dialog 438 // Delete this object after any running tasks, so that the extension dialog
438 // still has it as a delegate to finish the current tasks. 439 // still has it as a delegate to finish the current tasks.
439 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 440 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, ptr.release());
440 } 441 }
441 442
442 // Globals -------------------------------------------------------------------- 443 // Globals --------------------------------------------------------------------
443 444
444 namespace extensions { 445 namespace extensions {
445 446
446 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, 447 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service,
447 const std::string& extension_id, 448 const std::string& extension_id,
448 bool is_remote_install, 449 bool is_remote_install,
449 const gfx::Image& icon) { 450 const gfx::Image& icon) {
450 if (!service.get()) 451 if (!service.get())
451 return; 452 return;
452 const Extension* extension = service->GetInstalledExtension(extension_id); 453 const Extension* extension = service->GetInstalledExtension(extension_id);
453 if (extension) { 454 if (extension) {
454 GlobalErrorServiceFactory::GetForProfile(service->profile()) 455 GlobalErrorServiceFactory::GetForProfile(service->profile())
455 ->AddGlobalError(new ExtensionDisabledGlobalError( 456 ->AddOwnedGlobalError(base::MakeUnique<ExtensionDisabledGlobalError>(
456 service.get(), extension, is_remote_install, icon)); 457 service.get(), extension, is_remote_install, icon));
457 } 458 }
458 } 459 }
459 460
460 void AddExtensionDisabledError(ExtensionService* service, 461 void AddExtensionDisabledError(ExtensionService* service,
461 const Extension* extension, 462 const Extension* extension,
462 bool is_remote_install) { 463 bool is_remote_install) {
463 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource( 464 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource(
464 extension, kIconSize, ExtensionIconSet::MATCH_BIGGER); 465 extension, kIconSize, ExtensionIconSet::MATCH_BIGGER);
465 gfx::Size size(kIconSize, kIconSize); 466 gfx::Size size(kIconSize, kIconSize);
(...skipping 11 matching lines...) Expand all
477 content::WebContents* web_contents, 478 content::WebContents* web_contents,
478 const Extension* extension) { 479 const Extension* extension) {
479 std::unique_ptr<ExtensionInstallPrompt> install_ui( 480 std::unique_ptr<ExtensionInstallPrompt> install_ui(
480 new ExtensionInstallPrompt(web_contents)); 481 new ExtensionInstallPrompt(web_contents));
481 // This object manages its own lifetime. 482 // This object manages its own lifetime.
482 new ExtensionDisabledDialogDelegate(service, std::move(install_ui), 483 new ExtensionDisabledDialogDelegate(service, std::move(install_ui),
483 extension); 484 extension);
484 } 485 }
485 486
486 } // namespace extensions 487 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698