| Index: chrome/browser/ui/webui/web_ui_factory.cc
|
| diff --git a/content/browser/webui/web_ui_factory.cc b/chrome/browser/ui/webui/web_ui_factory.cc
|
| similarity index 91%
|
| rename from content/browser/webui/web_ui_factory.cc
|
| rename to chrome/browser/ui/webui/web_ui_factory.cc
|
| index 238b841479243c05debf6a4afac998657f6d20f2..98c20cb2fad3346a227876c2c97169945a2cb50a 100644
|
| --- a/content/browser/webui/web_ui_factory.cc
|
| +++ b/chrome/browser/ui/webui/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/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,28 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile,
|
| return NULL;
|
| }
|
|
|
| -// static
|
| -WebUITypeID WebUIFactory::GetWebUIType(Profile* profile, const GURL& url) {
|
| +} // namespace
|
| +
|
| +WebUI::WebUITypeID WebUIFactory::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 WebUIFactory::UseWebUIForURL(Profile* profile, const GURL& url) const {
|
| + return GetWebUIType(profile, url) != WebUI::kNoWebUI;
|
| +}
|
| +
|
| +bool WebUIFactory::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 WebUIFactory::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 +262,8 @@ bool WebUIFactory::IsURLAcceptableForWebUI(Profile* profile, const GURL& url) {
|
| url.spec() == chrome::kAboutShorthangURL;
|
| }
|
|
|
| -// static
|
| WebUI* WebUIFactory::CreateWebUIForURL(TabContents* tab_contents,
|
| - const GURL& url) {
|
| + const GURL& url) const {
|
| WebUIFactoryFunction function = GetWebUIFactoryFunction(
|
| tab_contents->profile(), url);
|
| if (!function)
|
| @@ -270,10 +271,9 @@ WebUI* WebUIFactory::CreateWebUIForURL(TabContents* tab_contents,
|
| return (*function)(tab_contents, url);
|
| }
|
|
|
| -// static
|
| void WebUIFactory::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 +282,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 +292,19 @@ void WebUIFactory::GetFaviconForURL(Profile* profile,
|
| }
|
|
|
| // static
|
| -RefCountedMemory* WebUIFactory::GetFaviconResourceBytes(Profile* profile,
|
| - const GURL& page_url) {
|
| +WebUIFactory* WebUIFactory::GetInstance() {
|
| + return Singleton<WebUIFactory>::get();
|
| +}
|
| +
|
| +WebUIFactory::WebUIFactory() {
|
| +}
|
| +
|
| +WebUIFactory::~WebUIFactory() {
|
| +}
|
| +
|
| +RefCountedMemory* WebUIFactory::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)
|
|
|