Rename WebUIFactory to WebUIControllerFactory since that's what it creates now.

I've removed EmptyWebUIFactory, since that doesn't fit in well with Content API now. There were only a few places in the code that called it, and handling NULL wasn't much work.

BUG=98716
Review URL: https://chromiumcodereview.appspot.com/9288074

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119341 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index a37af6f..18daf98 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -53,7 +53,7 @@
 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
 #include "chrome/browser/tab_contents/tab_util.h"
 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 #include "chrome/browser/user_style_sheet_watcher.h"
 #include "chrome/common/child_process_logging.h"
 #include "chrome/common/chrome_constants.h"
@@ -140,7 +140,8 @@
 
 // Handles rewriting Web UI URLs.
 bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
-  if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(browser_context, *url))
+  if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
+          browser_context, *url))
     return false;
 
   // Special case the new tab page. In older versions of Chrome, the new tab
@@ -358,8 +359,9 @@
   host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
 }
 
-content::WebUIFactory* ChromeContentBrowserClient::GetWebUIFactory() {
-  return ChromeWebUIFactory::GetInstance();
+content::WebUIControllerFactory*
+    ChromeContentBrowserClient::GetWebUIControllerFactory() {
+  return ChromeWebUIControllerFactory::GetInstance();
 }
 
 GURL ChromeContentBrowserClient::GetEffectiveURL(
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index 7f74616..b097634 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -22,7 +22,7 @@
   virtual void RenderViewHostCreated(RenderViewHost* render_view_host) OVERRIDE;
   virtual void RenderProcessHostCreated(
       content::RenderProcessHost* host) OVERRIDE;
-  virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE;
+  virtual content::WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE;
   virtual bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
                                        const GURL& effective_url) OVERRIDE;
   virtual GURL GetEffectiveURL(content::BrowserContext* browser_context,
diff --git a/chrome/browser/extensions/extension_debugger_api.cc b/chrome/browser/extensions/extension_debugger_api.cc
index e71b237..bbe71a3c 100644
--- a/chrome/browser/extensions/extension_debugger_api.cc
+++ b/chrome/browser/extensions/extension_debugger_api.cc
@@ -22,7 +22,7 @@
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_error_utils.h"
@@ -377,7 +377,8 @@
   }
   contents_ = wrapper->web_contents();
 
-  if (ChromeWebUIFactory::GetInstance()->HasWebUIScheme(contents_->GetURL())) {
+  if (ChromeWebUIControllerFactory::GetInstance()->HasWebUIScheme(
+          contents_->GetURL())) {
     error_ = ExtensionErrorUtils::FormatErrorMessage(
         keys::kAttachToWebUIError,
         contents_->GetURL().scheme());
diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc
index f95e34fd..eea72f1 100644
--- a/chrome/browser/extensions/extension_web_ui.cc
+++ b/chrome/browser/extensions/extension_web_ui.cc
@@ -141,7 +141,7 @@
   bool should_hide_url = !extension->is_hosted_app();
 
   // The base class defaults to enabling WebUI bindings, but we don't need
-  // those (this is also reflected in ChromeWebUIFactory::
+  // those (this is also reflected in ChromeWebUIControllerFactory::
   // UseWebUIBindingsForURL).
   int bindings = 0;
 
diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc
index 52faaa3..f1ca5da 100644
--- a/chrome/browser/favicon/favicon_service.cc
+++ b/chrome/browser/favicon/favicon_service.cc
@@ -7,7 +7,7 @@
 #include "chrome/browser/history/history.h"
 #include "chrome/browser/history/history_backend.h"
 #include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 #include "chrome/common/url_constants.h"
 
 FaviconService::FaviconService(Profile* profile) : profile_(profile) {
@@ -54,7 +54,7 @@
   FaviconService::Handle handle = request->handle();
   if (page_url.SchemeIs(chrome::kChromeUIScheme) ||
       page_url.SchemeIs(chrome::kExtensionScheme)) {
-    ChromeWebUIFactory::GetInstance()->GetFaviconForURL(
+    ChromeWebUIControllerFactory::GetInstance()->GetFaviconForURL(
         profile_, request, page_url);
   } else {
     HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index aa2eb475..8a265e2 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -9,7 +9,7 @@
 #include "chrome/browser/renderer_preferences_util.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "chrome/common/extensions/extension_messages.h"
 #include "chrome/common/render_messages.h"
diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc
index 16d3dfe..14e1cad8 100644
--- a/chrome/browser/tab_contents/background_contents.cc
+++ b/chrome/browser/tab_contents/background_contents.cc
@@ -8,7 +8,7 @@
 #include "chrome/browser/extensions/extension_message_service.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/renderer_preferences_util.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "chrome/common/extensions/extension_constants.h"
 #include "chrome/common/url_constants.h"
diff --git a/chrome/browser/tab_contents/tab_util.cc b/chrome/browser/tab_contents/tab_util.cc
index 09461bee..da91a1a 100644
--- a/chrome/browser/tab_contents/tab_util.cc
+++ b/chrome/browser/tab_contents/tab_util.cc
@@ -6,7 +6,7 @@
 
 #include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 #include "chrome/common/chrome_switches.h"
 #include "content/browser/renderer_host/render_view_host.h"
 #include "content/public/browser/render_view_host_delegate.h"
@@ -36,7 +36,8 @@
   // of renderer process up front.  Otherwise, we create a normal SiteInstance
   // as part of creating the tab.
   ExtensionService* service = profile->GetExtensionService();
-  if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url) ||
+  if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
+          profile, url) ||
       (service &&
        service->extensions()->GetHostedAppByURL(ExtensionURLInfo(url)))) {
     return SiteInstance::CreateForURL(profile, url);
diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
similarity index 94%
rename from chrome/browser/ui/webui/chrome_web_ui_factory.cc
rename to chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index 059a1c1..f41f6e0 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 
 #include "base/command_line.h"
 #include "chrome/browser/about_flags.h"
@@ -44,7 +44,7 @@
 #include "chrome/browser/ui/webui/quota_internals_ui.h"
 #include "chrome/browser/ui/webui/sessions_ui.h"
 #include "chrome/browser/ui/webui/sync_internals_ui.h"
-#include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h"
 #include "chrome/browser/ui/webui/tracing_ui.h"
 #include "chrome/browser/ui/webui/uber/uber_ui.h"
 #include "chrome/browser/ui/webui/workers_ui.h"
@@ -363,19 +363,19 @@
 
 }  // namespace
 
-WebUI::TypeID ChromeWebUIFactory::GetWebUIType(
+WebUI::TypeID ChromeWebUIControllerFactory::GetWebUIType(
       content::BrowserContext* browser_context, const GURL& url) const {
   Profile* profile = Profile::FromBrowserContext(browser_context);
   WebUIFactoryFunction function = GetWebUIFactoryFunction(NULL, profile, url);
   return function ? reinterpret_cast<WebUI::TypeID>(function) : WebUI::kNoWebUI;
 }
 
-bool ChromeWebUIFactory::UseWebUIForURL(
+bool ChromeWebUIControllerFactory::UseWebUIForURL(
     content::BrowserContext* browser_context, const GURL& url) const {
   return GetWebUIType(browser_context, url) != WebUI::kNoWebUI;
 }
 
-bool ChromeWebUIFactory::UseWebUIBindingsForURL(
+bool ChromeWebUIControllerFactory::UseWebUIBindingsForURL(
     content::BrowserContext* browser_context, const GURL& url) const {
   // Extensions are rendered via WebUI in tabs, but don't actually need WebUI
   // bindings (see the ExtensionWebUI constructor).
@@ -385,13 +385,13 @@
       UseWebUIForURL(browser_context, url);
 }
 
-bool ChromeWebUIFactory::HasWebUIScheme(const GURL& url) const {
+bool ChromeWebUIControllerFactory::HasWebUIScheme(const GURL& url) const {
   return url.SchemeIs(chrome::kChromeDevToolsScheme) ||
          url.SchemeIs(chrome::kChromeInternalScheme) ||
          url.SchemeIs(chrome::kChromeUIScheme);
 }
 
-bool ChromeWebUIFactory::IsURLAcceptableForWebUI(
+bool ChromeWebUIControllerFactory::IsURLAcceptableForWebUI(
     content::BrowserContext* browser_context,
     const GURL& url) const {
   return UseWebUIForURL(browser_context, url) ||
@@ -407,7 +407,7 @@
       url == GURL(chrome::kChromeUIShorthangURL);
 }
 
-WebUIController* ChromeWebUIFactory::CreateWebUIForURL(
+WebUIController* ChromeWebUIControllerFactory::CreateWebUIControllerForURL(
     content::WebUI* web_ui,
     const GURL& url) const {
   Profile* profile = Profile::FromWebUI(web_ui);
@@ -419,7 +419,7 @@
   return (*function)(web_ui, url);
 }
 
-void ChromeWebUIFactory::GetFaviconForURL(
+void ChromeWebUIControllerFactory::GetFaviconForURL(
     Profile* profile,
     FaviconService::GetFaviconRequest* request,
     const GURL& page_url) const {
@@ -440,18 +440,18 @@
 }
 
 // static
-ChromeWebUIFactory* ChromeWebUIFactory::GetInstance() {
-  return Singleton< ChromeWebUIFactory, PossibleTestSingletonTraits<
-      ChromeWebUIFactory, TestChromeWebUIFactory> >::get();
+ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() {
+  return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits<
+      ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get();
 }
 
-ChromeWebUIFactory::ChromeWebUIFactory() {
+ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() {
 }
 
-ChromeWebUIFactory::~ChromeWebUIFactory() {
+ChromeWebUIControllerFactory::~ChromeWebUIControllerFactory() {
 }
 
-RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes(
+RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(
     const GURL& page_url) const {
   // The bookmark manager is a chrome extension, so we have to check for it
   // before we check for extension scheme.
diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.h b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h
similarity index 78%
rename from chrome/browser/ui/webui/chrome_web_ui_factory.h
rename to chrome/browser/ui/webui/chrome_web_ui_controller_factory.h
index ca03a46..db53d01 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_factory.h
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h
@@ -9,13 +9,13 @@
 #include "base/basictypes.h"
 #include "base/memory/singleton.h"
 #include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_factory.h"
+#include "content/public/browser/web_ui_controller_factory.h"
 #include "chrome/browser/favicon/favicon_service.h"
 
 class Profile;
 class RefCountedMemory;
 
-class ChromeWebUIFactory : public content::WebUIFactory {
+class ChromeWebUIControllerFactory : public content::WebUIControllerFactory {
  public:
   virtual content::WebUI::TypeID GetWebUIType(
       content::BrowserContext* browser_context,
@@ -27,7 +27,7 @@
   virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE;
   virtual bool IsURLAcceptableForWebUI(content::BrowserContext* browser_context,
                                        const GURL& url) const OVERRIDE;
-  virtual content::WebUIController* CreateWebUIForURL(
+  virtual content::WebUIController* CreateWebUIControllerForURL(
       content::WebUI* web_ui,
       const GURL& url) const OVERRIDE;
 
@@ -37,21 +37,21 @@
                         FaviconService::GetFaviconRequest* request,
                         const GURL& page_url) const;
 
-  static ChromeWebUIFactory* GetInstance();
+  static ChromeWebUIControllerFactory* GetInstance();
 
  protected:
-  ChromeWebUIFactory();
-  virtual ~ChromeWebUIFactory();
+  ChromeWebUIControllerFactory();
+  virtual ~ChromeWebUIControllerFactory();
 
  private:
 
-  friend struct DefaultSingletonTraits<ChromeWebUIFactory>;
+  friend struct DefaultSingletonTraits<ChromeWebUIControllerFactory>;
 
   // Gets the data for the favicon for a WebUI page. Returns NULL if the WebUI
   // does not have a favicon.
   RefCountedMemory* GetFaviconResourceBytes(const GURL& page_url) const;
 
-  DISALLOW_COPY_AND_ASSIGN(ChromeWebUIFactory);
+  DISALLOW_COPY_AND_ASSIGN(ChromeWebUIControllerFactory);
 };
 
 #endif  // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_FACTORY_H_
diff --git a/chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.cc
new file mode 100644
index 0000000..e82b3bd
--- /dev/null
+++ b/chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/web_contents.h"
+
+using content::WebContents;
+using content::WebUI;
+using content::WebUIController;
+
+TestChromeWebUIControllerFactory::WebUIProvider::~WebUIProvider() {
+}
+
+TestChromeWebUIControllerFactory::TestChromeWebUIControllerFactory() {
+}
+
+TestChromeWebUIControllerFactory::~TestChromeWebUIControllerFactory() {
+}
+
+void TestChromeWebUIControllerFactory::AddFactoryOverride(
+    const std::string& host, WebUIProvider* provider) {
+  DCHECK_EQ(0U, GetInstance()->factory_overrides_.count(host));
+  GetInstance()->factory_overrides_[host] = provider;
+}
+
+void TestChromeWebUIControllerFactory::RemoveFactoryOverride(
+    const std::string& host) {
+  DCHECK_EQ(1U, GetInstance()->factory_overrides_.count(host));
+  GetInstance()->factory_overrides_.erase(host);
+}
+
+WebUI::TypeID TestChromeWebUIControllerFactory::GetWebUIType(
+    content::BrowserContext* browser_context, const GURL& url) const {
+  Profile* profile = Profile::FromBrowserContext(browser_context);
+  WebUIProvider* provider = GetWebUIProvider(profile, url);
+  return provider ? reinterpret_cast<WebUI::TypeID>(provider) :
+      ChromeWebUIControllerFactory::GetWebUIType(profile, url);
+}
+
+WebUIController* TestChromeWebUIControllerFactory::CreateWebUIControllerForURL(
+    content::WebUI* web_ui, const GURL& url) const {
+  Profile* profile = Profile::FromWebUI(web_ui);
+  WebUIProvider* provider = GetWebUIProvider(profile, url);
+  return provider ? provider->NewWebUI(web_ui, url) :
+      ChromeWebUIControllerFactory::CreateWebUIControllerForURL(web_ui, url);
+}
+
+TestChromeWebUIControllerFactory*
+    TestChromeWebUIControllerFactory::GetInstance() {
+  return static_cast<TestChromeWebUIControllerFactory*>(
+      ChromeWebUIControllerFactory::GetInstance());
+}
+
+TestChromeWebUIControllerFactory::WebUIProvider*
+    TestChromeWebUIControllerFactory::GetWebUIProvider(
+        Profile* profile, const GURL& url) const {
+  FactoryOverridesMap::const_iterator found =
+      factory_overrides_.find(url.host());
+  return (found == factory_overrides_.end()) ? NULL : found->second;
+}
diff --git a/chrome/browser/ui/webui/test_chrome_web_ui_factory.h b/chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h
similarity index 75%
rename from chrome/browser/ui/webui/test_chrome_web_ui_factory.h
rename to chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h
index 772c408..644f13ff 100644
--- a/chrome/browser/ui/webui/test_chrome_web_ui_factory.h
+++ b/chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h
@@ -10,12 +10,13 @@
 #include <map>
 #include <string>
 
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 #include "content/public/browser/web_ui.h"
 
 // This class replaces the ChromeWebUIFactory when the switches::kTestType flag
-// is passed. It provides a registry to override CreateWebUIForURL() by host.
-class TestChromeWebUIFactory : public ChromeWebUIFactory {
+// is passed. It provides a registry to override CreateWebUIControllerForURL()
+// by host.
+class TestChromeWebUIControllerFactory : public ChromeWebUIControllerFactory {
  public:
   // Interface to create a new WebUI object.
   class WebUIProvider {
@@ -42,17 +43,17 @@
   virtual content::WebUI::TypeID GetWebUIType(
       content::BrowserContext* browser_context,
       const GURL& url) const OVERRIDE;
-  virtual content::WebUIController* CreateWebUIForURL(
+  virtual content::WebUIController* CreateWebUIControllerForURL(
       content::WebUI* web_ui, const GURL& url) const OVERRIDE;
 
   // Return the singleton instance.
-  static TestChromeWebUIFactory* GetInstance();
+  static TestChromeWebUIControllerFactory* GetInstance();
 
  private:
-  TestChromeWebUIFactory();
-  virtual ~TestChromeWebUIFactory();
+  TestChromeWebUIControllerFactory();
+  virtual ~TestChromeWebUIControllerFactory();
 
-  friend struct DefaultSingletonTraits<TestChromeWebUIFactory>;
+  friend struct DefaultSingletonTraits<TestChromeWebUIControllerFactory>;
 
   // Return the WebUIProvider for the |url|'s host if it exists, otherwise NULL.
   WebUIProvider* GetWebUIProvider(Profile* profile, const GURL& url) const;
@@ -60,7 +61,7 @@
   // Stores the mapping of host to WebUIProvider.
   FactoryOverridesMap factory_overrides_;
 
-  DISALLOW_COPY_AND_ASSIGN(TestChromeWebUIFactory);
+  DISALLOW_COPY_AND_ASSIGN(TestChromeWebUIControllerFactory);
 };
 
 #endif  // CHROME_BROWSER_UI_WEBUI_TEST_CHROME_WEB_UI_FACTORY_H_
diff --git a/chrome/browser/ui/webui/test_chrome_web_ui_controller_factory_browsertest.cc b/chrome/browser/ui/webui/test_chrome_web_ui_controller_factory_browsertest.cc
new file mode 100644
index 0000000..759c9f1
--- /dev/null
+++ b/chrome/browser/ui/webui/test_chrome_web_ui_controller_factory_browsertest.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chrome_web_ui.h"
+#include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h"
+#include "content/public/browser/web_ui_controller.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "googleurl/src/gurl.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using content::WebContents;
+using content::WebUI;
+using content::WebUIController;
+using ::testing::_;
+using ::testing::Eq;
+using ::testing::StrictMock;
+
+namespace {
+
+// Returns a new WebUI object for the TabContents from |arg0|.
+ACTION(ReturnNewWebUI) {
+  return new WebUIController(arg0);
+}
+
+// Mock the TestChromeWebUIControllerFactory::WebUIProvider to prove that we are
+// called as expected.
+class MockWebUIProvider
+    : public TestChromeWebUIControllerFactory::WebUIProvider {
+ public:
+  MOCK_METHOD2(NewWebUI, WebUIController*(content::WebUI* web_ui,
+                                          const GURL& url));
+};
+
+// Dummy URL location for us to override.
+const char kChromeTestChromeWebUIControllerFactory[] =
+    "chrome://ChromeTestChromeWebUIControllerFactory/";
+
+// Sets up and tears down the factory override for our url's host. It is
+// necessary to do this here, rather than in the test declaration, which is too
+// late to catch the possibility of an initial browse to about:blank mistakenly
+// going to this handler.
+class TestChromeWebUIControllerFactoryTest : public InProcessBrowserTest {
+ public:
+  virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+    InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
+    TestChromeWebUIControllerFactory::AddFactoryOverride(
+        GURL(kChromeTestChromeWebUIControllerFactory).host(), &mock_provider_);
+  }
+
+  virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
+    TestChromeWebUIControllerFactory::RemoveFactoryOverride(
+        GURL(kChromeTestChromeWebUIControllerFactory).host());
+  }
+
+ protected:
+  StrictMock<MockWebUIProvider> mock_provider_;
+};
+
+}  // namespace
+
+// Test that browsing to our test url causes us to be called once.
+IN_PROC_BROWSER_TEST_F(TestChromeWebUIControllerFactoryTest,
+                       TestWebUIProvider) {
+  const GURL kChromeTestChromeWebUIControllerFactoryURL(
+      kChromeTestChromeWebUIControllerFactory);
+  EXPECT_CALL(mock_provider_,
+              NewWebUI(_, Eq(kChromeTestChromeWebUIControllerFactoryURL)))
+      .WillOnce(ReturnNewWebUI());
+  ui_test_utils::NavigateToURL(browser(),
+                               kChromeTestChromeWebUIControllerFactoryURL);
+}
diff --git a/chrome/browser/ui/webui/test_chrome_web_ui_factory.cc b/chrome/browser/ui/webui/test_chrome_web_ui_factory.cc
deleted file mode 100644
index e172c2f..0000000
--- a/chrome/browser/ui/webui/test_chrome_web_ui_factory.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h"
-
-#include "chrome/browser/profiles/profile.h"
-#include "content/public/browser/web_contents.h"
-
-using content::WebContents;
-using content::WebUI;
-using content::WebUIController;
-
-TestChromeWebUIFactory::WebUIProvider::~WebUIProvider() {
-}
-
-TestChromeWebUIFactory::TestChromeWebUIFactory() {
-}
-
-TestChromeWebUIFactory::~TestChromeWebUIFactory() {
-}
-
-void TestChromeWebUIFactory::AddFactoryOverride(const std::string& host,
-                                                WebUIProvider* provider) {
-  DCHECK_EQ(0U, GetInstance()->factory_overrides_.count(host));
-  GetInstance()->factory_overrides_[host] = provider;
-}
-
-void TestChromeWebUIFactory::RemoveFactoryOverride(const std::string& host) {
-  DCHECK_EQ(1U, GetInstance()->factory_overrides_.count(host));
-  GetInstance()->factory_overrides_.erase(host);
-}
-
-WebUI::TypeID TestChromeWebUIFactory::GetWebUIType(
-    content::BrowserContext* browser_context, const GURL& url) const {
-  Profile* profile = Profile::FromBrowserContext(browser_context);
-  WebUIProvider* provider = GetWebUIProvider(profile, url);
-  return provider ? reinterpret_cast<WebUI::TypeID>(provider) :
-      ChromeWebUIFactory::GetWebUIType(profile, url);
-}
-
-WebUIController* TestChromeWebUIFactory::CreateWebUIForURL(
-    content::WebUI* web_ui, const GURL& url) const {
-  Profile* profile = Profile::FromWebUI(web_ui);
-  WebUIProvider* provider = GetWebUIProvider(profile, url);
-  return provider ? provider->NewWebUI(web_ui, url) :
-      ChromeWebUIFactory::CreateWebUIForURL(web_ui, url);
-}
-
-TestChromeWebUIFactory* TestChromeWebUIFactory::GetInstance() {
-  return static_cast<TestChromeWebUIFactory*>(
-      ChromeWebUIFactory::GetInstance());
-}
-
-TestChromeWebUIFactory::WebUIProvider* TestChromeWebUIFactory::GetWebUIProvider(
-    Profile* profile, const GURL& url) const {
-  FactoryOverridesMap::const_iterator found =
-      factory_overrides_.find(url.host());
-  return (found == factory_overrides_.end()) ? NULL : found->second;
-}
diff --git a/chrome/browser/ui/webui/test_chrome_web_ui_factory_browsertest.cc b/chrome/browser/ui/webui/test_chrome_web_ui_factory_browsertest.cc
deleted file mode 100644
index e847166..0000000
--- a/chrome/browser/ui/webui/test_chrome_web_ui_factory_browsertest.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/chrome_web_ui.h"
-#include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h"
-#include "content/public/browser/web_ui_controller.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/ui_test_utils.h"
-#include "googleurl/src/gurl.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using content::WebContents;
-using content::WebUI;
-using content::WebUIController;
-using ::testing::_;
-using ::testing::Eq;
-using ::testing::StrictMock;
-
-namespace {
-
-// Returns a new WebUI object for the TabContents from |arg0|.
-ACTION(ReturnNewWebUI) {
-  return new WebUIController(arg0);
-}
-
-// Mock the TestChromeWebUIFactory::WebUIProvider to prove that we are called as
-// expected.
-class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider {
- public:
-  MOCK_METHOD2(NewWebUI, WebUIController*(content::WebUI* web_ui,
-                                          const GURL& url));
-};
-
-// Dummy URL location for us to override.
-const char kChromeTestChromeWebUIFactory[] =
-    "chrome://ChromeTestChromeWebUIFactory/";
-
-// Sets up and tears down the factory override for our url's host. It is
-// necessary to do this here, rather than in the test declaration, which is too
-// late to catch the possibility of an initial browse to about:blank mistakenly
-// going to this handler.
-class TestChromeWebUIFactoryTest : public InProcessBrowserTest {
- public:
-  virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
-    InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
-    TestChromeWebUIFactory::AddFactoryOverride(
-        GURL(kChromeTestChromeWebUIFactory).host(), &mock_provider_);
-  }
-
-  virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
-    TestChromeWebUIFactory::RemoveFactoryOverride(
-        GURL(kChromeTestChromeWebUIFactory).host());
-  }
-
- protected:
-  StrictMock<MockWebUIProvider> mock_provider_;
-};
-
-}  // namespace
-
-// Test that browsing to our test url causes us to be called once.
-IN_PROC_BROWSER_TEST_F(TestChromeWebUIFactoryTest, TestWebUIProvider) {
-  const GURL kChromeTestChromeWebUIFactoryURL(kChromeTestChromeWebUIFactory);
-  EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(kChromeTestChromeWebUIFactoryURL)))
-      .WillOnce(ReturnNewWebUI());
-  ui_test_utils::NavigateToURL(browser(), kChromeTestChromeWebUIFactoryURL);
-}
diff --git a/chrome/browser/ui/webui/uber/uber_ui.cc b/chrome/browser/ui/webui/uber/uber_ui.cc
index c41c7a6..998a211c 100644
--- a/chrome/browser/ui/webui/uber/uber_ui.cc
+++ b/chrome/browser/ui/webui/uber/uber_ui.cc
@@ -9,7 +9,7 @@
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 #include "chrome/browser/ui/webui/extensions/extensions_ui.h"
 #include "chrome/browser/ui/webui/options2/options_ui2.h"
 #include "chrome/common/url_constants.h"
diff --git a/chrome/browser/ui/webui/web_ui_browsertest.cc b/chrome/browser/ui/webui/web_ui_browsertest.cc
index 6a1b85e..533fa9d 100644
--- a/chrome/browser/ui/webui/web_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/web_ui_browsertest.cc
@@ -19,7 +19,7 @@
 #include "chrome/browser/ui/browser_navigator.h"
 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
 #include "chrome/browser/ui/webui/chrome_web_ui.h"
-#include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h"
+#include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h"
 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/url_constants.h"
@@ -270,7 +270,8 @@
 
 // WebUIProvider to allow attaching the DataSource for the dummy URL when
 // testing.
-class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider {
+class MockWebUIProvider
+    : public TestChromeWebUIControllerFactory::WebUIProvider {
  public:
   MockWebUIProvider() {}
 
@@ -306,8 +307,8 @@
 
 void WebUIBrowserTest::SetUpInProcessBrowserTestFixture() {
   InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
-  TestChromeWebUIFactory::AddFactoryOverride(GURL(kDummyURL).host(),
-                                             mock_provider_.Pointer());
+  TestChromeWebUIControllerFactory::AddFactoryOverride(
+      GURL(kDummyURL).host(), mock_provider_.Pointer());
 
   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_));
   test_data_directory_ = test_data_directory_.Append(kWebUITestFolder);
@@ -331,7 +332,8 @@
 
 void WebUIBrowserTest::TearDownInProcessBrowserTestFixture() {
   InProcessBrowserTest::TearDownInProcessBrowserTestFixture();
-  TestChromeWebUIFactory::RemoveFactoryOverride(GURL(kDummyURL).host());
+  TestChromeWebUIControllerFactory::RemoveFactoryOverride(
+      GURL(kDummyURL).host());
 }
 
 void WebUIBrowserTest::SetWebUIInstance(content::WebUI* web_ui) {
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 598f0de..9a52db04 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3752,10 +3752,10 @@
         'browser/ui/webui/chrome_url_data_manager_backend.h',
         'browser/ui/webui/chrome_web_ui.cc',
         'browser/ui/webui/chrome_web_ui.h',
+        'browser/ui/webui/chrome_web_ui_controller_factory.cc',
+        'browser/ui/webui/chrome_web_ui_controller_factory.h',
         'browser/ui/webui/chrome_web_ui_data_source.cc',
         'browser/ui/webui/chrome_web_ui_data_source.h',
-        'browser/ui/webui/chrome_web_ui_factory.cc',
-        'browser/ui/webui/chrome_web_ui_factory.h',
         'browser/ui/webui/chromeos/choose_mobile_network_ui.cc',
         'browser/ui/webui/chromeos/choose_mobile_network_ui.h',
         'browser/ui/webui/chromeos/imageburner/imageburner_ui.cc',
@@ -4118,8 +4118,8 @@
         'browser/ui/webui/task_manager_handler.h',
         'browser/ui/webui/task_manager_ui.cc',
         'browser/ui/webui/task_manager_ui.h',
-        'browser/ui/webui/test_chrome_web_ui_factory.cc',
-        'browser/ui/webui/test_chrome_web_ui_factory.h',
+        'browser/ui/webui/test_chrome_web_ui_controller_factory.cc',
+        'browser/ui/webui/test_chrome_web_ui_controller_factory.h',
         'browser/ui/webui/theme_source.cc',
         'browser/ui/webui/theme_source.h',
         'browser/ui/webui/tracing_ui.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 23eb6514..6f2f491 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2724,7 +2724,7 @@
         'browser/ui/views/status_icons/status_tray_chromeos_browsertest.cc',
         'browser/ui/webui/chrome_url_data_manager_browsertest.cc',
         'browser/ui/webui/ntp/most_visited_browsertest.cc',
-        'browser/ui/webui/test_chrome_web_ui_factory_browsertest.cc',
+        'browser/ui/webui/test_chrome_web_ui_controller_factory_browsertest.cc',
         'browser/ui/webui/bidi_checker_web_ui_test.cc',
         'browser/ui/webui/bidi_checker_web_ui_test.h',
         'browser/ui/webui/html_dialog_controller_browsertest.cc',
diff --git a/content/browser/browsing_instance.cc b/content/browser/browsing_instance.cc
index b82ef96..ae42e29a 100644
--- a/content/browser/browsing_instance.cc
+++ b/content/browser/browsing_instance.cc
@@ -9,11 +9,12 @@
 #include "content/browser/site_instance_impl.h"
 #include "content/public/browser/browser_context.h"
 #include "content/public/browser/content_browser_client.h"
-#include "content/public/browser/web_ui_factory.h"
+#include "content/public/browser/web_ui_controller_factory.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/common/url_constants.h"
 
 using content::SiteInstance;
+using content::WebUIControllerFactory;
 
 // static
 base::LazyInstance<BrowsingInstance::ContextSiteInstanceMap>::Leaky
@@ -43,8 +44,9 @@
     return true;
 
   // DevTools pages have WebUI type but should not reuse the same host.
-  if (content::GetContentClient()->browser()->GetWebUIFactory()->
-          UseWebUIForURL(browser_context_, url) &&
+  WebUIControllerFactory* factory =
+      content::GetContentClient()->browser()->GetWebUIControllerFactory();
+  if (factory && factory->UseWebUIForURL(browser_context_, url) &&
       !url.SchemeIs(chrome::kChromeDevToolsScheme)) {
     return true;
   }
diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc
index 87614a2..34e05a782 100644
--- a/content/browser/mock_content_browser_client.cc
+++ b/content/browser/mock_content_browser_client.cc
@@ -8,7 +8,6 @@
 
 #include "base/file_path.h"
 #include "base/logging.h"
-#include "content/browser/webui/empty_web_ui_factory.h"
 #include "content/test/test_web_contents_view.h"
 #include "googleurl/src/gurl.h"
 #include "third_party/skia/include/core/SkBitmap.h"
@@ -41,9 +40,8 @@
     RenderProcessHost* host) {
 }
 
-WebUIFactory* MockContentBrowserClient::GetWebUIFactory() {
-  // Return an empty factory so callsites don't have to check for NULL.
-  return EmptyWebUIFactory::GetInstance();
+WebUIControllerFactory* MockContentBrowserClient::GetWebUIControllerFactory() {
+  return NULL;
 }
 
 GURL MockContentBrowserClient::GetEffectiveURL(
diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h
index b441703..1502c2f 100644
--- a/content/browser/mock_content_browser_client.h
+++ b/content/browser/mock_content_browser_client.h
@@ -29,7 +29,7 @@
       RenderViewHost* render_view_host) OVERRIDE;
   virtual void RenderProcessHostCreated(
       RenderProcessHost* host) OVERRIDE;
-  virtual WebUIFactory* GetWebUIFactory() OVERRIDE;
+  virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE;
   virtual GURL GetEffectiveURL(content::BrowserContext* browser_context,
                                const GURL& url) OVERRIDE;
   virtual bool ShouldUseProcessPerSite(BrowserContext* browser_context,
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 38103c9..2c291d7c 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -89,7 +89,7 @@
 #include "content/public/browser/notification_service.h"
 #include "content/public/browser/render_view_host_delegate.h"
 #include "content/public/browser/user_metrics.h"
-#include "content/public/browser/web_ui_factory.h"
+#include "content/public/browser/web_ui_controller_factory.h"
 #include "content/public/common/content_constants.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/common/process_type.h"
@@ -119,6 +119,7 @@
 using content::ChildProcessHost;
 using content::ChildProcessHostImpl;
 using content::UserMetricsAction;
+using content::WebUIControllerFactory;
 
 // This class creates the IO thread for the renderer when running in
 // single-process mode.  It's not used in multi-process mode.
@@ -1092,11 +1093,14 @@
   if (host->GetBrowserContext() != browser_context)
     return false;
 
-  if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings(
+  WebUIControllerFactory* factory =
+      content::GetContentClient()->browser()->GetWebUIControllerFactory();
+  if (factory &&
+      ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings(
           host->GetID()) !=
-      content::GetContentClient()->browser()->GetWebUIFactory()->
-          UseWebUIBindingsForURL(browser_context, site_url))
+      factory->UseWebUIBindingsForURL(browser_context, site_url)) {
     return false;
+  }
 
   return content::GetContentClient()->browser()->IsSuitableHost(host, site_url);
 }
diff --git a/content/browser/site_instance_impl_unittest.cc b/content/browser/site_instance_impl_unittest.cc
index f45baf7..77ae33c 100644
--- a/content/browser/site_instance_impl_unittest.cc
+++ b/content/browser/site_instance_impl_unittest.cc
@@ -15,7 +15,7 @@
 #include "content/browser/site_instance_impl.h"
 #include "content/browser/tab_contents/navigation_entry_impl.h"
 #include "content/browser/tab_contents/tab_contents.h"
-#include "content/browser/webui/empty_web_ui_factory.h"
+#include "content/public/browser/web_ui_controller_factory.h"
 #include "content/public/common/content_client.h"
 #include "content/public/common/content_constants.h"
 #include "content/public/common/url_constants.h"
@@ -23,11 +23,14 @@
 #include "googleurl/src/url_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
+using content::BrowserContext;
 using content::BrowserThread;
 using content::BrowserThreadImpl;
 using content::NavigationEntry;
 using content::NavigationEntryImpl;
 using content::SiteInstance;
+using content::WebUI;
+using content::WebUIController;
 
 namespace {
 
@@ -35,19 +38,32 @@
 
 const char kPrivilegedScheme[] = "privileged";
 
-class SiteInstanceTestWebUIFactory : public content::EmptyWebUIFactory {
+class SiteInstanceTestWebUIControllerFactory
+    : public content::WebUIControllerFactory {
  public:
-  virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
+  virtual WebUIController* CreateWebUIControllerForURL(
+      WebUI* web_ui, const GURL& url) const OVERRIDE {
+    return NULL;
+  }
+  virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context,
+      const GURL& url) const OVERRIDE {
+    return WebUI::kNoWebUI;
+  }
+  virtual bool UseWebUIForURL(BrowserContext* browser_context,
                               const GURL& url) const OVERRIDE {
     return HasWebUIScheme(url);
   }
-  virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
+  virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
                                       const GURL& url) const OVERRIDE {
     return HasWebUIScheme(url);
   }
   virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE {
     return url.SchemeIs(chrome::kChromeUIScheme);
   }
+  virtual bool IsURLAcceptableForWebUI(BrowserContext* browser_context,
+      const GURL& url) const OVERRIDE {
+    return false;
+  }
 };
 
 class SiteInstanceTestBrowserClient : public content::MockContentBrowserClient {
@@ -56,11 +72,12 @@
       : privileged_process_id_(-1) {
   }
 
-  virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE {
+  virtual content::WebUIControllerFactory*
+      GetWebUIControllerFactory() OVERRIDE {
     return &factory_;
   }
 
-  virtual bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
+  virtual bool ShouldUseProcessPerSite(BrowserContext* browser_context,
                                        const GURL& effective_url) OVERRIDE {
     return false;
   }
@@ -81,7 +98,7 @@
   }
 
  private:
-  SiteInstanceTestWebUIFactory factory_;
+  SiteInstanceTestWebUIControllerFactory factory_;
   int privileged_process_id_;
 };
 
@@ -117,8 +134,7 @@
 
 class TestBrowsingInstance : public BrowsingInstance {
  public:
-  TestBrowsingInstance(content::BrowserContext* browser_context,
-                       int* delete_counter)
+  TestBrowsingInstance(BrowserContext* browser_context, int* delete_counter)
       : BrowsingInstance(browser_context),
         use_process_per_site_(false),
         delete_counter_(delete_counter) {
@@ -156,7 +172,7 @@
 class TestSiteInstance : public SiteInstanceImpl {
  public:
   static TestSiteInstance* CreateTestSiteInstance(
-      content::BrowserContext* browser_context,
+      BrowserContext* browser_context,
       int* site_delete_counter,
       int* browsing_delete_counter) {
     TestBrowsingInstance* browsing_instance =
diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc
index f5174798..30c6396b 100644
--- a/content/browser/tab_contents/render_view_host_manager.cc
+++ b/content/browser/tab_contents/render_view_host_manager.cc
@@ -23,7 +23,7 @@
 #include "content/public/browser/render_view_host_delegate.h"
 #include "content/public/browser/web_contents_view.h"
 #include "content/public/browser/web_ui_controller.h"
-#include "content/public/browser/web_ui_factory.h"
+#include "content/public/browser/web_ui_controller_factory.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/common/url_constants.h"
 
@@ -31,6 +31,7 @@
 using content::NavigationEntry;
 using content::NavigationEntryImpl;
 using content::SiteInstance;
+using content::WebUIControllerFactory;
 
 RenderViewHostManager::RenderViewHostManager(
     content::RenderViewHostDelegate* render_view_delegate,
@@ -349,17 +350,19 @@
       render_view_host_->site_instance()->GetSite();
   content::BrowserContext* browser_context =
       delegate_->GetControllerForRenderManager().GetBrowserContext();
-  const content::WebUIFactory* web_ui_factory =
-      content::GetContentClient()->browser()->GetWebUIFactory();
-  if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) {
-    // Force swap if it's not an acceptable URL for Web UI.
-    if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context,
-                                                 new_entry->GetURL()))
-      return true;
-  } else {
-    // Force swap if it's a Web UI URL.
-    if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->GetURL()))
-      return true;
+  const WebUIControllerFactory* web_ui_factory =
+      content::GetContentClient()->browser()->GetWebUIControllerFactory();
+  if (web_ui_factory) {
+    if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) {
+      // Force swap if it's not an acceptable URL for Web UI.
+      if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context,
+                                                   new_entry->GetURL()))
+        return true;
+    } else {
+      // Force swap if it's a Web UI URL.
+      if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->GetURL()))
+        return true;
+    }
   }
 
   if (content::GetContentClient()->browser()->ShouldSwapProcessesForNavigation(
diff --git a/content/browser/tab_contents/render_view_host_manager_unittest.cc b/content/browser/tab_contents/render_view_host_manager_unittest.cc
index 78e3e5d..978fe903 100644
--- a/content/browser/tab_contents/render_view_host_manager_unittest.cc
+++ b/content/browser/tab_contents/render_view_host_manager_unittest.cc
@@ -11,13 +11,13 @@
 #include "content/browser/tab_contents/navigation_entry_impl.h"
 #include "content/browser/tab_contents/render_view_host_manager.h"
 #include "content/browser/tab_contents/test_tab_contents.h"
-#include "content/browser/webui/empty_web_ui_factory.h"
 #include "content/common/test_url_constants.h"
 #include "content/common/view_messages.h"
 #include "content/public/browser/notification_details.h"
 #include "content/public/browser/notification_source.h"
 #include "content/public/browser/notification_types.h"
 #include "content/public/browser/web_ui_controller.h"
+#include "content/public/browser/web_ui_controller_factory.h"
 #include "content/public/common/page_transition_types.h"
 #include "content/public/common/url_constants.h"
 #include "content/test/test_browser_context.h"
@@ -26,6 +26,7 @@
 #include "googleurl/src/url_util.h"
 #include "webkit/glue/webkit_glue.h"
 
+using content::BrowserContext;
 using content::BrowserThread;
 using content::BrowserThreadImpl;
 using content::NavigationController;
@@ -33,38 +34,44 @@
 using content::NavigationEntryImpl;
 using content::SiteInstance;
 using content::WebContents;
+using content::WebUI;
 using content::WebUIController;
 
 namespace {
 
 const char kChromeUISchemeButNotWebUIURL[] = "chrome://not-webui";
 
-class RenderViewHostManagerTestWebUIFactory
-    : public content::EmptyWebUIFactory {
+class RenderViewHostManagerTestWebUIControllerFactory
+    : public content::WebUIControllerFactory {
  public:
-  RenderViewHostManagerTestWebUIFactory()
+  RenderViewHostManagerTestWebUIControllerFactory()
     : should_create_webui_(false) {
   }
-  virtual ~RenderViewHostManagerTestWebUIFactory() {}
+  virtual ~RenderViewHostManagerTestWebUIControllerFactory() {}
 
   void set_should_create_webui(bool should_create_webui) {
     should_create_webui_ = should_create_webui;
   }
 
   // WebUIFactory implementation.
-  virtual WebUIController* CreateWebUIForURL(content::WebUI* web_ui,
-                                             const GURL& url) const OVERRIDE {
+  virtual WebUIController* CreateWebUIControllerForURL(
+      WebUI* web_ui, const GURL& url) const OVERRIDE {
     if (!(should_create_webui_ && HasWebUIScheme(url)))
       return NULL;
     return new WebUIController(web_ui);
   }
 
-  virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
+   virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context,
+      const GURL& url) const OVERRIDE {
+    return WebUI::kNoWebUI;
+  }
+
+  virtual bool UseWebUIForURL(BrowserContext* browser_context,
                               const GURL& url) const OVERRIDE {
     return HasWebUIScheme(url);
   }
 
-  virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
+  virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
                                       const GURL& url) const OVERRIDE {
     return HasWebUIScheme(url);
   }
@@ -74,10 +81,15 @@
         url.spec() != kChromeUISchemeButNotWebUIURL;
   }
 
+  virtual bool IsURLAcceptableForWebUI(BrowserContext* browser_context,
+      const GURL& url) const OVERRIDE {
+    return false;
+  }
+
  private:
   bool should_create_webui_;
 
-  DISALLOW_COPY_AND_ASSIGN(RenderViewHostManagerTestWebUIFactory);
+  DISALLOW_COPY_AND_ASSIGN(RenderViewHostManagerTestWebUIControllerFactory);
 };
 
 class RenderViewHostManagerTestBrowserClient
@@ -91,12 +103,13 @@
   }
 
   // content::MockContentBrowserClient implementation.
-  virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE {
+  virtual content::WebUIControllerFactory*
+      GetWebUIControllerFactory() OVERRIDE {
     return &factory_;
   }
 
  private:
-  RenderViewHostManagerTestWebUIFactory factory_;
+  RenderViewHostManagerTestWebUIControllerFactory factory_;
 
   DISALLOW_COPY_AND_ASSIGN(RenderViewHostManagerTestBrowserClient);
 };
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 8edcdf3..cf79d60 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -46,7 +46,7 @@
 #include "content/public/browser/web_contents_delegate.h"
 #include "content/public/browser/web_contents_observer.h"
 #include "content/public/browser/web_contents_view.h"
-#include "content/public/browser/web_ui_factory.h"
+#include "content/public/browser/web_ui_controller_factory.h"
 #include "content/public/common/bindings_policy.h"
 #include "content/public/common/content_constants.h"
 #include "content/public/common/content_restriction.h"
@@ -122,6 +122,7 @@
 using content::WebContentsObserver;
 using content::WebUI;
 using content::WebUIController;
+using content::WebUIControllerFactory;
 
 namespace {
 
@@ -435,10 +436,13 @@
 }
 
 content::WebUI* TabContents::CreateWebUI(const GURL& url) {
+  WebUIControllerFactory* factory =
+      content::GetContentClient()->browser()->GetWebUIControllerFactory();
+  if (!factory)
+    return NULL;
   WebUIImpl* web_ui = new WebUIImpl(this);
   WebUIController* controller =
-      content::GetContentClient()->browser()->GetWebUIFactory()->
-          CreateWebUIForURL(web_ui, url);
+      factory->CreateWebUIControllerForURL(web_ui, url);
   if (controller) {
     web_ui->SetController(controller);
     return web_ui;
@@ -828,9 +832,11 @@
   // For security, we should never send non-Web-UI URLs to a Web UI renderer.
   // Double check that here.
   int enabled_bindings = dest_render_view_host->enabled_bindings();
-  bool is_allowed_in_web_ui_renderer = content::GetContentClient()->
-      browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(GetBrowserContext(),
-                                                            entry.GetURL());
+  WebUIControllerFactory* factory =
+      content::GetContentClient()->browser()->GetWebUIControllerFactory();
+  bool is_allowed_in_web_ui_renderer =
+      factory &&
+      factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL());
 #if defined(OS_CHROMEOS)
   is_allowed_in_web_ui_renderer |= entry.GetURL().SchemeIs(chrome::kDataScheme);
 #endif
@@ -1098,8 +1104,11 @@
 }
 
 WebUI::TypeID TabContents::GetWebUITypeForCurrentState() {
-  return content::GetContentClient()->browser()->GetWebUIFactory()->
-      GetWebUIType(GetBrowserContext(), GetURL());
+  WebUIControllerFactory* factory =
+      content::GetContentClient()->browser()->GetWebUIControllerFactory();
+  if (!factory)
+    return WebUI::kNoWebUI;
+  return factory->GetWebUIType(GetBrowserContext(), GetURL());
 }
 
 content::WebUI* TabContents::GetWebUIForCurrentState() {
diff --git a/content/browser/tab_contents/tab_contents_unittest.cc b/content/browser/tab_contents/tab_contents_unittest.cc
index d943c1f..bb7c7d469 100644
--- a/content/browser/tab_contents/tab_contents_unittest.cc
+++ b/content/browser/tab_contents/tab_contents_unittest.cc
@@ -12,13 +12,13 @@
 #include "content/browser/tab_contents/interstitial_page.h"
 #include "content/browser/tab_contents/navigation_entry_impl.h"
 #include "content/browser/tab_contents/test_tab_contents.h"
-#include "content/browser/webui/empty_web_ui_factory.h"
 #include "content/common/view_messages.h"
 #include "content/public/browser/navigation_details.h"
 #include "content/public/browser/notification_details.h"
 #include "content/public/browser/notification_source.h"
 #include "content/public/browser/notification_source.h"
 #include "content/public/browser/web_ui_controller.h"
+#include "content/public/browser/web_ui_controller_factory.h"
 #include "content/public/common/bindings_policy.h"
 #include "content/public/common/content_constants.h"
 #include "content/public/common/url_constants.h"
@@ -26,37 +26,50 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "webkit/glue/webkit_glue.h"
 
+using content::BrowserContext;
 using content::BrowserThread;
 using content::NavigationEntry;
 using content::NavigationEntryImpl;
 using content::SiteInstance;
 using content::WebContents;
+using content::WebUI;
 using content::WebUIController;
 using webkit::forms::PasswordForm;
 
 namespace {
 
-class TabContentsTestWebUIFactory : public content::EmptyWebUIFactory {
+class TabContentsTestWebUIControllerFactory
+    : public content::WebUIControllerFactory {
  public:
-  virtual WebUIController* CreateWebUIForURL(content::WebUI* web_ui,
-                                             const GURL& url) const OVERRIDE {
+  virtual WebUIController* CreateWebUIControllerForURL(
+      content::WebUI* web_ui, const GURL& url) const OVERRIDE {
    if (!HasWebUIScheme(url))
      return NULL;
 
    return new WebUIController(web_ui);
   }
 
-  virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
+  virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context,
+      const GURL& url) const OVERRIDE {
+    return WebUI::kNoWebUI;
+  }
+
+  virtual bool UseWebUIForURL(BrowserContext* browser_context,
                               const GURL& url) const OVERRIDE {
     return HasWebUIScheme(url);
   }
 
+  virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
+                                      const GURL& url) const OVERRIDE {
+    return HasWebUIScheme(url);
+  }
+
   virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE {
     return url.SchemeIs("tabcontentstest");
   }
 
-  virtual bool IsURLAcceptableForWebUI(content::BrowserContext* browser_context,
-      const GURL& url) const {
+  virtual bool IsURLAcceptableForWebUI(
+      BrowserContext* browser_context, const GURL& url) const {
     return HasWebUIScheme(url);
   }
 };
@@ -66,12 +79,13 @@
   TabContentsTestBrowserClient() {
   }
 
-  virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE {
+  virtual content::WebUIControllerFactory*
+      GetWebUIControllerFactory() OVERRIDE {
     return &factory_;
   }
 
  private:
-  TabContentsTestWebUIFactory factory_;
+  TabContentsTestWebUIControllerFactory factory_;
 };
 
 class TestInterstitialPage : public InterstitialPage {
diff --git a/content/browser/webui/empty_web_ui_factory.cc b/content/browser/webui/empty_web_ui_factory.cc
deleted file mode 100644
index e5ede37..0000000
--- a/content/browser/webui/empty_web_ui_factory.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/webui/empty_web_ui_factory.h"
-
-namespace content {
-
-EmptyWebUIFactory::EmptyWebUIFactory() {
-}
-
-EmptyWebUIFactory::~EmptyWebUIFactory() {
-}
-
-WebUIController* EmptyWebUIFactory::CreateWebUIForURL(WebUI* web_ui,
-                                                      const GURL& url) const {
-  return NULL;
-}
-
-WebUI::TypeID EmptyWebUIFactory::GetWebUIType(
-    content::BrowserContext* browser_context, const GURL& url) const {
-  return WebUI::kNoWebUI;
-}
-
-bool EmptyWebUIFactory::UseWebUIForURL(
-    content::BrowserContext* browser_context, const GURL& url) const {
-  return false;
-}
-
-bool EmptyWebUIFactory::UseWebUIBindingsForURL(
-    content::BrowserContext* browser_context, const GURL& url) const {
-  return false;
-}
-
-bool EmptyWebUIFactory::HasWebUIScheme(const GURL& url) const {
-  return false;
-}
-
-bool EmptyWebUIFactory::IsURLAcceptableForWebUI(
-    content::BrowserContext* browser_context,
-    const GURL& url) const {
-  return false;
-}
-
-// static
-EmptyWebUIFactory* EmptyWebUIFactory::GetInstance() {
-  return Singleton<EmptyWebUIFactory>::get();
-}
-
-}  // namespace content
diff --git a/content/browser/webui/empty_web_ui_factory.h b/content/browser/webui/empty_web_ui_factory.h
deleted file mode 100644
index a6d8084..0000000
--- a/content/browser/webui/empty_web_ui_factory.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_BROWSER_WEBUI_EMPTY_WEB_UI_FACTORY_H_
-#define CONTENT_BROWSER_WEBUI_EMPTY_WEB_UI_FACTORY_H_
-
-#include "base/memory/singleton.h"
-#include "content/common/content_export.h"
-#include "content/public/browser/web_ui_factory.h"
-
-namespace content {
-
-// A stubbed out version of WebUIFactory.
-class CONTENT_EXPORT EmptyWebUIFactory : public content::WebUIFactory {
- public:
-  // Returns the singleton instance.
-  static EmptyWebUIFactory* GetInstance();
-
-  virtual WebUIController* CreateWebUIForURL(WebUI* web_ui,
-                                             const GURL& url) const OVERRIDE;
-  virtual WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context,
-                                     const GURL& url) const OVERRIDE;
-  virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
-                              const GURL& url) const OVERRIDE;
-  virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
-                                      const GURL& url) const OVERRIDE;
-  virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE;
-  virtual bool IsURLAcceptableForWebUI(content::BrowserContext* browser_context,
-                                       const GURL& url) const OVERRIDE;
-
- protected:
-  EmptyWebUIFactory();
-  virtual ~EmptyWebUIFactory();
-
- private:
-  friend struct DefaultSingletonTraits<EmptyWebUIFactory>;
-};
-
-}  // namespace content
-
-#endif  // CONTENT_BROWSER_WEBUI_EMPTY_WEB_UI_FACTORY_H_
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 2e7b62d..a527fc0 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -106,7 +106,7 @@
     'public/browser/web_ui.h',
     'public/browser/web_ui_controller.cc',
     'public/browser/web_ui_controller.h',
-    'public/browser/web_ui_factory.h',
+    'public/browser/web_ui_controller_factory.h',
     'public/browser/web_ui_message_handler.h',
     'public/browser/worker_service.h',
     'public/browser/worker_service_observer.h',
@@ -654,8 +654,6 @@
     'browser/user_metrics.cc',
     'browser/utility_process_host.cc',
     'browser/utility_process_host.h',
-    'browser/webui/empty_web_ui_factory.cc',
-    'browser/webui/empty_web_ui_factory.h',
     'browser/webui/generic_handler.cc',
     'browser/webui/generic_handler.h',
     'browser/webui/web_ui_impl.cc',
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index d008bc0..b3205bc 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -65,7 +65,7 @@
 
 class BrowserContext;
 class ResourceContext;
-class WebUIFactory;
+class WebUIControllerFactory;
 
 // Embedder API (or SPI) for participating in browser logic, to be implemented
 // by the client of the content browser. See ChromeContentBrowserClient for the
@@ -96,8 +96,9 @@
   virtual void RenderProcessHostCreated(
       content::RenderProcessHost* host) = 0;
 
-  // Gets the WebUIFactory which will be responsible for generating WebUIs.
-  virtual WebUIFactory* GetWebUIFactory() = 0;
+  // Gets the WebUIControllerFactory which will be responsible for generating
+  // WebUIs. Can return NULL if the embedder doesn't need WebUI support.
+  virtual WebUIControllerFactory* GetWebUIControllerFactory() = 0;
 
   // Get the effective URL for the given actual URL, to allow an embedder to
   // group different url schemes in the same SiteInstance.
diff --git a/content/public/browser/web_ui_factory.h b/content/public/browser/web_ui_controller_factory.h
similarity index 76%
rename from content/public/browser/web_ui_factory.h
rename to content/public/browser/web_ui_controller_factory.h
index 6821a93..fe5853e 100644
--- a/content/public/browser/web_ui_factory.h
+++ b/content/public/browser/web_ui_controller_factory.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_FACTORY_H_
-#define CONTENT_PUBLIC_BROWSER_WEB_UI_FACTORY_H_
+#ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_
+#define CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_
 #pragma once
 
 #include "content/common/content_export.h"
@@ -18,13 +18,15 @@
 class WebUIController;
 
 // Interface for an object which controls which URLs are considered WebUI URLs
-// and creates WebUI instances for given URLs.
-class CONTENT_EXPORT WebUIFactory {
+// and creates WebUIController instances for given URLs.
+class CONTENT_EXPORT WebUIControllerFactory {
  public:
-  // Returns a WebUI instance for the given URL, or NULL if the URL doesn't
-  // correspond to a WebUI.
-  virtual WebUIController* CreateWebUIForURL(WebUI* web_ui,
-                                             const GURL& url) const = 0;
+  virtual ~WebUIControllerFactory() {}
+
+  // Returns a WebUIController instance for the given URL, or NULL if the URL
+  // doesn't correspond to a WebUI.
+  virtual WebUIController* CreateWebUIControllerForURL(
+      WebUI* web_ui, const GURL& url) const = 0;
 
   // Gets the WebUI type for the given URL. This will return kNoWebUI if the
   // corresponding call to CreateWebUIForURL would fail, or something non-NULL
@@ -50,10 +52,8 @@
   // normal tabs such as javascript: URLs or about:hang.
   virtual bool IsURLAcceptableForWebUI(BrowserContext* browser_context,
                                        const GURL& url) const = 0;
-
-  virtual ~WebUIFactory() {}
 };
 
 }  // namespace content
 
-#endif  // CONTENT_PUBLIC_BROWSER_WEB_UI_FACTORY_H_
+#endif  // CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_
diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc
index 79d9be7..65e784b 100644
--- a/content/shell/shell_content_browser_client.cc
+++ b/content/shell/shell_content_browser_client.cc
@@ -5,7 +5,6 @@
 #include "content/shell/shell_content_browser_client.h"
 
 #include "base/file_path.h"
-#include "content/browser/webui/empty_web_ui_factory.h"
 #include "content/shell/shell.h"
 #include "content/shell/shell_browser_main.h"
 #include "googleurl/src/gurl.h"
@@ -53,9 +52,8 @@
     RenderProcessHost* host) {
 }
 
-WebUIFactory* ShellContentBrowserClient::GetWebUIFactory() {
-  // Return an empty factory so callsites don't have to check for NULL.
-  return EmptyWebUIFactory::GetInstance();
+WebUIControllerFactory* ShellContentBrowserClient::GetWebUIControllerFactory() {
+  return NULL;
 }
 
 GURL ShellContentBrowserClient::GetEffectiveURL(
diff --git a/content/shell/shell_content_browser_client.h b/content/shell/shell_content_browser_client.h
index f9238cc4..26ccebe5 100644
--- a/content/shell/shell_content_browser_client.h
+++ b/content/shell/shell_content_browser_client.h
@@ -33,7 +33,7 @@
       RenderViewHost* render_view_host) OVERRIDE;
   virtual void RenderProcessHostCreated(
       RenderProcessHost* host) OVERRIDE;
-  virtual WebUIFactory* GetWebUIFactory() OVERRIDE;
+  virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE;
   virtual GURL GetEffectiveURL(content::BrowserContext* browser_context,
                                const GURL& url) OVERRIDE;
   virtual bool ShouldUseProcessPerSite(BrowserContext* browser_context,