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

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

Issue 2893693002: Remove NOTIFICATION_EXTENSION_ENABLED. (Closed)
Patch Set: address comments Created 3 years, 6 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_service.h ('k') | chrome/browser/themes/theme_service.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "content/public/browser/render_process_host.h" 72 #include "content/public/browser/render_process_host.h"
73 #include "content/public/browser/storage_partition.h" 73 #include "content/public/browser/storage_partition.h"
74 #include "extensions/browser/app_sorting.h" 74 #include "extensions/browser/app_sorting.h"
75 #include "extensions/browser/event_router.h" 75 #include "extensions/browser/event_router.h"
76 #include "extensions/browser/extension_host.h" 76 #include "extensions/browser/extension_host.h"
77 #include "extensions/browser/extension_registry.h" 77 #include "extensions/browser/extension_registry.h"
78 #include "extensions/browser/extension_system.h" 78 #include "extensions/browser/extension_system.h"
79 #include "extensions/browser/extensions_browser_client.h" 79 #include "extensions/browser/extensions_browser_client.h"
80 #include "extensions/browser/external_install_info.h" 80 #include "extensions/browser/external_install_info.h"
81 #include "extensions/browser/install_flag.h" 81 #include "extensions/browser/install_flag.h"
82 #include "extensions/browser/lazy_background_task_queue.h"
82 #include "extensions/browser/renderer_startup_helper.h" 83 #include "extensions/browser/renderer_startup_helper.h"
83 #include "extensions/browser/runtime_data.h" 84 #include "extensions/browser/runtime_data.h"
84 #include "extensions/browser/uninstall_reason.h" 85 #include "extensions/browser/uninstall_reason.h"
85 #include "extensions/browser/update_observer.h" 86 #include "extensions/browser/update_observer.h"
86 #include "extensions/browser/updater/extension_cache.h" 87 #include "extensions/browser/updater/extension_cache.h"
87 #include "extensions/browser/updater/extension_downloader.h" 88 #include "extensions/browser/updater/extension_downloader.h"
88 #include "extensions/common/extension_messages.h" 89 #include "extensions/common/extension_messages.h"
89 #include "extensions/common/extension_urls.h" 90 #include "extensions/common/extension_urls.h"
90 #include "extensions/common/feature_switch.h" 91 #include "extensions/common/feature_switch.h"
91 #include "extensions/common/features/feature_channel.h" 92 #include "extensions/common/features/feature_channel.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 138
138 namespace { 139 namespace {
139 140
140 // Wait this many seconds after an extensions becomes idle before updating it. 141 // Wait this many seconds after an extensions becomes idle before updating it.
141 const int kUpdateIdleDelay = 5; 142 const int kUpdateIdleDelay = 5;
142 143
143 // Comma-separated list of directories with extensions to load. 144 // Comma-separated list of directories with extensions to load.
144 // TODO(samuong): Remove this in M58 (see comment in ExtensionService::Init). 145 // TODO(samuong): Remove this in M58 (see comment in ExtensionService::Init).
145 const char kDeprecatedLoadComponentExtension[] = "load-component-extension"; 146 const char kDeprecatedLoadComponentExtension[] = "load-component-extension";
146 147
148 void DoNothingWithExtensionHost(extensions::ExtensionHost* host) {}
149
147 } // namespace 150 } // namespace
148 151
149 // ExtensionService. 152 // ExtensionService.
150 153
151 void ExtensionService::CheckExternalUninstall(const std::string& id) { 154 void ExtensionService::CheckExternalUninstall(const std::string& id) {
152 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 155 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
153 156
154 // Check if the providers know about this extension. 157 // Check if the providers know about this extension.
155 for (const auto& provider : external_extension_providers_) { 158 for (const auto& provider : external_extension_providers_) {
156 DCHECK(provider->IsReady()); 159 DCHECK(provider->IsReady());
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 // This can happen if sync enables an extension that is not installed yet. 920 // This can happen if sync enables an extension that is not installed yet.
918 if (!extension) 921 if (!extension)
919 return; 922 return;
920 923
921 // Move it over to the enabled list. 924 // Move it over to the enabled list.
922 registry_->AddEnabled(make_scoped_refptr(extension)); 925 registry_->AddEnabled(make_scoped_refptr(extension));
923 registry_->RemoveDisabled(extension->id()); 926 registry_->RemoveDisabled(extension->id());
924 927
925 NotifyExtensionLoaded(extension); 928 NotifyExtensionLoaded(extension);
926 929
927 // Notify listeners that the extension was enabled. 930 MaybeSpinUpLazyBackgroundPage(extension);
928 content::NotificationService::current()->Notify(
929 extensions::NOTIFICATION_EXTENSION_ENABLED,
930 content::Source<Profile>(profile_),
931 content::Details<const Extension>(extension));
932 } 931 }
933 932
934 void ExtensionService::DisableExtension(const std::string& extension_id, 933 void ExtensionService::DisableExtension(const std::string& extension_id,
935 int disable_reasons) { 934 int disable_reasons) {
936 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 935 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
937 936
938 if (extension_prefs_->IsExtensionBlacklisted(extension_id)) 937 if (extension_prefs_->IsExtensionBlacklisted(extension_id))
939 return; 938 return;
940 939
941 // The extension may have been disabled already. Just add the disable reasons. 940 // The extension may have been disabled already. Just add the disable reasons.
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2550 for (const auto& extension : registry_->disabled_extensions()) { 2549 for (const auto& extension : registry_->disabled_extensions()) {
2551 if (SharedModuleInfo::IsSharedModule(extension.get())) 2550 if (SharedModuleInfo::IsSharedModule(extension.get()))
2552 to_enable.push_back(extension); 2551 to_enable.push_back(extension);
2553 } 2552 }
2554 for (const auto& extension : to_enable) { 2553 for (const auto& extension : to_enable) {
2555 EnableExtension(extension->id()); 2554 EnableExtension(extension->id());
2556 } 2555 }
2557 2556
2558 OnBlacklistUpdated(); 2557 OnBlacklistUpdated();
2559 } 2558 }
2559
2560 void ExtensionService::MaybeSpinUpLazyBackgroundPage(
2561 const Extension* extension) {
2562 if (!extensions::BackgroundInfo::HasLazyBackgroundPage(extension))
2563 return;
2564
2565 // For orphaned devtools, we will reconnect devtools to it later in
2566 // DidCreateRenderViewForBackgroundPage().
2567 OrphanedDevTools::iterator iter = orphaned_dev_tools_.find(extension->id());
2568 bool has_orphaned_dev_tools = iter != orphaned_dev_tools_.end();
2569
2570 // Reloading component extension does not trigger install, so RuntimeAPI won't
2571 // be able to detect its loading. Therefore, we need to spin up its lazy
2572 // background page.
2573 bool is_component_extension =
2574 Manifest::IsComponentLocation(extension->location());
2575
2576 if (!has_orphaned_dev_tools && !is_component_extension)
2577 return;
2578
2579 // Wake up the event page by posting a dummy task.
2580 extensions::LazyBackgroundTaskQueue* queue =
2581 extensions::LazyBackgroundTaskQueue::Get(profile_);
2582 queue->AddPendingTask(profile_, extension->id(),
2583 base::Bind(&DoNothingWithExtensionHost));
2584 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/themes/theme_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698