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.
5 #include "content/browser/webui/content_web_ui_controller_factory.h"
7 #include "content/browser/accessibility/accessibility_ui.h"
8 #include "content/browser/appcache/appcache_internals_ui.h"
9 #include "content/browser/gpu/gpu_internals_ui.h"
10 #include "content/browser/indexed_db/indexed_db_internals_ui.h"
11 #include "content/browser/media/media_internals_ui.h"
12 #include "content/browser/service_worker/service_worker_internals_ui.h"
13 #include "content/browser/tracing/tracing_ui.h"
14 #include "content/public/browser/storage_partition.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_ui.h"
17 #include "content/public/common/url_constants.h"
19 #if defined(ENABLE_WEBRTC)
20 #include "content/browser/media/webrtc_internals_ui.h"
25 WebUI::TypeID
ContentWebUIControllerFactory::GetWebUIType(
26 BrowserContext
* browser_context
, const GURL
& url
) const {
27 if (!url
.SchemeIs(kChromeUIScheme
))
28 return WebUI::kNoWebUI
;
30 if (url
.host() == kChromeUIWebRTCInternalsHost
||
31 #if !defined(OS_ANDROID)
32 url
.host() == kChromeUITracingHost
||
34 url
.host() == kChromeUIGpuHost
||
35 url
.host() == kChromeUIIndexedDBInternalsHost
||
36 url
.host() == kChromeUIMediaInternalsHost
||
37 url
.host() == kChromeUIServiceWorkerInternalsHost
||
38 url
.host() == kChromeUIAccessibilityHost
||
39 url
.host() == kChromeUIAppCacheInternalsHost
) {
40 return const_cast<ContentWebUIControllerFactory
*>(this);
42 return WebUI::kNoWebUI
;
45 bool ContentWebUIControllerFactory::UseWebUIForURL(
46 BrowserContext
* browser_context
, const GURL
& url
) const {
47 return GetWebUIType(browser_context
, url
) != WebUI::kNoWebUI
;
50 bool ContentWebUIControllerFactory::UseWebUIBindingsForURL(
51 BrowserContext
* browser_context
, const GURL
& url
) const {
52 return UseWebUIForURL(browser_context
, url
);
55 WebUIController
* ContentWebUIControllerFactory::CreateWebUIControllerForURL(
56 WebUI
* web_ui
, const GURL
& url
) const {
57 if (!url
.SchemeIs(kChromeUIScheme
))
60 if (url
.host() == kChromeUIAppCacheInternalsHost
)
61 return new AppCacheInternalsUI(web_ui
);
62 if (url
.host() == kChromeUIGpuHost
)
63 return new GpuInternalsUI(web_ui
);
64 if (url
.host() == kChromeUIIndexedDBInternalsHost
)
65 return new IndexedDBInternalsUI(web_ui
);
66 if (url
.host() == kChromeUIMediaInternalsHost
)
67 return new MediaInternalsUI(web_ui
);
68 if (url
.host() == kChromeUIAccessibilityHost
)
69 return new AccessibilityUI(web_ui
);
70 if (url
.host() == kChromeUIServiceWorkerInternalsHost
)
71 return new ServiceWorkerInternalsUI(web_ui
);
72 #if !defined(OS_ANDROID)
73 if (url
.host() == kChromeUITracingHost
)
74 return new TracingUI(web_ui
);
77 #if defined(ENABLE_WEBRTC)
78 if (url
.host() == kChromeUIWebRTCInternalsHost
)
79 return new WebRTCInternalsUI(web_ui
);
86 ContentWebUIControllerFactory
* ContentWebUIControllerFactory::GetInstance() {
87 return Singleton
<ContentWebUIControllerFactory
>::get();
90 ContentWebUIControllerFactory::ContentWebUIControllerFactory() {
93 ContentWebUIControllerFactory::~ContentWebUIControllerFactory() {
96 } // namespace content