Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 // This can happen if sync enables an extension that is not installed yet. | 925 // This can happen if sync enables an extension that is not installed yet. |
| 923 if (!extension) | 926 if (!extension) |
| 924 return; | 927 return; |
| 925 | 928 |
| 926 // Move it over to the enabled list. | 929 // Move it over to the enabled list. |
| 927 registry_->AddEnabled(make_scoped_refptr(extension)); | 930 registry_->AddEnabled(make_scoped_refptr(extension)); |
| 928 registry_->RemoveDisabled(extension->id()); | 931 registry_->RemoveDisabled(extension->id()); |
| 929 | 932 |
| 930 NotifyExtensionLoaded(extension); | 933 NotifyExtensionLoaded(extension); |
| 931 | 934 |
| 932 // Notify listeners that the extension was enabled. | 935 MaybeReconnectDevtoolsToLazyBackgroundPage(extension); |
| 933 content::NotificationService::current()->Notify( | |
| 934 extensions::NOTIFICATION_EXTENSION_ENABLED, | |
| 935 content::Source<Profile>(profile_), | |
| 936 content::Details<const Extension>(extension)); | |
| 937 } | 936 } |
| 938 | 937 |
| 939 void ExtensionService::DisableExtension(const std::string& extension_id, | 938 void ExtensionService::DisableExtension(const std::string& extension_id, |
| 940 int disable_reasons) { | 939 int disable_reasons) { |
| 941 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 940 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 942 | 941 |
| 943 if (extension_prefs_->IsExtensionBlacklisted(extension_id)) | 942 if (extension_prefs_->IsExtensionBlacklisted(extension_id)) |
| 944 return; | 943 return; |
| 945 | 944 |
| 946 // The extension may have been disabled already. Just add the disable reasons. | 945 // The extension may have been disabled already. Just add the disable reasons. |
| (...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2554 } | 2553 } |
| 2555 | 2554 |
| 2556 void ExtensionService::OnProfileDestructionStarted() { | 2555 void ExtensionService::OnProfileDestructionStarted() { |
| 2557 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2556 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2558 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2557 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2559 it != ids_to_unload.end(); | 2558 it != ids_to_unload.end(); |
| 2560 ++it) { | 2559 ++it) { |
| 2561 UnloadExtension(*it, UnloadedExtensionReason::PROFILE_SHUTDOWN); | 2560 UnloadExtension(*it, UnloadedExtensionReason::PROFILE_SHUTDOWN); |
| 2562 } | 2561 } |
| 2563 } | 2562 } |
| 2563 | |
| 2564 void ExtensionService::MaybeReconnectDevtoolsToLazyBackgroundPage( | |
| 2565 const Extension* extension) { | |
| 2566 OrphanedDevTools::iterator iter = orphaned_dev_tools_.find(extension->id()); | |
| 2567 if (iter == orphaned_dev_tools_.end()) | |
| 2568 return; | |
| 2569 if (extensions::BackgroundInfo::HasLazyBackgroundPage(extension)) { | |
|
Devlin
2017/05/23 21:30:36
Add a comment explaining this.
lazyboy
2017/05/23 23:19:08
Done.
| |
| 2570 extensions::LazyBackgroundTaskQueue* queue = | |
| 2571 extensions::LazyBackgroundTaskQueue::Get(profile_); | |
| 2572 queue->AddPendingTask(profile_, extension->id(), | |
| 2573 base::Bind(&DoNothingWithExtensionHost)); | |
| 2574 } | |
| 2575 } | |
| OLD | NEW |