1// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "content/browser/webui/content_web_ui_controller_factory.h" 6 7#include "content/browser/accessibility/accessibility_ui.h" 8#include "content/browser/gpu/gpu_internals_ui.h" 9#include "content/browser/indexed_db/indexed_db_internals_ui.h" 10#include "content/browser/media/media_internals_ui.h" 11#include "content/browser/service_worker/service_worker_internals_ui.h" 12#include "content/browser/tracing/tracing_ui.h" 13#include "content/public/browser/storage_partition.h" 14#include "content/public/browser/web_contents.h" 15#include "content/public/browser/web_ui.h" 16#include "content/public/common/url_constants.h" 17 18#if defined(ENABLE_WEBRTC) 19#include "content/browser/media/webrtc_internals_ui.h" 20#endif 21 22namespace content { 23 24WebUI::TypeID ContentWebUIControllerFactory::GetWebUIType( 25 BrowserContext* browser_context, const GURL& url) const { 26 if (url.host() == kChromeUIWebRTCInternalsHost || 27#if !defined(OS_ANDROID) 28 url.host() == kChromeUITracingHost || 29#endif 30 url.host() == kChromeUIGpuHost || 31 url.host() == kChromeUIIndexedDBInternalsHost || 32 url.host() == kChromeUIMediaInternalsHost || 33 url.host() == kChromeUIServiceWorkerInternalsHost || 34 url.host() == kChromeUIAccessibilityHost) { 35 return const_cast<ContentWebUIControllerFactory*>(this); 36 } 37 return WebUI::kNoWebUI; 38} 39 40bool ContentWebUIControllerFactory::UseWebUIForURL( 41 BrowserContext* browser_context, const GURL& url) const { 42 return GetWebUIType(browser_context, url) != WebUI::kNoWebUI; 43} 44 45bool ContentWebUIControllerFactory::UseWebUIBindingsForURL( 46 BrowserContext* browser_context, const GURL& url) const { 47 return UseWebUIForURL(browser_context, url); 48} 49 50WebUIController* ContentWebUIControllerFactory::CreateWebUIControllerForURL( 51 WebUI* web_ui, const GURL& url) const { 52 if (url.host() == kChromeUIGpuHost) 53 return new GpuInternalsUI(web_ui); 54 if (url.host() == kChromeUIIndexedDBInternalsHost) 55 return new IndexedDBInternalsUI(web_ui); 56 if (url.host() == kChromeUIMediaInternalsHost) 57 return new MediaInternalsUI(web_ui); 58 if (url.host() == kChromeUIAccessibilityHost) 59 return new AccessibilityUI(web_ui); 60 if (url.host() == kChromeUIServiceWorkerInternalsHost) 61 return new ServiceWorkerInternalsUI(web_ui); 62#if !defined(OS_ANDROID) 63 if (url.host() == kChromeUITracingHost) 64 return new TracingUI(web_ui); 65#endif 66 67#if defined(ENABLE_WEBRTC) 68 if (url.host() == kChromeUIWebRTCInternalsHost) 69 return new WebRTCInternalsUI(web_ui); 70#endif 71 72 return NULL; 73} 74 75// static 76ContentWebUIControllerFactory* ContentWebUIControllerFactory::GetInstance() { 77 return Singleton<ContentWebUIControllerFactory>::get(); 78} 79 80ContentWebUIControllerFactory::ContentWebUIControllerFactory() { 81} 82 83ContentWebUIControllerFactory::~ContentWebUIControllerFactory() { 84} 85 86} // namespace content 87