[Extensions] Simplify OnLoadedInstalledExtensions calls
InstalledLoader calls ExtensionService::OnLoadedInstalledExtensions()
at the completion of LoadAllExtensions(), but since
LoadAllExtensions() is synchronous, we can just call
OnLoadedInstalledExtensions() directly from ExtensionService. This
avoids a weird branch (where we don't call LoadAllExtensions()) and lets
us make OnLoadedInstalledExtensions private.
Also de-virtual OnLoadedInstalledExtensions(), since it was never
overridden.
BUG=None
Review-Url: https://codereview.chromium.org/2905003002
Cr-Commit-Position: refs/heads/master@{#475204}
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 33d5dfbf..8654385 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -451,16 +451,11 @@
load_command_line_extensions = false;
}
#endif
- if (load_saved_extensions) {
+ if (load_saved_extensions)
extensions::InstalledLoader(this).LoadAllExtensions();
- } else {
- // InstalledLoader::LoadAllExtensions normally calls
- // OnLoadedInstalledExtensions itself, but here we circumvent that path.
- // Call OnLoadedInstalledExtensions directly.
- // TODO(devlin): LoadInstalledExtensions() is synchronous - we can simplify
- // this.
- OnLoadedInstalledExtensions();
- }
+
+ OnInstalledExtensionsLoaded();
+
LoadExtensionsFromCommandLineFlag(switches::kDisableExtensionsExcept);
if (load_command_line_extensions)
LoadExtensionsFromCommandLineFlag(switches::kLoadExtension);
@@ -1455,6 +1450,7 @@
UnloadAllExtensionsInternal();
component_loader_->LoadAll();
extensions::InstalledLoader(this).LoadAllExtensions();
+ OnInstalledExtensionsLoaded();
// Don't call SetReadyAndNotifyListeners() since tests call this multiple
// times.
}
@@ -1472,25 +1468,6 @@
content::NotificationService::NoDetails());
}
-void ExtensionService::OnLoadedInstalledExtensions() {
- if (updater_)
- updater_->Start();
-
- // Enable any Shared Modules that incorrectly got disabled previously.
- // This is temporary code to fix incorrect behavior from previous versions of
- // Chrome and can be removed after several releases (perhaps M60).
- extensions::ExtensionList to_enable;
- for (const auto& extension : registry_->disabled_extensions()) {
- if (SharedModuleInfo::IsSharedModule(extension.get()))
- to_enable.push_back(extension);
- }
- for (const auto& extension : to_enable) {
- EnableExtension(extension->id());
- }
-
- OnBlacklistUpdated();
-}
-
void ExtensionService::AddExtension(const Extension* extension) {
if (!Manifest::IsValidLocation(extension->location())) {
// TODO(devlin): We should *never* add an extension with an invalid
@@ -2561,3 +2538,22 @@
UnloadExtension(*it, UnloadedExtensionReason::PROFILE_SHUTDOWN);
}
}
+
+void ExtensionService::OnInstalledExtensionsLoaded() {
+ if (updater_)
+ updater_->Start();
+
+ // Enable any Shared Modules that incorrectly got disabled previously.
+ // This is temporary code to fix incorrect behavior from previous versions of
+ // Chrome and can be removed after several releases (perhaps M60).
+ extensions::ExtensionList to_enable;
+ for (const auto& extension : registry_->disabled_extensions()) {
+ if (SharedModuleInfo::IsSharedModule(extension.get()))
+ to_enable.push_back(extension);
+ }
+ for (const auto& extension : to_enable) {
+ EnableExtension(extension->id());
+ }
+
+ OnBlacklistUpdated();
+}