summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_url_handler.cc5
-rw-r--r--chrome/browser/chrome_content_browser_client.cc5
-rw-r--r--chrome/browser/chrome_content_browser_client.h1
-rw-r--r--chrome/browser/extensions/extension_host.cc6
-rw-r--r--chrome/browser/favicon_service.cc5
-rw-r--r--chrome/browser/notifications/balloon_host.cc3
-rw-r--r--chrome/browser/notifications/balloon_host.h1
-rw-r--r--chrome/browser/prerender/prerender_contents.h1
-rw-r--r--chrome/browser/tab_contents/background_contents.cc4
-rw-r--r--chrome/browser/tab_contents/background_contents.h1
-rw-r--r--chrome/browser/tab_contents/render_view_host_delegate_helper.cc3
-rw-r--r--chrome/browser/tab_contents/render_view_host_delegate_helper.h4
-rw-r--r--chrome/browser/ui/browser_navigator.cc3
-rw-r--r--chrome/browser/ui/webui/chrome_web_ui_factory.cc359
-rw-r--r--chrome/browser/ui/webui/chrome_web_ui_factory.h51
-rw-r--r--chrome/browser/ui/webui/generic_handler.cc (renamed from content/browser/webui/generic_handler.cc)2
-rw-r--r--chrome/browser/ui/webui/generic_handler.h (renamed from content/browser/webui/generic_handler.h)6
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--content/browser/browsing_instance.cc7
-rw-r--r--content/browser/content_browser_client.cc17
-rw-r--r--content/browser/content_browser_client.h5
-rw-r--r--content/browser/site_instance.cc4
-rw-r--r--content/browser/tab_contents/render_view_host_manager.cc11
-rw-r--r--content/browser/tab_contents/tab_contents.cc32
-rw-r--r--content/browser/tab_contents/tab_contents.h9
-rw-r--r--content/browser/tab_contents/tab_contents_view.cc3
-rw-r--r--content/browser/webui/empty_web_ui_factory.cc44
-rw-r--r--content/browser/webui/empty_web_ui_factory.h37
-rw-r--r--content/browser/webui/web_ui.cc5
-rw-r--r--content/browser/webui/web_ui.h8
-rw-r--r--content/browser/webui/web_ui_factory.cc342
-rw-r--r--content/browser/webui/web_ui_factory.h85
-rw-r--r--content/content_browser.gypi5
33 files changed, 430 insertions, 648 deletions
diff --git a/chrome/browser/browser_url_handler.cc b/chrome/browser/browser_url_handler.cc
index b9c8147..4234ea2 100644
--- a/chrome/browser/browser_url_handler.cc
+++ b/chrome/browser/browser_url_handler.cc
@@ -8,9 +8,8 @@
#include "chrome/browser/browser_about_handler.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
#include "chrome/common/url_constants.h"
-#include "content/browser/webui/web_ui.h"
+#include "content/browser/webui/web_ui_factory.h"
#include "googleurl/src/gurl.h"
// Handles rewriting view-source URLs for what we'll actually load.
@@ -62,7 +61,7 @@ static bool ReverseViewSource(GURL* url, Profile* profile) {
// Handles rewriting Web UI URLs.
static bool HandleWebUI(GURL* url, Profile* profile) {
- if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, *url))
+ if (!WebUIFactory::UseWebUIForURL(profile, *url))
return false;
// Special case the new tab page. In older versions of Chrome, the new tab
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 58a63a5..ce37842 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -7,7 +7,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
#include "content/browser/renderer_host/render_view_host.h"
namespace chrome {
@@ -28,8 +27,4 @@ void ChromeContentBrowserClient::PreCreateRenderView(
}
}
-content::WebUIFactory* ChromeContentBrowserClient::GetWebUIFactory() {
- return ChromeWebUIFactory::GetInstance();
-}
-
} // namespace chrome
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index dd71656..0cdbe51 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -15,7 +15,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
virtual void PreCreateRenderView(RenderViewHost* render_view_host,
Profile* profile,
const GURL& url);
- virtual content::WebUIFactory* GetWebUIFactory();
};
} // namespace chrome
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 47a6260..8d95d1b 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -26,7 +26,6 @@
#include "chrome/browser/tab_contents/popup_menu_helper_mac.h"
#include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/bindings_policy.h"
#include "chrome/common/extensions/extension.h"
@@ -42,6 +41,7 @@
#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
+#include "content/browser/webui/web_ui_factory.h"
#include "content/common/native_web_keyboard_event.h"
#include "content/common/notification_service.h"
#include "content/common/view_messages.h"
@@ -573,8 +573,8 @@ void ExtensionHost::CreateNewWindow(
route_id,
render_view_host()->process()->profile(),
site_instance(),
- ChromeWebUIFactory::GetInstance()->GetWebUIType(
- render_view_host()->process()->profile(), url_),
+ WebUIFactory::GetWebUIType(render_view_host()->process()->profile(),
+ url_),
this,
params.window_container_type,
params.frame_name);
diff --git a/chrome/browser/favicon_service.cc b/chrome/browser/favicon_service.cc
index 05caa22..ddf632b 100644
--- a/chrome/browser/favicon_service.cc
+++ b/chrome/browser/favicon_service.cc
@@ -7,8 +7,8 @@
#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/common/url_constants.h"
+#include "content/browser/webui/web_ui_factory.h"
FaviconService::FaviconService(Profile* profile) : profile_(profile) {
}
@@ -54,8 +54,7 @@ FaviconService::Handle FaviconService::GetFaviconForURL(
FaviconService::Handle handle = request->handle();
if (page_url.SchemeIs(chrome::kChromeUIScheme) ||
page_url.SchemeIs(chrome::kExtensionScheme)) {
- ChromeWebUIFactory::GetInstance()->GetFaviconForURL(
- profile_, request, page_url);
+ WebUIFactory::GetFaviconForURL(profile_, request, page_url);
} else {
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
if (hs)
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index e105b3c..f5a824e 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -12,7 +12,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/browser/renderer_preferences_util.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
#include "chrome/common/bindings_policy.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
@@ -148,7 +147,7 @@ void BalloonHost::CreateNewWindow(
route_id,
balloon_->profile(),
site_instance_.get(),
- ChromeWebUIFactory::GetInstance()->GetWebUIType(balloon_->profile(),
+ WebUIFactory::GetWebUIType(balloon_->profile(),
balloon_->notification().content_url()),
this,
params.window_container_type,
diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h
index 475d6bd..d00fbf9 100644
--- a/chrome/browser/notifications/balloon_host.h
+++ b/chrome/browser/notifications/balloon_host.h
@@ -9,7 +9,6 @@
#include <string>
#include <vector>
-#include "base/scoped_ptr.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
diff --git a/chrome/browser/prerender/prerender_contents.h b/chrome/browser/prerender/prerender_contents.h
index 9db6e4c..7ec68e1 100644
--- a/chrome/browser/prerender/prerender_contents.h
+++ b/chrome/browser/prerender/prerender_contents.h
@@ -9,7 +9,6 @@
#include <string>
#include <vector>
-#include "base/scoped_ptr.h"
#include "base/time.h"
#include "chrome/browser/prerender/prerender_final_status.h"
#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc
index b8c24d6..945a88b 100644
--- a/chrome/browser/tab_contents/background_contents.cc
+++ b/chrome/browser/tab_contents/background_contents.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/desktop_notification_handler.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/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/url_constants.h"
@@ -225,8 +224,7 @@ void BackgroundContents::CreateNewWindow(
route_id,
render_view_host_->process()->profile(),
render_view_host_->site_instance(),
- ChromeWebUIFactory::GetInstance()->GetWebUIType(
- render_view_host_->process()->profile(), url_),
+ WebUIFactory::GetWebUIType(render_view_host_->process()->profile(), url_),
this,
params.window_container_type,
params.frame_name);
diff --git a/chrome/browser/tab_contents/background_contents.h b/chrome/browser/tab_contents/background_contents.h
index e8a1847..670abd4 100644
--- a/chrome/browser/tab_contents/background_contents.h
+++ b/chrome/browser/tab_contents/background_contents.h
@@ -9,7 +9,6 @@
#include <string>
#include <vector>
-#include "base/scoped_ptr.h"
#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
#include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
#include "chrome/common/view_types.h"
diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
index 4cec7a1..f88dddb 100644
--- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
+++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
@@ -27,7 +27,6 @@
#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
-#include "content/browser/webui/web_ui.h"
RenderViewHostDelegateViewHelper::RenderViewHostDelegateViewHelper() {}
@@ -79,7 +78,7 @@ TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow(
int route_id,
Profile* profile,
SiteInstance* site,
- WebUI::TypeID webui_type,
+ WebUITypeID webui_type,
RenderViewHostDelegate* opener,
WindowContainerType window_container_type,
const string16& frame_name) {
diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.h b/chrome/browser/tab_contents/render_view_host_delegate_helper.h
index 3c1f922..4af68c8 100644
--- a/chrome/browser/tab_contents/render_view_host_delegate_helper.h
+++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.h
@@ -9,7 +9,7 @@
#include <map>
#include "base/basictypes.h"
-#include "content/browser/webui/web_ui.h"
+#include "content/browser/webui/web_ui_factory.h"
#include "content/common/window_container_type.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h"
#include "ui/gfx/rect.h"
@@ -41,7 +41,7 @@ class RenderViewHostDelegateViewHelper {
int route_id,
Profile* profile,
SiteInstance* site,
- WebUI::TypeID webui_type,
+ WebUITypeID webui_type,
RenderViewHostDelegate* opener,
WindowContainerType window_container_type,
const string16& frame_name);
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc
index 86754f2..36b53ca 100644
--- a/chrome/browser/ui/browser_navigator.cc
+++ b/chrome/browser/ui/browser_navigator.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/ui/status_bubble.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "content/browser/site_instance.h"
@@ -32,7 +31,7 @@ SiteInstance* GetSiteInstance(TabContents* source_contents, Profile* profile,
// If url is a WebUI or extension, we need to be sure to use the right type
// of renderer process up front. Otherwise, we create a normal SiteInstance
// as part of creating the tab.
- if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url))
+ if (WebUIFactory::UseWebUIForURL(profile, url))
return SiteInstance::CreateSiteInstanceForURL(profile, url);
if (!source_contents)
diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_factory.cc
deleted file mode 100644
index 9d80155..0000000
--- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc
+++ /dev/null
@@ -1,359 +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_factory.h"
-
-#include "base/command_line.h"
-#include "chrome/browser/about_flags.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_web_ui.h"
-#include "chrome/browser/extensions/extensions_ui.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/bookmarks_ui.h"
-#include "chrome/browser/ui/webui/bug_report_ui.h"
-#include "chrome/browser/ui/webui/constrained_html_ui.h"
-#include "chrome/browser/ui/webui/crashes_ui.h"
-#include "chrome/browser/ui/webui/devtools_ui.h"
-#include "chrome/browser/ui/webui/downloads_ui.h"
-#include "chrome/browser/ui/webui/flags_ui.h"
-#include "chrome/browser/ui/webui/gpu_internals_ui.h"
-#include "chrome/browser/ui/webui/history2_ui.h"
-#include "chrome/browser/ui/webui/history_ui.h"
-#include "chrome/browser/ui/webui/html_dialog_ui.h"
-#include "chrome/browser/ui/webui/net_internals_ui.h"
-#include "chrome/browser/ui/webui/new_tab_ui.h"
-#include "chrome/browser/ui/webui/options/options_ui.h"
-#include "chrome/browser/ui/webui/plugins_ui.h"
-#include "chrome/browser/ui/webui/print_preview_ui.h"
-#include "chrome/browser/ui/webui/remoting_ui.h"
-#include "chrome/browser/ui/webui/slideshow_ui.h"
-#include "chrome/browser/ui/webui/sync_internals_ui.h"
-#include "chrome/browser/ui/webui/textfields_ui.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/url_constants.h"
-#include "content/browser/tab_contents/tab_contents.h"
-#include "content/browser/webui/web_ui.h"
-#include "googleurl/src/gurl.h"
-
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/ui/webui/chromeos/imageburner_ui.h"
-#include "chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h"
-#include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h"
-#include "chrome/browser/ui/webui/chromeos/proxy_settings_ui.h"
-#include "chrome/browser/ui/webui/chromeos/register_page_ui.h"
-#include "chrome/browser/ui/webui/chromeos/sim_unlock_ui.h"
-#include "chrome/browser/ui/webui/chromeos/system_info_ui.h"
-#include "chrome/browser/ui/webui/filebrowse_ui.h"
-#include "chrome/browser/ui/webui/mediaplayer_ui.h"
-#endif
-
-#if defined(TOUCH_UI)
-#include "chrome/browser/ui/webui/keyboard_ui.h"
-#endif
-
-#if defined(TOUCH_UI) && defined(OS_CHROMEOS)
-#include "chrome/browser/ui/webui/chromeos/login/login_container_ui.h"
-#include "chrome/browser/ui/webui/chromeos/login/login_ui.h"
-#endif
-
-#if defined(OS_WIN)
-#include "chrome/browser/ui/webui/conflicts_ui.h"
-#endif
-
-namespace {
-
-// A function for creating a new WebUI. The caller owns the return value, which
-// may be NULL (for example, if the URL refers to an non-existent extension).
-typedef WebUI* (*WebUIFactoryFunction)(TabContents* tab_contents,
- const GURL& url);
-
-// Template for defining WebUIFactoryFunction.
-template<class T>
-WebUI* NewWebUI(TabContents* contents, const GURL& url) {
- return new T(contents);
-}
-
-// Special case for extensions.
-template<>
-WebUI* NewWebUI<ExtensionWebUI>(TabContents* contents, const GURL& url) {
- // Don't use a WebUI for incognito tabs because we require extensions to run
- // within a single process.
- ExtensionService* service = contents->profile()->GetExtensionService();
- if (service &&
- service->ExtensionBindingsAllowed(url)) {
- return new ExtensionWebUI(contents, url);
- }
- return NULL;
-}
-
-// Returns a function that can be used to create the right type of WebUI for a
-// tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated
-// with it. Even if the factory function is valid, it may yield a NULL WebUI
-// when invoked for a particular tab - see NewWebUI<ExtensionWebUI>.
-static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile,
- const GURL& url) {
- if (url.host() == chrome::kChromeUIDialogHost)
- return &NewWebUI<ConstrainedHtmlUI>;
-
- ExtensionService* service = profile ? profile->GetExtensionService() : NULL;
- if (service && service->ExtensionBindingsAllowed(url))
- return &NewWebUI<ExtensionWebUI>;
-
- // All platform builds of Chrome will need to have a cloud printing
- // dialog as backup. It's just that on Chrome OS, it's the only
- // print dialog.
- if (url.host() == chrome::kCloudPrintResourcesHost)
- return &NewWebUI<ExternalHtmlDialogUI>;
-
- // This will get called a lot to check all URLs, so do a quick check of other
- // schemes to filter out most URLs.
- if (!url.SchemeIs(chrome::kChromeDevToolsScheme) &&
- !url.SchemeIs(chrome::kChromeInternalScheme) &&
- !url.SchemeIs(chrome::kChromeUIScheme))
- return NULL;
-
- if (url.host() == chrome::kChromeUISyncResourcesHost ||
- url.host() == chrome::kChromeUIRemotingResourcesHost ||
- url.host() == chrome::kCloudPrintSetupHost)
- return &NewWebUI<HtmlDialogUI>;
-
- // Special case the new tab page. In older versions of Chrome, the new tab
- // page was hosted at chrome-internal:<blah>. This might be in people's saved
- // sessions or bookmarks, so we say any URL with that scheme triggers the new
- // tab page.
- if (url.host() == chrome::kChromeUINewTabHost ||
- url.SchemeIs(chrome::kChromeInternalScheme))
- return &NewWebUI<NewTabUI>;
-
- // Give about:about a generic Web UI so it can navigate to pages with Web UIs.
- if (url.spec() == chrome::kChromeUIAboutAboutURL)
- return &NewWebUI<WebUI>;
-
- // We must compare hosts only since some of the Web UIs append extra stuff
- // after the host name.
- if (url.host() == chrome::kChromeUIBookmarksHost)
- return &NewWebUI<BookmarksUI>;
- if (url.host() == chrome::kChromeUIBugReportHost)
- return &NewWebUI<BugReportUI>;
- if (url.host() == chrome::kChromeUICrashesHost)
- return &NewWebUI<CrashesUI>;
- if (url.host() == chrome::kChromeUIDevToolsHost)
- return &NewWebUI<DevToolsUI>;
-#if defined(OS_WIN)
- if (url.host() == chrome::kChromeUIConflictsHost)
- return &NewWebUI<ConflictsUI>;
-#endif
- if (url.host() == chrome::kChromeUIDownloadsHost)
- return &NewWebUI<DownloadsUI>;
- if (url.host() == chrome::kChromeUITextfieldsHost)
- return &NewWebUI<TextfieldsUI>;
- if (url.host() == chrome::kChromeUIExtensionsHost)
- return &NewWebUI<ExtensionsUI>;
- if (url.host() == chrome::kChromeUIHistoryHost)
- return &NewWebUI<HistoryUI>;
- if (url.host() == chrome::kChromeUIHistory2Host)
- return &NewWebUI<HistoryUI2>;
- if (url.host() == chrome::kChromeUIFlagsHost)
- return &NewWebUI<FlagsUI>;
-#if defined(TOUCH_UI)
- if (url.host() == chrome::kChromeUIKeyboardHost)
- return &NewWebUI<KeyboardUI>;
-#endif
- if (url.host() == chrome::kChromeUIGpuInternalsHost)
- return &NewWebUI<GpuInternalsUI>;
- if (url.host() == chrome::kChromeUINetInternalsHost)
- return &NewWebUI<NetInternalsUI>;
- if (url.host() == chrome::kChromeUIPluginsHost)
- return &NewWebUI<PluginsUI>;
- if (url.host() == chrome::kChromeUISyncInternalsHost)
- return &NewWebUI<SyncInternalsUI>;
-#if defined(ENABLE_REMOTING)
- if (url.host() == chrome::kChromeUIRemotingHost) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableRemoting)) {
- return &NewWebUI<RemotingUI>;
- }
- }
-#endif
-
-#if defined(OS_CHROMEOS)
- if (url.host() == chrome::kChromeUICollectedCookiesHost ||
- url.host() == chrome::kChromeUIHttpAuthHost) {
- return &NewWebUI<ConstrainedHtmlUI>;
- }
- if (url.host() == chrome::kChromeUIFileBrowseHost)
- return &NewWebUI<FileBrowseUI>;
- if (url.host() == chrome::kChromeUIImageBurnerHost)
- return &NewWebUI<ImageBurnUI>;
- if (url.host() == chrome::kChromeUIKeyboardOverlayHost)
- return &NewWebUI<KeyboardOverlayUI>;
- if (url.host() == chrome::kChromeUIMediaplayerHost)
- return &NewWebUI<MediaplayerUI>;
- if (url.host() == chrome::kChromeUIMobileSetupHost)
- return &NewWebUI<MobileSetupUI>;
- if (url.host() == chrome::kChromeUIProxySettingsHost)
- return &NewWebUI<chromeos::ProxySettingsUI>;
- if (url.host() == chrome::kChromeUIRegisterPageHost)
- return &NewWebUI<RegisterPageUI>;
- if (url.host() == chrome::kChromeUISettingsHost)
- return &NewWebUI<OptionsUI>;
- if (url.host() == chrome::kChromeUISlideshowHost)
- return &NewWebUI<SlideshowUI>;
- if (url.host() == chrome::kChromeUISimUnlockHost)
- return &NewWebUI<chromeos::SimUnlockUI>;
- if (url.host() == chrome::kChromeUISystemInfoHost)
- return &NewWebUI<SystemInfoUI>;
-#else
- if (url.host() == chrome::kChromeUISettingsHost)
- return &NewWebUI<OptionsUI>;
- if (url.host() == chrome::kChromeUIPrintHost) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnablePrintPreview)) {
- return &NewWebUI<PrintPreviewUI>;
- }
- }
-#endif // defined(OS_CHROMEOS)
-
-#if defined(TOUCH_UI) && defined(OS_CHROMEOS)
- if (url.host() == chrome::kChromeUILoginHost)
- return &NewWebUI<chromeos::LoginUI>;
- if (url.host() == chrome::kChromeUILoginContainerHost)
- return &NewWebUI<chromeos::LoginContainerUI>;
-#endif
-
- if (url.spec() == chrome::kChromeUIConstrainedHTMLTestURL)
- return &NewWebUI<ConstrainedHtmlUI>;
-
- return NULL;
-}
-
-} // namespace
-
-WebUI::TypeID ChromeWebUIFactory::GetWebUIType(Profile* profile,
- const GURL& url) const {
- WebUIFactoryFunction function = GetWebUIFactoryFunction(profile, url);
- return function ? reinterpret_cast<WebUI::TypeID>(function) : WebUI::kNoWebUI;
-}
-
-bool ChromeWebUIFactory::UseWebUIForURL(Profile* profile,
- const GURL& url) const {
- return GetWebUIType(profile, url) != WebUI::kNoWebUI;
-}
-
-bool ChromeWebUIFactory::HasWebUIScheme(const GURL& url) const {
- return url.SchemeIs(chrome::kChromeDevToolsScheme) ||
- url.SchemeIs(chrome::kChromeInternalScheme) ||
- url.SchemeIs(chrome::kChromeUIScheme) ||
- url.SchemeIs(chrome::kExtensionScheme);
-}
-
-bool ChromeWebUIFactory::IsURLAcceptableForWebUI(Profile* profile,
- const GURL& url) const {
- return UseWebUIForURL(profile, url) ||
- // javacsript: URLs are allowed to run in Web UI pages
- url.SchemeIs(chrome::kJavaScriptScheme) ||
- // It's possible to load about:blank in a Web UI renderer.
- // See http://crbug.com/42547
- url.spec() == chrome::kAboutBlankURL ||
- // about:crash, about:kill, about:hang, and about:shorthang are allowed.
- url.spec() == chrome::kAboutCrashURL ||
- url.spec() == chrome::kAboutKillURL ||
- url.spec() == chrome::kAboutHangURL ||
- url.spec() == chrome::kAboutShorthangURL;
-}
-
-WebUI* ChromeWebUIFactory::CreateWebUIForURL(TabContents* tab_contents,
- const GURL& url) const {
- WebUIFactoryFunction function = GetWebUIFactoryFunction(
- tab_contents->profile(), url);
- if (!function)
- return NULL;
- return (*function)(tab_contents, url);
-}
-
-void ChromeWebUIFactory::GetFaviconForURL(Profile* profile,
- FaviconService::GetFaviconRequest* request,
- const GURL& page_url) const {
- // All extensions but the bookmark manager get their favicon from the icons
- // part of the manifest.
- if (page_url.SchemeIs(chrome::kExtensionScheme) &&
- page_url.host() != extension_misc::kBookmarkManagerId) {
- ExtensionWebUI::GetFaviconForURL(profile, request, page_url);
- } else {
- history::FaviconData favicon;
- favicon.image_data = scoped_refptr<RefCountedMemory>(
- GetFaviconResourceBytes(profile, page_url));
- favicon.known_icon = favicon.image_data.get() != NULL &&
- favicon.image_data->size() > 0;
- request->ForwardResultAsync(
- FaviconService::FaviconDataCallback::TupleType(request->handle(),
- favicon));
- }
-}
-
-// static
-ChromeWebUIFactory* ChromeWebUIFactory::GetInstance() {
- return Singleton<ChromeWebUIFactory>::get();
-}
-
-ChromeWebUIFactory::ChromeWebUIFactory() {
-}
-
-ChromeWebUIFactory::~ChromeWebUIFactory() {
-}
-
-RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes(
- Profile* profile,
- 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.
- if (page_url.host() == extension_misc::kBookmarkManagerId)
- return BookmarksUI::GetFaviconResourceBytes();
-
- // The extension scheme is handled in GetFaviconForURL.
- if (page_url.SchemeIs(chrome::kExtensionScheme)) {
- NOTREACHED();
- return NULL;
- }
-
- if (!HasWebUIScheme(page_url))
- return NULL;
-
-#if defined(OS_WIN)
- if (page_url.host() == chrome::kChromeUIConflictsHost)
- return ConflictsUI::GetFaviconResourceBytes();
-#endif
-
- if (page_url.host() == chrome::kChromeUICrashesHost)
- return CrashesUI::GetFaviconResourceBytes();
-
- if (page_url.host() == chrome::kChromeUIDownloadsHost)
- return DownloadsUI::GetFaviconResourceBytes();
-
- if (page_url.host() == chrome::kChromeUIExtensionsHost)
- return ExtensionsUI::GetFaviconResourceBytes();
-
- if (page_url.host() == chrome::kChromeUIHistoryHost)
- return HistoryUI::GetFaviconResourceBytes();
-
- if (page_url.host() == chrome::kChromeUIHistory2Host)
- return HistoryUI2::GetFaviconResourceBytes();
-
- if (page_url.host() == chrome::kChromeUIFlagsHost)
- return FlagsUI::GetFaviconResourceBytes();
-
- if (page_url.host() == chrome::kChromeUISettingsHost)
- return OptionsUI::GetFaviconResourceBytes();
-
- if (page_url.host() == chrome::kChromeUIPluginsHost)
- return PluginsUI::GetFaviconResourceBytes();
-
-#if defined(ENABLE_REMOTING)
- if (page_url.host() == chrome::kChromeUIRemotingHost)
- return RemotingUI::GetFaviconResourceBytes();
-#endif
-
- return NULL;
-}
diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.h b/chrome/browser/ui/webui/chrome_web_ui_factory.h
deleted file mode 100644
index b2328f9..0000000
--- a/chrome/browser/ui/webui/chrome_web_ui_factory.h
+++ /dev/null
@@ -1,51 +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 CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_FACTORY_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_FACTORY_H_
-#pragma once
-
-#include "base/basictypes.h"
-#include "base/memory/singleton.h"
-#include "content/browser/webui/web_ui.h"
-#include "content/browser/webui/web_ui_factory.h"
-#include "chrome/browser/favicon_service.h"
-
-class WebUI;
-class GURL;
-class Profile;
-class RefCountedMemory;
-class TabContents;
-
-class ChromeWebUIFactory : public content::WebUIFactory {
- public:
- virtual WebUI::TypeID GetWebUIType(Profile* profile, const GURL& url) const;
- virtual bool UseWebUIForURL(Profile* profile, const GURL& url) const;
- virtual bool HasWebUIScheme(const GURL& url) const;
- virtual bool IsURLAcceptableForWebUI(Profile* profile, const GURL& url) const;
- virtual WebUI* CreateWebUIForURL(TabContents* tab_contents,
- const GURL& url) const;
-
- // Get the favicon for |page_url| and forward the result to the |request|
- // when loaded.
- void GetFaviconForURL(Profile* profile,
- FaviconService::GetFaviconRequest* request,
- const GURL& page_url) const;
-
- static ChromeWebUIFactory* GetInstance();
-
- private:
- virtual ~ChromeWebUIFactory();
-
- friend struct DefaultSingletonTraits<ChromeWebUIFactory>;
-
- // Gets the data for the favicon for a WebUI page. Returns NULL if the WebUI
- // does not have a favicon.
- RefCountedMemory* GetFaviconResourceBytes(Profile* profile,
- const GURL& page_url) const;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(ChromeWebUIFactory);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_FACTORY_H_
diff --git a/content/browser/webui/generic_handler.cc b/chrome/browser/ui/webui/generic_handler.cc
index f4f57dc..7bfe8f5 100644
--- a/content/browser/webui/generic_handler.cc
+++ b/chrome/browser/ui/webui/generic_handler.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 "content/browser/webui/generic_handler.h"
+#include "chrome/browser/ui/webui/generic_handler.h"
#include "base/logging.h"
#include "base/values.h"
diff --git a/content/browser/webui/generic_handler.h b/chrome/browser/ui/webui/generic_handler.h
index 408ecbb..bf40d08 100644
--- a/content/browser/webui/generic_handler.h
+++ b/chrome/browser/ui/webui/generic_handler.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_BROWSER_WEBUI_GENERIC_HANDLER_H_
-#define CONTENT_BROWSER_WEBUI_GENERIC_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_GENERIC_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_GENERIC_HANDLER_H_
#pragma once
#include "content/browser/webui/web_ui.h"
@@ -25,4 +25,4 @@ class GenericHandler : public WebUIMessageHandler {
DISALLOW_COPY_AND_ASSIGN(GenericHandler);
};
-#endif // CONTENT_BROWSER_WEBUI_GENERIC_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_GENERIC_HANDLER_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index f16a0b4..525a987 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3068,8 +3068,6 @@
'browser/ui/webui/chrome_url_data_manager_backend.h',
'browser/ui/webui/chrome_url_data_manager.cc',
'browser/ui/webui/chrome_url_data_manager.h',
- 'browser/ui/webui/chrome_web_ui_factory.cc',
- 'browser/ui/webui/chrome_web_ui_factory.h',
'browser/ui/webui/chromeos/imageburner_ui.cc',
'browser/ui/webui/chromeos/imageburner_ui.h',
'browser/ui/webui/chromeos/keyboard_overlay_ui.cc',
@@ -3123,6 +3121,8 @@
'browser/ui/webui/flags_ui.h',
'browser/ui/webui/foreign_session_handler.cc',
'browser/ui/webui/foreign_session_handler.h',
+ 'browser/ui/webui/generic_handler.cc',
+ 'browser/ui/webui/generic_handler.h',
'browser/ui/webui/gpu_internals_ui.cc',
'browser/ui/webui/gpu_internals_ui.h',
'browser/ui/webui/history2_ui.cc',
diff --git a/content/browser/browsing_instance.cc b/content/browser/browsing_instance.cc
index be55f5e..1759fc0 100644
--- a/content/browser/browsing_instance.cc
+++ b/content/browser/browsing_instance.cc
@@ -9,10 +9,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
-#include "content/browser/content_browser_client.h"
#include "content/browser/site_instance.h"
#include "content/browser/webui/web_ui_factory.h"
-#include "content/common/content_client.h"
// static
BrowsingInstance::ProfileSiteInstanceMap
@@ -41,10 +39,9 @@ bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) {
return true;
// DevTools pages have WebUI type but should not reuse the same host.
- if (content::WebUIFactory::Get()->UseWebUIForURL(profile_, url) &&
- !url.SchemeIs(chrome::kChromeDevToolsScheme)) {
+ if (WebUIFactory::UseWebUIForURL(profile_, url) &&
+ !url.SchemeIs(chrome::kChromeDevToolsScheme))
return true;
- }
// In all other cases, don't use process-per-site logic.
return false;
diff --git a/content/browser/content_browser_client.cc b/content/browser/content_browser_client.cc
deleted file mode 100644
index b96b55e..0000000
--- a/content/browser/content_browser_client.cc
+++ /dev/null
@@ -1,17 +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/content_browser_client.h"
-
-#include "base/memory/singleton.h"
-#include "content/browser/webui/empty_web_ui_factory.h"
-
-namespace content {
-
-WebUIFactory* ContentBrowserClient::GetWebUIFactory() {
- // Return an empty factory so callsites don't have to check for NULL.
- return EmptyWebUIFactory::Get();
-}
-
-} // namespace content
diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h
index c7218f8..b916263 100644
--- a/content/browser/content_browser_client.h
+++ b/content/browser/content_browser_client.h
@@ -14,8 +14,6 @@ class RenderViewHost;
namespace content {
-class WebUIFactory;
-
// Embedder API for participating in browser logic.
class ContentBrowserClient {
public:
@@ -23,9 +21,6 @@ class ContentBrowserClient {
virtual void PreCreateRenderView(RenderViewHost* render_view_host,
Profile* profile,
const GURL& url) {}
-
- // Gets the WebUIFactory which will be responsible for generating WebUIs.
- virtual WebUIFactory* GetWebUIFactory();
};
} // namespace content
diff --git a/content/browser/site_instance.cc b/content/browser/site_instance.cc
index 26565a1..a59d1ca 100644
--- a/content/browser/site_instance.cc
+++ b/content/browser/site_instance.cc
@@ -8,10 +8,8 @@
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/common/url_constants.h"
#include "content/browser/browsing_instance.h"
-#include "content/browser/content_browser_client.h"
#include "content/browser/webui/web_ui_factory.h"
#include "content/common/notification_service.h"
-#include "content/common/content_client.h"
#include "net/base/registry_controlled_domain.h"
// We treat javascript:, about:crash, about:hang, and about:shorthang as the
@@ -213,7 +211,7 @@ RenderProcessHost::Type SiteInstance::RendererTypeForURL(const GURL& url) {
return RenderProcessHost::TYPE_EXTENSION;
// TODO(erikkay) creis recommends using UseWebUIForURL instead.
- if (content::WebUIFactory::Get()->HasWebUIScheme(url))
+ if (WebUIFactory::HasWebUIScheme(url))
return RenderProcessHost::TYPE_WEBUI;
return RenderProcessHost::TYPE_NORMAL;
diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc
index a00d40c..ee56978 100644
--- a/content/browser/tab_contents/render_view_host_manager.cc
+++ b/content/browser/tab_contents/render_view_host_manager.cc
@@ -21,7 +21,6 @@
#include "content/browser/tab_contents/tab_contents_view.h"
#include "content/browser/webui/web_ui.h"
#include "content/browser/webui/web_ui_factory.h"
-#include "content/common/content_client.h"
#include "content/common/notification_service.h"
#include "content/common/notification_type.h"
#include "content/common/view_messages.h"
@@ -302,14 +301,13 @@ bool RenderViewHostManager::ShouldSwapProcessesForNavigation(
const GURL& current_url = (cur_entry) ? cur_entry->url() :
render_view_host_->site_instance()->site();
Profile* profile = delegate_->GetControllerForRenderManager().profile();
- const content::WebUIFactory* web_ui_factory = content::WebUIFactory::Get();
- if (web_ui_factory->UseWebUIForURL(profile, current_url)) {
+ if (WebUIFactory::UseWebUIForURL(profile, current_url)) {
// Force swap if it's not an acceptable URL for Web UI.
- if (!web_ui_factory->IsURLAcceptableForWebUI(profile, new_entry->url()))
+ if (!WebUIFactory::IsURLAcceptableForWebUI(profile, new_entry->url()))
return true;
} else {
// Force swap if it's a Web UI URL.
- if (web_ui_factory->UseWebUIForURL(profile, new_entry->url()))
+ if (WebUIFactory::UseWebUIForURL(profile, new_entry->url()))
return true;
}
@@ -386,9 +384,8 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry(
// want to use the curr_instance if it has no site, since it will have a
// RenderProcessHost of TYPE_NORMAL. Create a new SiteInstance for this
// URL instead (with the correct process type).
- if (content::WebUIFactory::Get()->UseWebUIForURL(profile, dest_url)) {
+ if (WebUIFactory::UseWebUIForURL(profile, dest_url))
return SiteInstance::CreateSiteInstanceForURL(profile, dest_url);
- }
// Normally the "site" on the SiteInstance is set lazily when the load
// actually commits. This is to support better process sharing in case
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 61bc4b5..7ac1749 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -66,7 +66,6 @@
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "content/browser/child_process_security_policy.h"
-#include "content/browser/content_browser_client.h"
#include "content/browser/host_zoom_map.h"
#include "content/browser/in_process_webkit/session_storage_namespace.h"
#include "content/browser/renderer_host/render_process_host.h"
@@ -80,8 +79,7 @@
#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "content/browser/tab_contents/tab_contents_observer.h"
#include "content/browser/tab_contents/tab_contents_view.h"
-#include "content/browser/webui/web_ui_factory.h"
-#include "content/common/content_client.h"
+#include "content/browser/webui/web_ui.h"
#include "content/common/navigation_types.h"
#include "content/common/notification_service.h"
#include "content/common/view_messages.h"
@@ -252,7 +250,7 @@ TabContents::TabContents(Profile* profile,
#endif
suppress_javascript_messages_(false),
is_showing_before_unload_dialog_(false),
- opener_web_ui_type_(WebUI::kNoWebUI),
+ opener_web_ui_type_(WebUIFactory::kNoWebUI),
language_state_(&controller_),
closed_by_user_gesture_(false),
minimum_zoom_percent_(
@@ -552,7 +550,7 @@ bool TabContents::ShouldDisplayURL() {
}
// We always display the URL for non-WebUI URLs to prevent spoofing.
- if (entry && !content::WebUIFactory::Get()->HasWebUIScheme(entry->url()))
+ if (entry && !WebUIFactory::HasWebUIScheme(entry->url()))
return true;
WebUI* web_ui = GetWebUIForCurrentState();
@@ -715,9 +713,8 @@ bool TabContents::NavigateToEntry(
// 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(profile(),
- entry.url());
+ bool is_allowed_in_web_ui_renderer =
+ WebUIFactory::IsURLAcceptableForWebUI(profile(), entry.url());
CHECK(!BindingsPolicy::is_web_ui_enabled(enabled_bindings) ||
is_allowed_in_web_ui_renderer);
@@ -1601,27 +1598,23 @@ WebUI* TabContents::GetWebUIForCurrentState() {
return render_manager_.web_ui();
}
-WebUI::TypeID TabContents::GetWebUITypeForCurrentState() {
- return content::WebUIFactory::Get()->GetWebUIType(profile(), GetURL());
-}
-
void TabContents::DidNavigateMainFramePostCommit(
const NavigationController::LoadCommittedDetails& details,
const ViewHostMsg_FrameNavigate_Params& params) {
- if (opener_web_ui_type_ != WebUI::kNoWebUI) {
+ if (opener_web_ui_type_ != WebUIFactory::kNoWebUI) {
// If this is a window.open navigation, use the same WebUI as the renderer
// that opened the window, as long as both renderers have the same
// privileges.
- if (delegate_ && opener_web_ui_type_ == GetWebUITypeForCurrentState()) {
- WebUI* web_ui = content::GetContentClient()->browser()->
- GetWebUIFactory()->CreateWebUIForURL(this, GetURL());
+ if (opener_web_ui_type_ ==
+ WebUIFactory::GetWebUIType(profile(), GetURL())) {
+ WebUI* web_ui = WebUIFactory::CreateWebUIForURL(this, GetURL());
// web_ui might be NULL if the URL refers to a non-existent extension.
if (web_ui) {
render_manager_.SetWebUIPostCommit(web_ui);
web_ui->RenderViewCreated(render_view_host());
}
}
- opener_web_ui_type_ = WebUI::kNoWebUI;
+ opener_web_ui_type_ = WebUIFactory::kNoWebUI;
}
if (details.is_user_initiated_main_frame_load()) {
@@ -2001,8 +1994,9 @@ void TabContents::RenderViewCreated(RenderViewHost* render_view_host) {
// When we're creating views, we're still doing initial setup, so we always
// use the pending Web UI rather than any possibly existing committed one.
- if (render_manager_.pending_web_ui())
+ if (render_manager_.pending_web_ui()) {
render_manager_.pending_web_ui()->RenderViewCreated(render_view_host);
+ }
if (entry->IsViewSourceMode()) {
// Put the renderer in view source mode.
@@ -2577,7 +2571,7 @@ NavigationController& TabContents::GetControllerForRenderManager() {
}
WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) {
- return content::WebUIFactory::Get()->CreateWebUIForURL(this, url);
+ return WebUIFactory::CreateWebUIForURL(this, url);
}
NavigationEntry*
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 60602f6..daa7813 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -31,7 +31,7 @@
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/page_navigator.h"
#include "content/browser/tab_contents/render_view_host_manager.h"
-#include "content/browser/webui/web_ui.h"
+#include "content/browser/webui/web_ui_factory.h"
#include "content/common/notification_registrar.h"
#include "content/common/property_bag.h"
#include "content/common/renderer_preferences.h"
@@ -600,7 +600,7 @@ class TabContents : public PageNavigator,
return &renderer_preferences_;
}
- void set_opener_web_ui_type(WebUI::TypeID opener_web_ui_type) {
+ void set_opener_web_ui_type(WebUITypeID opener_web_ui_type) {
opener_web_ui_type_ = opener_web_ui_type;
}
@@ -693,9 +693,6 @@ class TabContents : public PageNavigator,
return safebrowsing_detection_host_.get();
}
- // Query the WebUIFactory for the TypeID for the current URL.
- WebUI::TypeID GetWebUITypeForCurrentState();
-
protected:
// from RenderViewHostDelegate.
virtual bool OnMessageReceived(const IPC::Message& message);
@@ -1177,7 +1174,7 @@ class TabContents : public PageNavigator,
// If this tab was created from a renderer using window.open, this will be
// non-NULL and represent the WebUI of the opening renderer.
- WebUI::TypeID opener_web_ui_type_;
+ WebUITypeID opener_web_ui_type_;
// The time that we started to create the new tab page.
base::TimeTicks new_tab_start_time_;
diff --git a/content/browser/tab_contents/tab_contents_view.cc b/content/browser/tab_contents/tab_contents_view.cc
index 09db402..a4e5c7b 100644
--- a/content/browser/tab_contents/tab_contents_view.cc
+++ b/content/browser/tab_contents/tab_contents_view.cc
@@ -37,7 +37,8 @@ void TabContentsView::CreateNewWindow(
route_id,
tab_contents_->profile(),
tab_contents_->GetSiteInstance(),
- tab_contents_->GetWebUITypeForCurrentState(),
+ WebUIFactory::GetWebUIType(tab_contents_->profile(),
+ tab_contents_->GetURL()),
tab_contents_,
params.window_container_type,
params.frame_name);
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 fd29847..0000000
--- a/content/browser/webui/empty_web_ui_factory.cc
+++ /dev/null
@@ -1,44 +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() {
-}
-
-WebUI* EmptyWebUIFactory::CreateWebUIForURL(TabContents* source,
- const GURL& url) const {
- return NULL;
-}
-
-WebUI::TypeID EmptyWebUIFactory::GetWebUIType(Profile* profile,
- const GURL& url) const {
- return WebUI::kNoWebUI;
-}
-
-bool EmptyWebUIFactory::UseWebUIForURL(Profile* profile,
- const GURL& url) const {
- return false;
-}
-
-bool EmptyWebUIFactory::HasWebUIScheme(const GURL& url) const {
- return false;
-}
-
-bool EmptyWebUIFactory::IsURLAcceptableForWebUI(Profile* profile,
- 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 3778220..0000000
--- a/content/browser/webui/empty_web_ui_factory.h
+++ /dev/null
@@ -1,37 +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/browser/webui/web_ui_factory.h"
-
-namespace content {
-
-// A stubbed out version of WebUIFactory.
-class EmptyWebUIFactory : public content::WebUIFactory {
- public:
- // Returns the singleton instance.
- static EmptyWebUIFactory* GetInstance();
-
- virtual WebUI* CreateWebUIForURL(TabContents* source,
- const GURL& url) const;
- virtual WebUI::TypeID GetWebUIType(Profile* profile,
- const GURL& url) const;
- virtual bool UseWebUIForURL(Profile* profile, const GURL& url) const;
- virtual bool HasWebUIScheme(const GURL& url) const;
- virtual bool IsURLAcceptableForWebUI(Profile* profile,
- const GURL& url) const;
-
- private:
- EmptyWebUIFactory();
- virtual ~EmptyWebUIFactory();
-
- friend struct DefaultSingletonTraits<EmptyWebUIFactory>;
-};
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_WEBUI_EMPTY_WEB_UI_FACTORY_H_
diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc
index 3cc3633..9202958 100644
--- a/content/browser/webui/web_ui.cc
+++ b/content/browser/webui/web_ui.cc
@@ -10,13 +10,14 @@
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/generic_handler.h"
#include "chrome/common/bindings_policy.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/render_messages.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
-#include "content/browser/webui/generic_handler.h"
namespace {
@@ -58,8 +59,6 @@ WebUI::~WebUI() {
// WebUI, public: -------------------------------------------------------------
-const WebUI::TypeID WebUI::kNoWebUI = NULL;
-
void WebUI::ProcessWebUIMessage(
const ExtensionHostMsg_DomMessage_Params& params) {
// Look up the callback for this message.
diff --git a/content/browser/webui/web_ui.h b/content/browser/webui/web_ui.h
index 4d0215f..98adcb1 100644
--- a/content/browser/webui/web_ui.h
+++ b/content/browser/webui/web_ui.h
@@ -144,14 +144,6 @@ class WebUI {
TabContents* tab_contents() const { return tab_contents_; }
- // An opaque identifier used to identify a WebUI. This can only be compared to
- // kNoWebUI or other WebUI types. See GetWebUIType.
- typedef void* TypeID;
-
- // A special WebUI type that signifies that a given page would not use the
- // Web UI system.
- static const TypeID kNoWebUI;
-
protected:
void AddMessageHandler(WebUIMessageHandler* handler);
diff --git a/content/browser/webui/web_ui_factory.cc b/content/browser/webui/web_ui_factory.cc
index 63a8c8e..04776a5 100644
--- a/content/browser/webui/web_ui_factory.cc
+++ b/content/browser/webui/web_ui_factory.cc
@@ -4,14 +4,344 @@
#include "content/browser/webui/web_ui_factory.h"
-#include "content/browser/content_browser_client.h"
-#include "content/common/content_client.h"
+#include "base/command_line.h"
+#include "chrome/browser/about_flags.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_web_ui.h"
+#include "chrome/browser/extensions/extensions_ui.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/bookmarks_ui.h"
+#include "chrome/browser/ui/webui/bug_report_ui.h"
+#include "chrome/browser/ui/webui/constrained_html_ui.h"
+#include "chrome/browser/ui/webui/crashes_ui.h"
+#include "chrome/browser/ui/webui/devtools_ui.h"
+#include "chrome/browser/ui/webui/downloads_ui.h"
+#include "chrome/browser/ui/webui/flags_ui.h"
+#include "chrome/browser/ui/webui/gpu_internals_ui.h"
+#include "chrome/browser/ui/webui/history2_ui.h"
+#include "chrome/browser/ui/webui/history_ui.h"
+#include "chrome/browser/ui/webui/html_dialog_ui.h"
+#include "chrome/browser/ui/webui/net_internals_ui.h"
+#include "chrome/browser/ui/webui/new_tab_ui.h"
+#include "chrome/browser/ui/webui/options/options_ui.h"
+#include "chrome/browser/ui/webui/plugins_ui.h"
+#include "chrome/browser/ui/webui/print_preview_ui.h"
+#include "chrome/browser/ui/webui/remoting_ui.h"
+#include "chrome/browser/ui/webui/slideshow_ui.h"
+#include "chrome/browser/ui/webui/sync_internals_ui.h"
+#include "chrome/browser/ui/webui/textfields_ui.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/url_constants.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "googleurl/src/gurl.h"
-namespace content {
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/ui/webui/chromeos/imageburner_ui.h"
+#include "chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h"
+#include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h"
+#include "chrome/browser/ui/webui/chromeos/proxy_settings_ui.h"
+#include "chrome/browser/ui/webui/chromeos/register_page_ui.h"
+#include "chrome/browser/ui/webui/chromeos/sim_unlock_ui.h"
+#include "chrome/browser/ui/webui/chromeos/system_info_ui.h"
+#include "chrome/browser/ui/webui/filebrowse_ui.h"
+#include "chrome/browser/ui/webui/mediaplayer_ui.h"
+#endif
+
+#if defined(TOUCH_UI)
+#include "chrome/browser/ui/webui/keyboard_ui.h"
+#endif
+
+#if defined(TOUCH_UI) && defined(OS_CHROMEOS)
+#include "chrome/browser/ui/webui/chromeos/login/login_container_ui.h"
+#include "chrome/browser/ui/webui/chromeos/login/login_ui.h"
+#endif
+
+#if defined(OS_WIN)
+#include "chrome/browser/ui/webui/conflicts_ui.h"
+#endif
+
+const WebUITypeID WebUIFactory::kNoWebUI = NULL;
+
+// A function for creating a new WebUI. The caller owns the return value, which
+// may be NULL (for example, if the URL refers to an non-existent extension).
+typedef WebUI* (*WebUIFactoryFunction)(TabContents* tab_contents,
+ const GURL& url);
+
+// Template for defining WebUIFactoryFunction.
+template<class T>
+WebUI* NewWebUI(TabContents* contents, const GURL& url) {
+ return new T(contents);
+}
+
+// Special case for extensions.
+template<>
+WebUI* NewWebUI<ExtensionWebUI>(TabContents* contents, const GURL& url) {
+ // Don't use a WebUI for incognito tabs because we require extensions to run
+ // within a single process.
+ ExtensionService* service = contents->profile()->GetExtensionService();
+ if (service &&
+ service->ExtensionBindingsAllowed(url)) {
+ return new ExtensionWebUI(contents, url);
+ }
+ return NULL;
+}
+
+// Returns a function that can be used to create the right type of WebUI for a
+// tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated
+// with it. Even if the factory function is valid, it may yield a NULL WebUI
+// when invoked for a particular tab - see NewWebUI<ExtensionWebUI>.
+static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile,
+ const GURL& url) {
+ if (url.host() == chrome::kChromeUIDialogHost)
+ return &NewWebUI<ConstrainedHtmlUI>;
+
+ ExtensionService* service = profile ? profile->GetExtensionService() : NULL;
+ if (service && service->ExtensionBindingsAllowed(url))
+ return &NewWebUI<ExtensionWebUI>;
+
+ // All platform builds of Chrome will need to have a cloud printing
+ // dialog as backup. It's just that on Chrome OS, it's the only
+ // print dialog.
+ if (url.host() == chrome::kCloudPrintResourcesHost)
+ return &NewWebUI<ExternalHtmlDialogUI>;
+
+ // This will get called a lot to check all URLs, so do a quick check of other
+ // schemes to filter out most URLs.
+ if (!url.SchemeIs(chrome::kChromeDevToolsScheme) &&
+ !url.SchemeIs(chrome::kChromeInternalScheme) &&
+ !url.SchemeIs(chrome::kChromeUIScheme))
+ return NULL;
+
+ if (url.host() == chrome::kChromeUISyncResourcesHost ||
+ url.host() == chrome::kChromeUIRemotingResourcesHost ||
+ url.host() == chrome::kCloudPrintSetupHost)
+ return &NewWebUI<HtmlDialogUI>;
+
+ // Special case the new tab page. In older versions of Chrome, the new tab
+ // page was hosted at chrome-internal:<blah>. This might be in people's saved
+ // sessions or bookmarks, so we say any URL with that scheme triggers the new
+ // tab page.
+ if (url.host() == chrome::kChromeUINewTabHost ||
+ url.SchemeIs(chrome::kChromeInternalScheme))
+ return &NewWebUI<NewTabUI>;
+
+ // Give about:about a generic Web UI so it can navigate to pages with Web UIs.
+ if (url.spec() == chrome::kChromeUIAboutAboutURL)
+ return &NewWebUI<WebUI>;
+
+ // We must compare hosts only since some of the Web UIs append extra stuff
+ // after the host name.
+ if (url.host() == chrome::kChromeUIBookmarksHost)
+ return &NewWebUI<BookmarksUI>;
+ if (url.host() == chrome::kChromeUIBugReportHost)
+ return &NewWebUI<BugReportUI>;
+ if (url.host() == chrome::kChromeUICrashesHost)
+ return &NewWebUI<CrashesUI>;
+ if (url.host() == chrome::kChromeUIDevToolsHost)
+ return &NewWebUI<DevToolsUI>;
+#if defined(OS_WIN)
+ if (url.host() == chrome::kChromeUIConflictsHost)
+ return &NewWebUI<ConflictsUI>;
+#endif
+ if (url.host() == chrome::kChromeUIDownloadsHost)
+ return &NewWebUI<DownloadsUI>;
+ if (url.host() == chrome::kChromeUITextfieldsHost)
+ return &NewWebUI<TextfieldsUI>;
+ if (url.host() == chrome::kChromeUIExtensionsHost)
+ return &NewWebUI<ExtensionsUI>;
+ if (url.host() == chrome::kChromeUIHistoryHost)
+ return &NewWebUI<HistoryUI>;
+ if (url.host() == chrome::kChromeUIHistory2Host)
+ return &NewWebUI<HistoryUI2>;
+ if (url.host() == chrome::kChromeUIFlagsHost)
+ return &NewWebUI<FlagsUI>;
+#if defined(TOUCH_UI)
+ if (url.host() == chrome::kChromeUIKeyboardHost)
+ return &NewWebUI<KeyboardUI>;
+#endif
+ if (url.host() == chrome::kChromeUIGpuInternalsHost)
+ return &NewWebUI<GpuInternalsUI>;
+ if (url.host() == chrome::kChromeUINetInternalsHost)
+ return &NewWebUI<NetInternalsUI>;
+ if (url.host() == chrome::kChromeUIPluginsHost)
+ return &NewWebUI<PluginsUI>;
+ if (url.host() == chrome::kChromeUISyncInternalsHost)
+ return &NewWebUI<SyncInternalsUI>;
+#if defined(ENABLE_REMOTING)
+ if (url.host() == chrome::kChromeUIRemotingHost) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableRemoting)) {
+ return &NewWebUI<RemotingUI>;
+ }
+ }
+#endif
+
+#if defined(OS_CHROMEOS)
+ if (url.host() == chrome::kChromeUICollectedCookiesHost ||
+ url.host() == chrome::kChromeUIHttpAuthHost)
+ return &NewWebUI<ConstrainedHtmlUI>;
+ if (url.host() == chrome::kChromeUIFileBrowseHost)
+ return &NewWebUI<FileBrowseUI>;
+ if (url.host() == chrome::kChromeUIImageBurnerHost)
+ return &NewWebUI<ImageBurnUI>;
+ if (url.host() == chrome::kChromeUIKeyboardOverlayHost)
+ return &NewWebUI<KeyboardOverlayUI>;
+ if (url.host() == chrome::kChromeUIMediaplayerHost)
+ return &NewWebUI<MediaplayerUI>;
+ if (url.host() == chrome::kChromeUIMobileSetupHost)
+ return &NewWebUI<MobileSetupUI>;
+ if (url.host() == chrome::kChromeUIProxySettingsHost)
+ return &NewWebUI<chromeos::ProxySettingsUI>;
+ if (url.host() == chrome::kChromeUIRegisterPageHost)
+ return &NewWebUI<RegisterPageUI>;
+ if (url.host() == chrome::kChromeUISettingsHost)
+ return &NewWebUI<OptionsUI>;
+ if (url.host() == chrome::kChromeUISlideshowHost)
+ return &NewWebUI<SlideshowUI>;
+ if (url.host() == chrome::kChromeUISimUnlockHost)
+ return &NewWebUI<chromeos::SimUnlockUI>;
+ if (url.host() == chrome::kChromeUISystemInfoHost)
+ return &NewWebUI<SystemInfoUI>;
+#else
+ if (url.host() == chrome::kChromeUISettingsHost)
+ return &NewWebUI<OptionsUI>;
+ if (url.host() == chrome::kChromeUIPrintHost) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnablePrintPreview)) {
+ return &NewWebUI<PrintPreviewUI>;
+ }
+ }
+#endif // defined(OS_CHROMEOS)
+
+#if defined(TOUCH_UI) && defined(OS_CHROMEOS)
+ if (url.host() == chrome::kChromeUILoginHost)
+ return &NewWebUI<chromeos::LoginUI>;
+ if (url.host() == chrome::kChromeUILoginContainerHost)
+ return &NewWebUI<chromeos::LoginContainerUI>;
+#endif
+
+ if (url.spec() == chrome::kChromeUIConstrainedHTMLTestURL)
+ return &NewWebUI<ConstrainedHtmlUI>;
+
+ return NULL;
+}
+
+// static
+WebUITypeID WebUIFactory::GetWebUIType(Profile* profile, const GURL& url) {
+ WebUIFactoryFunction function = GetWebUIFactoryFunction(profile, url);
+ return function ? reinterpret_cast<WebUITypeID>(function) : kNoWebUI;
+}
+
+// static
+bool WebUIFactory::HasWebUIScheme(const GURL& url) {
+ return url.SchemeIs(chrome::kChromeDevToolsScheme) ||
+ url.SchemeIs(chrome::kChromeInternalScheme) ||
+ url.SchemeIs(chrome::kChromeUIScheme) ||
+ url.SchemeIs(chrome::kExtensionScheme);
+}
// static
-WebUIFactory* WebUIFactory::Get() {
- return content::GetContentClient()->browser()->GetWebUIFactory();
+bool WebUIFactory::UseWebUIForURL(Profile* profile, const GURL& url) {
+ return GetWebUIFactoryFunction(profile, url) != NULL;
}
-} // namespace content
+// static
+bool WebUIFactory::IsURLAcceptableForWebUI(Profile* profile, const GURL& url) {
+ return UseWebUIForURL(profile, url) ||
+ // javacsript: URLs are allowed to run in Web UI pages
+ url.SchemeIs(chrome::kJavaScriptScheme) ||
+ // It's possible to load about:blank in a Web UI renderer.
+ // See http://crbug.com/42547
+ url.spec() == chrome::kAboutBlankURL ||
+ // about:crash, about:kill, about:hang, and about:shorthang are allowed.
+ url.spec() == chrome::kAboutCrashURL ||
+ url.spec() == chrome::kAboutKillURL ||
+ url.spec() == chrome::kAboutHangURL ||
+ url.spec() == chrome::kAboutShorthangURL;
+}
+
+// static
+WebUI* WebUIFactory::CreateWebUIForURL(TabContents* tab_contents,
+ const GURL& url) {
+ WebUIFactoryFunction function = GetWebUIFactoryFunction(
+ tab_contents->profile(), url);
+ if (!function)
+ return NULL;
+ return (*function)(tab_contents, url);
+}
+
+// static
+void WebUIFactory::GetFaviconForURL(Profile* profile,
+ FaviconService::GetFaviconRequest* request,
+ const GURL& page_url) {
+ // All extensions but the bookmark manager get their favicon from the icons
+ // part of the manifest.
+ if (page_url.SchemeIs(chrome::kExtensionScheme) &&
+ page_url.host() != extension_misc::kBookmarkManagerId) {
+ ExtensionWebUI::GetFaviconForURL(profile, request, page_url);
+ } else {
+ history::FaviconData favicon;
+ favicon.image_data = scoped_refptr<RefCountedMemory>(
+ WebUIFactory::GetFaviconResourceBytes(profile, page_url));
+ favicon.known_icon = favicon.image_data.get() != NULL &&
+ favicon.image_data->size() > 0;
+ request->ForwardResultAsync(
+ FaviconService::FaviconDataCallback::TupleType(request->handle(),
+ favicon));
+ }
+}
+
+// static
+RefCountedMemory* WebUIFactory::GetFaviconResourceBytes(Profile* profile,
+ const GURL& page_url) {
+ // The bookmark manager is a chrome extension, so we have to check for it
+ // before we check for extension scheme.
+ if (page_url.host() == extension_misc::kBookmarkManagerId)
+ return BookmarksUI::GetFaviconResourceBytes();
+
+ // The extension scheme is handled in GetFaviconForURL.
+ if (page_url.SchemeIs(chrome::kExtensionScheme)) {
+ NOTREACHED();
+ return NULL;
+ }
+
+ if (!HasWebUIScheme(page_url))
+ return NULL;
+
+#if defined(OS_WIN)
+ if (page_url.host() == chrome::kChromeUIConflictsHost)
+ return ConflictsUI::GetFaviconResourceBytes();
+#endif
+
+ if (page_url.host() == chrome::kChromeUICrashesHost)
+ return CrashesUI::GetFaviconResourceBytes();
+
+ if (page_url.host() == chrome::kChromeUIDownloadsHost)
+ return DownloadsUI::GetFaviconResourceBytes();
+
+ if (page_url.host() == chrome::kChromeUIExtensionsHost)
+ return ExtensionsUI::GetFaviconResourceBytes();
+
+ if (page_url.host() == chrome::kChromeUIHistoryHost)
+ return HistoryUI::GetFaviconResourceBytes();
+
+ if (page_url.host() == chrome::kChromeUIHistory2Host)
+ return HistoryUI2::GetFaviconResourceBytes();
+
+ if (page_url.host() == chrome::kChromeUIFlagsHost)
+ return FlagsUI::GetFaviconResourceBytes();
+
+ if (page_url.host() == chrome::kChromeUISettingsHost)
+ return OptionsUI::GetFaviconResourceBytes();
+
+ if (page_url.host() == chrome::kChromeUIPluginsHost)
+ return PluginsUI::GetFaviconResourceBytes();
+
+#if defined(ENABLE_REMOTING)
+ if (page_url.host() == chrome::kChromeUIRemotingHost)
+ return RemotingUI::GetFaviconResourceBytes();
+#endif
+
+ return NULL;
+}
diff --git a/content/browser/webui/web_ui_factory.h b/content/browser/webui/web_ui_factory.h
index 0658c43..2be656a 100644
--- a/content/browser/webui/web_ui_factory.h
+++ b/content/browser/webui/web_ui_factory.h
@@ -6,51 +6,62 @@
#define CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_
#pragma once
-#include "content/browser/webui/web_ui.h"
+#include "base/basictypes.h"
+#include "chrome/browser/favicon_service.h"
+class WebUI;
+class GURL;
class Profile;
+class RefCountedMemory;
class TabContents;
-class GURL;
-namespace content {
+// An opaque identifier used to identify a WebUI. This can only be compared to
+// kNoWebUI or other WebUI types. See GetWebUIType.
+typedef void* WebUITypeID;
-// Interface for an object which controls which URLs are considered WebUI URLs
-// and creates WebUI instances for given URLs.
class WebUIFactory {
public:
- // Returns a WebUI instance for the given URL, or NULL if the URL doesn't
- // correspond to a WebUI.
- virtual WebUI* CreateWebUIForURL(TabContents* source,
- 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
- // if CreateWebUIForURL would succeed.
- virtual WebUI::TypeID GetWebUIType(Profile* profile,
- const GURL& url) const = 0;
-
- // Shorthand for the above, but returns a simple yes/no.
- virtual bool UseWebUIForURL(Profile* profile, const GURL& url) const = 0;
-
- // Returns true if the url has a scheme for WebUI. This differs from the above
- // in that it only checks the scheme; it is faster and can be used to
- // determine security policy.
- virtual bool HasWebUIScheme(const GURL& url) const = 0;
-
- // Returns true if the given URL can be loaded by Web UI system. This allows
- // URLs with WebUI types (as above) and also URLs that can be loaded by
- // normal tabs such as javascript: URLs or about:hang.
- virtual bool IsURLAcceptableForWebUI(Profile* profile,
- const GURL& url) const = 0;
-
- virtual ~WebUIFactory() {}
-
- // Helper function to streamline retrieval of the current WebUIFactory. Only
- // to be used in content/.
- static WebUIFactory* Get();
-};
+ // A special WebUI type that signifies that a given page would not use the
+ // Web UI system.
+ static const WebUITypeID kNoWebUI;
+
+ // Returns a type identifier indicating what WebUI we would use for the
+ // given URL. This is useful for comparing the potential WebUIs for two URLs.
+ // Returns kNoWebUI if the given URL will not use the Web UI system.
+ static WebUITypeID GetWebUIType(Profile* profile, const GURL& url);
+
+ // Returns true if the given URL's scheme would trigger the Web UI system.
+ // This is a less precise test than UseDONUIForURL, which tells you whether
+ // that specific URL matches a known one. This one is faster and can be used
+ // to determine security policy.
+ static bool HasWebUIScheme(const GURL& url);
+ // Returns true if the given URL must use the Web UI system.
+ static bool UseWebUIForURL(Profile* profile, const GURL& url);
-} // namespace content
+ // Returns true if the given URL can be loaded by Web UI system. This
+ // includes URLs that can be loaded by normal tabs as well, such as
+ // javascript: URLs or about:hang.
+ static bool IsURLAcceptableForWebUI(Profile* profile, const GURL& url);
+
+ // Allocates a new WebUI object for the given URL, and returns it. If the URL
+ // is not a Web UI URL, then it will return NULL. When non-NULL, ownership of
+ // the returned pointer is passed to the caller.
+ static WebUI* CreateWebUIForURL(TabContents* tab_contents, const GURL& url);
+
+ // Get the favicon for |page_url| and forward the result to the |request|
+ // when loaded.
+ static void GetFaviconForURL(Profile* profile,
+ FaviconService::GetFaviconRequest* request,
+ const GURL& page_url);
+
+ private:
+ // Gets the data for the favicon for a WebUI page. Returns NULL if the WebUI
+ // does not have a favicon.
+ static RefCountedMemory* GetFaviconResourceBytes(Profile* profile,
+ const GURL& page_url);
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(WebUIFactory);
+};
#endif // CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index b4b9226..445344c 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -52,7 +52,6 @@
'browser/child_process_security_policy.h',
'browser/chrome_blob_storage_context.cc',
'browser/chrome_blob_storage_context.h',
- 'browser/content_browser_client.cc',
'browser/content_browser_client.h',
'browser/cross_site_request_manager.cc',
'browser/cross_site_request_manager.h',
@@ -305,10 +304,6 @@
'browser/trace_controller.h',
'browser/trace_message_filter.cc',
'browser/trace_message_filter.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.cc',
'browser/webui/web_ui.h',
'browser/webui/web_ui_factory.cc',