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

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

Issue 2409443002: Make GlobalErrorService's ownership model slightly less insane. (Closed)
Patch Set: commentary Created 4 years 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 | « no previous file | chrome/browser/extensions/external_install_error.cc » ('j') | 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) 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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 RemoveGlobalError(); 353 RemoveGlobalError();
354 } 354 }
355 355
356 void ExtensionDisabledGlobalError::OnShutdown( 356 void ExtensionDisabledGlobalError::OnShutdown(
357 extensions::ExtensionRegistry* registry) { 357 extensions::ExtensionRegistry* registry) {
358 DCHECK_EQ(extensions::ExtensionRegistry::Get(service_->profile()), registry); 358 DCHECK_EQ(extensions::ExtensionRegistry::Get(service_->profile()), registry);
359 registry_observer_.RemoveAll(); 359 registry_observer_.RemoveAll();
360 } 360 }
361 361
362 void ExtensionDisabledGlobalError::RemoveGlobalError() { 362 void ExtensionDisabledGlobalError::RemoveGlobalError() {
363 GlobalErrorServiceFactory::GetForProfile(service_->profile()) 363 std::unique_ptr<GlobalError> ptr =
364 ->RemoveGlobalError(this); 364 GlobalErrorServiceFactory::GetForProfile(service_->profile())
365 ->RemoveGlobalError(this);
365 registrar_.RemoveAll(); 366 registrar_.RemoveAll();
366 registry_observer_.RemoveAll(); 367 registry_observer_.RemoveAll();
367 // Delete this object after any running tasks, so that the extension dialog 368 // Delete this object after any running tasks, so that the extension dialog
368 // still has it as a delegate to finish the current tasks. 369 // still has it as a delegate to finish the current tasks.
369 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 370 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, ptr.release());
370 } 371 }
371 372
372 // Globals -------------------------------------------------------------------- 373 // Globals --------------------------------------------------------------------
373 374
374 namespace extensions { 375 namespace extensions {
375 376
376 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, 377 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service,
377 const std::string& extension_id, 378 const std::string& extension_id,
378 bool is_remote_install, 379 bool is_remote_install,
379 const gfx::Image& icon) { 380 const gfx::Image& icon) {
380 if (!service.get()) 381 if (!service.get())
381 return; 382 return;
382 const Extension* extension = service->GetInstalledExtension(extension_id); 383 const Extension* extension = service->GetInstalledExtension(extension_id);
383 if (extension) { 384 if (extension) {
384 GlobalErrorServiceFactory::GetForProfile(service->profile()) 385 GlobalErrorServiceFactory::GetForProfile(service->profile())
385 ->AddGlobalError(new ExtensionDisabledGlobalError( 386 ->AddGlobalError(base::MakeUnique<ExtensionDisabledGlobalError>(
386 service.get(), extension, is_remote_install, icon)); 387 service.get(), extension, is_remote_install, icon));
387 } 388 }
388 } 389 }
389 390
390 void AddExtensionDisabledError(ExtensionService* service, 391 void AddExtensionDisabledError(ExtensionService* service,
391 const Extension* extension, 392 const Extension* extension,
392 bool is_remote_install) { 393 bool is_remote_install) {
393 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource( 394 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource(
394 extension, kIconSize, ExtensionIconSet::MATCH_BIGGER); 395 extension, kIconSize, ExtensionIconSet::MATCH_BIGGER);
395 gfx::Size size(kIconSize, kIconSize); 396 gfx::Size size(kIconSize, kIconSize);
396 ImageLoader::Get(service->profile()) 397 ImageLoader::Get(service->profile())
397 ->LoadImageAsync(extension, 398 ->LoadImageAsync(extension,
398 image, 399 image,
399 size, 400 size,
400 base::Bind(&AddExtensionDisabledErrorWithIcon, 401 base::Bind(&AddExtensionDisabledErrorWithIcon,
401 service->AsWeakPtr(), 402 service->AsWeakPtr(),
402 extension->id(), 403 extension->id(),
403 is_remote_install)); 404 is_remote_install));
404 } 405 }
405 406
406 } // namespace extensions 407 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/external_install_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698