[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();
+}
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 8ee8538..1c5005e 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -317,9 +317,6 @@
   // Check for updates (or potentially new extensions from external providers)
   void CheckForExternalUpdates();
 
-  // Called when the initial extensions load has completed.
-  virtual void OnLoadedInstalledExtensions();
-
   // Informs the service that an extension's files are in place for loading.
   //
   // |extension|     the extension
@@ -587,6 +584,9 @@
       const base::FilePath& install_dir,
       const base::FilePath& extension_path);
 
+  // Called when the initial extensions load has completed.
+  void OnInstalledExtensionsLoaded();
+
   const base::CommandLine* command_line_ = nullptr;
 
   // The normal profile associated with this ExtensionService.
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 89c0e9c..6e3e7e3 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -5019,7 +5019,7 @@
 
     // Should still be at 0.
     loaded_.clear();
-    extensions::InstalledLoader(service()).LoadAllExtensions();
+    service()->ReloadExtensionsForTest();
     content::RunAllBlockingPoolTasksUntilIdle();
     ASSERT_EQ(0u, loaded_.size());
     ValidatePrefKeyCount(1);
diff --git a/chrome/browser/extensions/installed_loader.cc b/chrome/browser/extensions/installed_loader.cc
index 9e7a70d..87879a3 100644
--- a/chrome/browser/extensions/installed_loader.cc
+++ b/chrome/browser/extensions/installed_loader.cc
@@ -311,8 +311,6 @@
       Load(*extensions_info->at(i), should_write_prefs);
   }
 
-  extension_service_->OnLoadedInstalledExtensions();
-
   // The histograms Extensions.ManifestReload* allow us to validate
   // the assumption that reloading manifest is a rare event.
   UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadNotNeeded",