Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(765)

Unified Diff: chrome/browser/ui/webui/chrome_web_ui_factory.cc

Issue 6713082: Move WebUIFactory to chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove WebUISource references Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/chrome_web_ui_factory.cc
diff --git a/content/browser/webui/web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_factory.cc
similarity index 89%
rename from content/browser/webui/web_ui_factory.cc
rename to chrome/browser/ui/webui/chrome_web_ui_factory.cc
index 238b841479243c05debf6a4afac998657f6d20f2..1a32f344af5c383081a3326f706020b0f2b64440 100644
--- a/content/browser/webui/web_ui_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_factory.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/webui/web_ui_factory.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
#include "base/command_line.h"
#include "chrome/browser/about_flags.h"
@@ -34,6 +34,7 @@
#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)
@@ -61,7 +62,7 @@
#include "chrome/browser/ui/webui/conflicts_ui.h"
#endif
-const WebUITypeID WebUIFactory::kNoWebUI = NULL;
+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).
@@ -92,7 +93,7 @@ WebUI* NewWebUI<ExtensionWebUI>(TabContents* contents, const GURL& url) {
// 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) {
+ const GURL& url) {
if (url.host() == chrome::kChromeUIDialogHost)
return &NewWebUI<ConstrainedHtmlUI>;
@@ -226,27 +227,29 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile,
return NULL;
}
-// static
-WebUITypeID WebUIFactory::GetWebUIType(Profile* profile, const GURL& url) {
+} // namespace
+
+WebUI::WebUITypeID ChromeWebUIFactory::GetWebUIType(Profile* profile,
+ const GURL& url) const {
WebUIFactoryFunction function = GetWebUIFactoryFunction(profile, url);
- return function ? reinterpret_cast<WebUITypeID>(function) : kNoWebUI;
+ return function ? reinterpret_cast<WebUI::WebUITypeID>(function) :
+ WebUI::kNoWebUI;
}
-// static
-bool WebUIFactory::HasWebUIScheme(const GURL& url) {
+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);
}
-// static
-bool WebUIFactory::UseWebUIForURL(Profile* profile, const GURL& url) {
- return GetWebUIFactoryFunction(profile, url) != NULL;
-}
-
-// static
-bool WebUIFactory::IsURLAcceptableForWebUI(Profile* profile, const GURL& url) {
+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) ||
@@ -260,9 +263,8 @@ bool WebUIFactory::IsURLAcceptableForWebUI(Profile* profile, const GURL& url) {
url.spec() == chrome::kAboutShorthangURL;
}
-// static
-WebUI* WebUIFactory::CreateWebUIForURL(TabContents* tab_contents,
- const GURL& url) {
+WebUI* ChromeWebUIFactory::CreateWebUIForURL(TabContents* tab_contents,
+ const GURL& url) const {
WebUIFactoryFunction function = GetWebUIFactoryFunction(
tab_contents->profile(), url);
if (!function)
@@ -270,10 +272,9 @@ WebUI* WebUIFactory::CreateWebUIForURL(TabContents* tab_contents,
return (*function)(tab_contents, url);
}
-// static
-void WebUIFactory::GetFaviconForURL(Profile* profile,
+void ChromeWebUIFactory::GetFaviconForURL(Profile* profile,
FaviconService::GetFaviconRequest* request,
- const GURL& page_url) {
+ 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) &&
@@ -282,7 +283,7 @@ void WebUIFactory::GetFaviconForURL(Profile* profile,
} else {
history::FaviconData favicon;
favicon.image_data = scoped_refptr<RefCountedMemory>(
- WebUIFactory::GetFaviconResourceBytes(profile, page_url));
+ GetFaviconResourceBytes(profile, page_url));
favicon.known_icon = favicon.image_data.get() != NULL &&
favicon.image_data->size() > 0;
request->ForwardResultAsync(
@@ -292,8 +293,19 @@ void WebUIFactory::GetFaviconForURL(Profile* profile,
}
// static
-RefCountedMemory* WebUIFactory::GetFaviconResourceBytes(Profile* profile,
- const GURL& page_url) {
+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)

Powered by Google App Engine
This is Rietveld 408576698