summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-30 16:55:56 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-30 16:55:56 +0000
commit1fd1a5043e4de3078e3e05684a14055474da0d0b (patch)
tree25d28a7c713fd8bbda6e28bd599d4a890e6b3254 /content/browser
parent76b0f686facc70c33f2983c115933006654ee482 (diff)
downloadchromium_src-1fd1a5043e4de3078e3e05684a14055474da0d0b.zip
chromium_src-1fd1a5043e4de3078e3e05684a14055474da0d0b.tar.gz
chromium_src-1fd1a5043e4de3078e3e05684a14055474da0d0b.tar.bz2
Move WebUIFactory to chrome/, try 2.
first try was r79691 This fixes the SiteInstance unit test failure. SiteInstance has all kinds of dependencies into chrome/. This fixes the unittest just enough to get it passing without trying to refactor SiteInstance at all. BUG=77092 TEST=trybots, again Review URL: http://codereview.chromium.org/6731060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79849 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-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/site_instance_unittest.cc67
-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.h38
-rw-r--r--content/browser/webui/generic_handler.cc54
-rw-r--r--content/browser/webui/generic_handler.h28
-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
17 files changed, 332 insertions, 427 deletions
diff --git a/content/browser/browsing_instance.cc b/content/browser/browsing_instance.cc
index 1759fc0..be55f5e 100644
--- a/content/browser/browsing_instance.cc
+++ b/content/browser/browsing_instance.cc
@@ -9,8 +9,10 @@
#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
@@ -39,9 +41,10 @@ bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) {
return true;
// DevTools pages have WebUI type but should not reuse the same host.
- if (WebUIFactory::UseWebUIForURL(profile_, url) &&
- !url.SchemeIs(chrome::kChromeDevToolsScheme))
+ if (content::WebUIFactory::Get()->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
new file mode 100644
index 0000000..b96b55e
--- /dev/null
+++ b/content/browser/content_browser_client.cc
@@ -0,0 +1,17 @@
+// 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 b916263..c7218f8 100644
--- a/content/browser/content_browser_client.h
+++ b/content/browser/content_browser_client.h
@@ -14,6 +14,8 @@ class RenderViewHost;
namespace content {
+class WebUIFactory;
+
// Embedder API for participating in browser logic.
class ContentBrowserClient {
public:
@@ -21,6 +23,9 @@ 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 a59d1ca..26565a1 100644
--- a/content/browser/site_instance.cc
+++ b/content/browser/site_instance.cc
@@ -8,8 +8,10 @@
#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
@@ -211,7 +213,7 @@ RenderProcessHost::Type SiteInstance::RendererTypeForURL(const GURL& url) {
return RenderProcessHost::TYPE_EXTENSION;
// TODO(erikkay) creis recommends using UseWebUIForURL instead.
- if (WebUIFactory::HasWebUIScheme(url))
+ if (content::WebUIFactory::Get()->HasWebUIScheme(url))
return RenderProcessHost::TYPE_WEBUI;
return RenderProcessHost::TYPE_NORMAL;
diff --git a/content/browser/site_instance_unittest.cc b/content/browser/site_instance_unittest.cc
index 1b072aa..247dd13 100644
--- a/content/browser/site_instance_unittest.cc
+++ b/content/browser/site_instance_unittest.cc
@@ -10,21 +10,55 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/testing_profile.h"
#include "content/browser/browsing_instance.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "content/browser/browsing_instance.h"
#include "content/browser/child_process_security_policy.h"
+#include "content/browser/content_browser_client.h"
#include "content/browser/renderer_host/render_view_host.h"
-#include "content/browser/site_instance.h"
#include "content/browser/renderer_host/test_render_view_host.h"
+#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/webui/empty_web_ui_factory.h"
+#include "content/common/content_client.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+// TODO(estade): this shouldn't need to be chrome:, but it does (or else GURL
+// doesn't think that the webui URLs have a host). Figure out where this is
+// coming from and fix it.
+const char kWebUIScheme[] = "chrome";
+
+class SiteInstanceTestWebUIFactory : public content::EmptyWebUIFactory {
+ public:
+ virtual bool UseWebUIForURL(Profile* profile, const GURL& url) const {
+ return HasWebUIScheme(url);
+ }
+ virtual bool HasWebUIScheme(const GURL& url) const {
+ return url.SchemeIs(kWebUIScheme);
+ }
+};
+
+class SiteInstanceTestBrowserClient : public content::ContentBrowserClient {
+ public:
+ virtual content::WebUIFactory* GetWebUIFactory() {
+ return &factory_;
+ }
+
+ private:
+ SiteInstanceTestWebUIFactory factory_;
+};
class SiteInstanceTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ content::GetContentClient()->set_browser(&browser_client_);
+ }
+
private:
MessageLoopForUI message_loop_;
-};
-namespace {
+ SiteInstanceTestBrowserClient browser_client_;
+};
class TestBrowsingInstance : public BrowsingInstance {
public:
@@ -51,14 +85,13 @@ class TestBrowsingInstance : public BrowsingInstance {
int* deleteCounter_;
};
-
class TestSiteInstance : public SiteInstance {
public:
static TestSiteInstance* CreateTestSiteInstance(Profile* profile,
int* siteDeleteCounter,
int* browsingDeleteCounter) {
TestBrowsingInstance* browsing_instance =
- new TestBrowsingInstance(profile, browsingDeleteCounter);
+ new TestBrowsingInstance(profile, browsingDeleteCounter);
return new TestSiteInstance(browsing_instance, siteDeleteCounter);
}
@@ -441,22 +474,24 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
extension2_instance->GetProcess());
// Create some WebUI instances and make sure they share a process.
- scoped_refptr<SiteInstance> dom1_instance(
- CreateSiteInstance(&rph_factory, GURL("chrome://newtab")));
- policy->GrantWebUIBindings(dom1_instance->GetProcess()->id());
+ scoped_refptr<SiteInstance> webui1_instance(
+ CreateSiteInstance(&rph_factory,
+ GURL(kWebUIScheme + std::string("://newtab"))));
+ policy->GrantWebUIBindings(webui1_instance->GetProcess()->id());
- scoped_refptr<SiteInstance> dom2_instance(
- CreateSiteInstance(&rph_factory, GURL("chrome://history")));
+ scoped_refptr<SiteInstance> webui2_instance(
+ CreateSiteInstance(&rph_factory,
+ GURL(kWebUIScheme + std::string("://history"))));
- scoped_ptr<RenderProcessHost> dom_host(dom1_instance->GetProcess());
- EXPECT_EQ(dom1_instance->GetProcess(), dom2_instance->GetProcess());
+ scoped_ptr<RenderProcessHost> dom_host(webui1_instance->GetProcess());
+ EXPECT_EQ(webui1_instance->GetProcess(), webui2_instance->GetProcess());
// Make sure none of differing privilege processes are mixed.
- EXPECT_NE(extension1_instance->GetProcess(), dom1_instance->GetProcess());
+ EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess());
for (size_t i = 0; i < chrome::kMaxRendererProcessCount; ++i) {
EXPECT_NE(extension1_instance->GetProcess(), hosts[i]);
- EXPECT_NE(dom1_instance->GetProcess(), hosts[i]);
+ EXPECT_NE(webui1_instance->GetProcess(), hosts[i]);
}
STLDeleteContainerPointers(hosts.begin(), hosts.end());
diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc
index ee56978..a00d40c 100644
--- a/content/browser/tab_contents/render_view_host_manager.cc
+++ b/content/browser/tab_contents/render_view_host_manager.cc
@@ -21,6 +21,7 @@
#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"
@@ -301,13 +302,14 @@ bool RenderViewHostManager::ShouldSwapProcessesForNavigation(
const GURL& current_url = (cur_entry) ? cur_entry->url() :
render_view_host_->site_instance()->site();
Profile* profile = delegate_->GetControllerForRenderManager().profile();
- if (WebUIFactory::UseWebUIForURL(profile, current_url)) {
+ const content::WebUIFactory* web_ui_factory = content::WebUIFactory::Get();
+ if (web_ui_factory->UseWebUIForURL(profile, current_url)) {
// Force swap if it's not an acceptable URL for Web UI.
- if (!WebUIFactory::IsURLAcceptableForWebUI(profile, new_entry->url()))
+ if (!web_ui_factory->IsURLAcceptableForWebUI(profile, new_entry->url()))
return true;
} else {
// Force swap if it's a Web UI URL.
- if (WebUIFactory::UseWebUIForURL(profile, new_entry->url()))
+ if (web_ui_factory->UseWebUIForURL(profile, new_entry->url()))
return true;
}
@@ -384,8 +386,9 @@ 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 (WebUIFactory::UseWebUIForURL(profile, dest_url))
+ if (content::WebUIFactory::Get()->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 7ac1749..61bc4b5 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -66,6 +66,7 @@
#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"
@@ -79,7 +80,8 @@
#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.h"
+#include "content/browser/webui/web_ui_factory.h"
+#include "content/common/content_client.h"
#include "content/common/navigation_types.h"
#include "content/common/notification_service.h"
#include "content/common/view_messages.h"
@@ -250,7 +252,7 @@ TabContents::TabContents(Profile* profile,
#endif
suppress_javascript_messages_(false),
is_showing_before_unload_dialog_(false),
- opener_web_ui_type_(WebUIFactory::kNoWebUI),
+ opener_web_ui_type_(WebUI::kNoWebUI),
language_state_(&controller_),
closed_by_user_gesture_(false),
minimum_zoom_percent_(
@@ -550,7 +552,7 @@ bool TabContents::ShouldDisplayURL() {
}
// We always display the URL for non-WebUI URLs to prevent spoofing.
- if (entry && !WebUIFactory::HasWebUIScheme(entry->url()))
+ if (entry && !content::WebUIFactory::Get()->HasWebUIScheme(entry->url()))
return true;
WebUI* web_ui = GetWebUIForCurrentState();
@@ -713,8 +715,9 @@ 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 =
- WebUIFactory::IsURLAcceptableForWebUI(profile(), entry.url());
+ bool is_allowed_in_web_ui_renderer = content::GetContentClient()->
+ browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(profile(),
+ entry.url());
CHECK(!BindingsPolicy::is_web_ui_enabled(enabled_bindings) ||
is_allowed_in_web_ui_renderer);
@@ -1598,23 +1601,27 @@ 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_ != WebUIFactory::kNoWebUI) {
+ if (opener_web_ui_type_ != WebUI::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 (opener_web_ui_type_ ==
- WebUIFactory::GetWebUIType(profile(), GetURL())) {
- WebUI* web_ui = WebUIFactory::CreateWebUIForURL(this, GetURL());
+ if (delegate_ && opener_web_ui_type_ == GetWebUITypeForCurrentState()) {
+ WebUI* web_ui = content::GetContentClient()->browser()->
+ GetWebUIFactory()->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_ = WebUIFactory::kNoWebUI;
+ opener_web_ui_type_ = WebUI::kNoWebUI;
}
if (details.is_user_initiated_main_frame_load()) {
@@ -1994,9 +2001,8 @@ 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.
@@ -2571,7 +2577,7 @@ NavigationController& TabContents::GetControllerForRenderManager() {
}
WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) {
- return WebUIFactory::CreateWebUIForURL(this, url);
+ return content::WebUIFactory::Get()->CreateWebUIForURL(this, url);
}
NavigationEntry*
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index daa7813..60602f6 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_factory.h"
+#include "content/browser/webui/web_ui.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(WebUITypeID opener_web_ui_type) {
+ void set_opener_web_ui_type(WebUI::TypeID opener_web_ui_type) {
opener_web_ui_type_ = opener_web_ui_type;
}
@@ -693,6 +693,9 @@ 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);
@@ -1174,7 +1177,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.
- WebUITypeID opener_web_ui_type_;
+ WebUI::TypeID 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 a4e5c7b..09db402 100644
--- a/content/browser/tab_contents/tab_contents_view.cc
+++ b/content/browser/tab_contents/tab_contents_view.cc
@@ -37,8 +37,7 @@ void TabContentsView::CreateNewWindow(
route_id,
tab_contents_->profile(),
tab_contents_->GetSiteInstance(),
- WebUIFactory::GetWebUIType(tab_contents_->profile(),
- tab_contents_->GetURL()),
+ tab_contents_->GetWebUITypeForCurrentState(),
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
new file mode 100644
index 0000000..fd29847
--- /dev/null
+++ b/content/browser/webui/empty_web_ui_factory.cc
@@ -0,0 +1,44 @@
+// 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
new file mode 100644
index 0000000..6ca8fca
--- /dev/null
+++ b/content/browser/webui/empty_web_ui_factory.h
@@ -0,0 +1,38 @@
+// 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;
+
+ protected:
+ EmptyWebUIFactory();
+ virtual ~EmptyWebUIFactory();
+
+ private:
+ friend struct DefaultSingletonTraits<EmptyWebUIFactory>;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_WEBUI_EMPTY_WEB_UI_FACTORY_H_
diff --git a/content/browser/webui/generic_handler.cc b/content/browser/webui/generic_handler.cc
new file mode 100644
index 0000000..bad0584
--- /dev/null
+++ b/content/browser/webui/generic_handler.cc
@@ -0,0 +1,54 @@
+// 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/generic_handler.h"
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "content/browser/disposition_utils.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "googleurl/src/gurl.h"
+
+GenericHandler::GenericHandler() {
+}
+
+GenericHandler::~GenericHandler() {
+}
+
+void GenericHandler::RegisterMessages() {
+ web_ui_->RegisterMessageCallback("navigateToUrl",
+ NewCallback(this, &GenericHandler::HandleNavigateToUrl));
+}
+
+void GenericHandler::HandleNavigateToUrl(const ListValue* args) {
+ std::string url_string;
+ std::string target_string;
+ double button;
+ bool alt_key;
+ bool ctrl_key;
+ bool meta_key;
+ bool shift_key;
+
+ CHECK(args->GetString(0, &url_string));
+ CHECK(args->GetString(1, &target_string));
+ CHECK(args->GetDouble(2, &button));
+ CHECK(args->GetBoolean(3, &alt_key));
+ CHECK(args->GetBoolean(4, &ctrl_key));
+ CHECK(args->GetBoolean(5, &meta_key));
+ CHECK(args->GetBoolean(6, &shift_key));
+
+ CHECK(button == 0.0 || button == 1.0);
+ bool middle_button = (button == 1.0);
+
+ WindowOpenDisposition disposition =
+ disposition_utils::DispositionFromClick(middle_button, alt_key, ctrl_key,
+ meta_key, shift_key);
+ if (disposition == CURRENT_TAB && target_string == "_blank")
+ disposition = NEW_FOREGROUND_TAB;
+
+ web_ui_->tab_contents()->OpenURL(
+ GURL(url_string), GURL(), disposition, PageTransition::LINK);
+
+ // This may delete us!
+}
diff --git a/content/browser/webui/generic_handler.h b/content/browser/webui/generic_handler.h
new file mode 100644
index 0000000..408ecbb
--- /dev/null
+++ b/content/browser/webui/generic_handler.h
@@ -0,0 +1,28 @@
+// 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_GENERIC_HANDLER_H_
+#define CONTENT_BROWSER_WEBUI_GENERIC_HANDLER_H_
+#pragma once
+
+#include "content/browser/webui/web_ui.h"
+
+class ListValue;
+
+// A place to add handlers for messages shared across all WebUI pages.
+class GenericHandler : public WebUIMessageHandler {
+ public:
+ GenericHandler();
+ virtual ~GenericHandler();
+
+ // WebUIMessageHandler implementation.
+ virtual void RegisterMessages();
+
+ private:
+ void HandleNavigateToUrl(const ListValue* args);
+
+ DISALLOW_COPY_AND_ASSIGN(GenericHandler);
+};
+
+#endif // CONTENT_BROWSER_WEBUI_GENERIC_HANDLER_H_
diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc
index 9202958..3cc3633 100644
--- a/content/browser/webui/web_ui.cc
+++ b/content/browser/webui/web_ui.cc
@@ -10,14 +10,13 @@
#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 {
@@ -59,6 +58,8 @@ 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 98adcb1..4d0215f 100644
--- a/content/browser/webui/web_ui.h
+++ b/content/browser/webui/web_ui.h
@@ -144,6 +144,14 @@ 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 04776a5..63a8c8e 100644
--- a/content/browser/webui/web_ui_factory.cc
+++ b/content/browser/webui/web_ui_factory.cc
@@ -4,344 +4,14 @@
#include "content/browser/webui/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 "googleurl/src/gurl.h"
+#include "content/browser/content_browser_client.h"
+#include "content/common/content_client.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
-
-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);
-}
+namespace content {
// static
-bool WebUIFactory::UseWebUIForURL(Profile* profile, const GURL& url) {
- return GetWebUIFactoryFunction(profile, url) != NULL;
+WebUIFactory* WebUIFactory::Get() {
+ return content::GetContentClient()->browser()->GetWebUIFactory();
}
-// 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;
-}
+} // namespace content
diff --git a/content/browser/webui/web_ui_factory.h b/content/browser/webui/web_ui_factory.h
index 2be656a..a1c6560 100644
--- a/content/browser/webui/web_ui_factory.h
+++ b/content/browser/webui/web_ui_factory.h
@@ -6,62 +6,51 @@
#define CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_
#pragma once
-#include "base/basictypes.h"
-#include "chrome/browser/favicon_service.h"
+#include "content/browser/webui/web_ui.h"
-class WebUI;
-class GURL;
class Profile;
-class RefCountedMemory;
class TabContents;
+class GURL;
-// An opaque identifier used to identify a WebUI. This can only be compared to
-// kNoWebUI or other WebUI types. See GetWebUIType.
-typedef void* WebUITypeID;
+namespace content {
+// Interface for an object which controls which URLs are considered WebUI URLs
+// and creates WebUI instances for given URLs.
class WebUIFactory {
public:
- // 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);
-
- // 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);
+ // 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/. Guaranteed to return non-NULL.
+ static WebUIFactory* Get();
+};
- 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);
-};
+} // namespace content
#endif // CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_