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

Unified Diff: chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc

Issue 2803923002: [Media Router] Unload the legacy Cast extension at install (Closed)
Patch Set: Unload instead of uninstall Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc
diff --git a/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc b/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc
index 2167cdb386e96920e1575b308d6f3430ba8b048d..935907e3d68393c13dc98bd9efb25d0cadfa3199 100644
--- a/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc
+++ b/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_system.h"
#if defined(ENABLE_MEDIA_ROUTER)
#include "chrome/browser/ui/toolbar/media_router_action.h"
@@ -28,13 +29,17 @@ const char ComponentToolbarActionsFactory::kMediaRouterActionId[] =
"media_router_action";
ComponentToolbarActionsFactory::ComponentToolbarActionsFactory(Profile* profile)
- : profile_(profile) {
+ : profile_(profile),
+ extension_registry_(extensions::ExtensionRegistry::Get(profile)),
+ extension_system_(extensions::ExtensionSystem::Get(profile)),
+ extension_registry_observer_(this) {
#if defined(ENABLE_MEDIA_ROUTER)
if (media_router::MediaRouterEnabled(profile_) &&
MediaRouterActionController::IsActionShownByPolicy(profile_)) {
initial_ids_.insert(kMediaRouterActionId);
}
#endif
+ extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(profile));
}
ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {}
@@ -74,21 +79,27 @@ ComponentToolbarActionsFactory::GetComponentToolbarActionForId(
return std::unique_ptr<ToolbarActionViewController>();
}
-void ComponentToolbarActionsFactory::UnloadMigratedExtensions(
- ExtensionService* service,
- extensions::ExtensionRegistry* registry) {
- // TODO(takumif): Replace the unloading of Cast and Cast Beta extensions with
- // uninstallation.
- UnloadExtension(service, registry, kCastExtensionId);
- UnloadExtension(service, registry, kCastBetaExtensionId);
+void ComponentToolbarActionsFactory::UnloadMigratedExtensions() {
+ UnloadExtension(kCastExtensionId);
+ UnloadExtension(kCastBetaExtensionId);
+}
+
+void ComponentToolbarActionsFactory::OnExtensionInstalled(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ bool is_update) {
+ if (extension->id() == kCastExtensionId ||
+ extension->id() == kCastBetaExtensionId) {
+ UnloadExtension(extension->id());
+ }
}
void ComponentToolbarActionsFactory::UnloadExtension(
- ExtensionService* service,
- extensions::ExtensionRegistry* registry,
const std::string& extension_id) {
- if (registry->enabled_extensions().Contains(extension_id)) {
- service->UnloadExtension(
+ if (extension_registry_->GenerateInstalledExtensionsSet()->Contains(
+ extension_id)) {
+ DCHECK(extension_system_->extension_service());
+ extension_system_->extension_service()->UnloadExtension(
extension_id,
extensions::UnloadedExtensionInfo::REASON_MIGRATED_TO_COMPONENT);
}

Powered by Google App Engine
This is Rietveld 408576698