diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-29 21:40:04 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-29 21:40:04 +0000 |
commit | 64ccac3e800377e6fb4f118fbb6da07bc693f275 (patch) | |
tree | 404fc438e373e6287a26750606af4770cf3259c7 /content/browser/webui | |
parent | a1f608e6fcd06053da85de6a707602c63bef62e9 (diff) | |
download | chromium_src-64ccac3e800377e6fb4f118fbb6da07bc693f275.zip chromium_src-64ccac3e800377e6fb4f118fbb6da07bc693f275.tar.gz chromium_src-64ccac3e800377e6fb4f118fbb6da07bc693f275.tar.bz2 |
Add a WebUIControllerFactory in content and move chrome://webrtc-internals to content.
BUG=169170
Review URL: https://codereview.chromium.org/12089034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179425 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/webui')
-rw-r--r-- | content/browser/webui/content_web_ui_controller_factory.cc | 50 | ||||
-rw-r--r-- | content/browser/webui/content_web_ui_controller_factory.h | 41 |
2 files changed, 91 insertions, 0 deletions
diff --git a/content/browser/webui/content_web_ui_controller_factory.cc b/content/browser/webui/content_web_ui_controller_factory.cc new file mode 100644 index 0000000..49900ac --- /dev/null +++ b/content/browser/webui/content_web_ui_controller_factory.cc @@ -0,0 +1,50 @@ +// Copyright (c) 2013 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/content_web_ui_controller_factory.h" + +#include "content/browser/media/webrtc_internals_ui.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui.h" +#include "content/public/common/url_constants.h" + +namespace content { + +WebUI::TypeID ContentWebUIControllerFactory::GetWebUIType( + BrowserContext* browser_context, const GURL& url) const { + if (url.host() == chrome::kChromeUIWebRTCInternalsHost) + return const_cast<ContentWebUIControllerFactory*>(this); + return WebUI::kNoWebUI; +} + +bool ContentWebUIControllerFactory::UseWebUIForURL( + BrowserContext* browser_context, const GURL& url) const { + return GetWebUIType(browser_context, url) != WebUI::kNoWebUI; +} + +bool ContentWebUIControllerFactory::UseWebUIBindingsForURL( + BrowserContext* browser_context, const GURL& url) const { + return UseWebUIForURL(browser_context, url); +} + +WebUIController* ContentWebUIControllerFactory::CreateWebUIControllerForURL( + WebUI* web_ui, const GURL& url) const { + if (url.host() == chrome::kChromeUIWebRTCInternalsHost) + return new WebRTCInternalsUI(web_ui); + + return NULL; +} + +// static +ContentWebUIControllerFactory* ContentWebUIControllerFactory::GetInstance() { + return Singleton<ContentWebUIControllerFactory>::get(); +} + +ContentWebUIControllerFactory::ContentWebUIControllerFactory() { +} + +ContentWebUIControllerFactory::~ContentWebUIControllerFactory() { +} + +} // namespace content diff --git a/content/browser/webui/content_web_ui_controller_factory.h b/content/browser/webui/content_web_ui_controller_factory.h new file mode 100644 index 0000000..cee0ec7 --- /dev/null +++ b/content/browser/webui/content_web_ui_controller_factory.h @@ -0,0 +1,41 @@ +// Copyright (c) 2013 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_CONTENT_WEB_UI_CONTROLLER_FACTORY_H_ +#define CONTENT_BROWSER_WEBUI_CONTENT_WEB_UI_CONTROLLER_FACTORY_H_ + +#include "base/basictypes.h" +#include "base/memory/singleton.h" +#include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_controller_factory.h" + +namespace content { + +class ContentWebUIControllerFactory : public WebUIControllerFactory { + public: + virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, + const GURL& url) const OVERRIDE; + virtual bool UseWebUIForURL(BrowserContext* browser_context, + const GURL& url) const OVERRIDE; + virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, + const GURL& url) const OVERRIDE; + virtual WebUIController* CreateWebUIControllerForURL( + WebUI* web_ui, + const GURL& url) const OVERRIDE; + + static ContentWebUIControllerFactory* GetInstance(); + + protected: + ContentWebUIControllerFactory(); + virtual ~ContentWebUIControllerFactory(); + + private: + friend struct DefaultSingletonTraits<ContentWebUIControllerFactory>; + + DISALLOW_COPY_AND_ASSIGN(ContentWebUIControllerFactory); +}; + +} // namespace content + +#endif // CONTENT_BROWSER_WEBUI_CONTENT_WEB_UI_CONTROLLER_FACTORY_H_ |