Revert changes to have ExtensionService notify ThemeService directly

This reverts r159875 and r170640.  It cause a performance regression
that's not easy to fix, as detailed in the bug.

BUG=163706
[email protected],[email protected],[email protected]

Review URL: https://codereview.chromium.org/11416324

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170824 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 97087335..a10372ec 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -80,6 +80,8 @@
 #include "chrome/browser/profiles/profile_manager.h"
 #include "chrome/browser/search_engines/template_url_service.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/themes/theme_service_factory.h"
 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
 #include "chrome/browser/ui/webui/favicon_source.h"
 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
@@ -116,11 +118,6 @@
 #include "webkit/database/database_tracker.h"
 #include "webkit/database/database_util.h"
 
-#if defined(ENABLE_THEMES)
-#include "chrome/browser/themes/theme_service.h"
-#include "chrome/browser/themes/theme_service_factory.h"
-#endif
-
 #if defined(OS_CHROMEOS)
 #include "chrome/browser/chromeos/cros/cros_library.h"
 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
@@ -1034,9 +1031,9 @@
   // extension.
   system_->RegisterExtensionWithRequestContexts(extension);
 
+  // Tell renderers about the new extension, unless it's a theme (renderers
+  // don't need to know about themes).
   if (!extension->is_theme()) {
-    // Tell renderers about non-theme extensions (renderers don't need
-    // to know about themes).
     for (content::RenderProcessHost::iterator i(
             content::RenderProcessHost::AllHostsIterator());
          !i.IsAtEnd(); i.Advance()) {
@@ -2029,7 +2026,7 @@
   // defensive; in the future, we may call GarbageCollectExtensions()
   // from somewhere other than Init() (e.g., in a timer).
   if (profile_) {
-    ThemeService::RemoveUnusedThemesForProfile(profile_);
+    ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes();
   }
 #endif
 }
@@ -2110,13 +2107,6 @@
   SyncExtensionChangeIfNeeded(*extension);
   NotifyExtensionLoaded(extension);
   DoPostLoadTasks(extension);
-
-#if defined(ENABLE_THEMES)
-  if (extension->is_theme()) {
-    // Notify the ThemeService about the newly-installed theme.
-    ThemeServiceFactory::SetThemeForProfile(profile_, extension);
-  }
-#endif
 }
 
 void ExtensionService::AddComponentExtension(const Extension* extension) {