- add sources.
[platform/framework/web/crosswalk.git] / src / content / browser / webui / content_web_ui_controller_factory.cc
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/media/webrtc_internals_ui.h"
12 #include "content/browser/tracing/tracing_ui.h"
13 #include "content/public/browser/web_contents.h"
14 #include "content/public/browser/web_ui.h"
15 #include "content/public/common/url_constants.h"
16
17 namespace content {
18
19 WebUI::TypeID ContentWebUIControllerFactory::GetWebUIType(
20       BrowserContext* browser_context, const GURL& url) const {
21   if (url.host() == kChromeUIWebRTCInternalsHost ||
22 #if !defined(OS_ANDROID)
23       url.host() == kChromeUITracingHost ||
24 #endif
25       url.host() == kChromeUIGpuHost ||
26       url.host() == kChromeUIIndexedDBInternalsHost ||
27       url.host() == kChromeUIMediaInternalsHost ||
28       url.host() == kChromeUIAccessibilityHost) {
29     return const_cast<ContentWebUIControllerFactory*>(this);
30   }
31   return WebUI::kNoWebUI;
32 }
33
34 bool ContentWebUIControllerFactory::UseWebUIForURL(
35     BrowserContext* browser_context, const GURL& url) const {
36   return GetWebUIType(browser_context, url) != WebUI::kNoWebUI;
37 }
38
39 bool ContentWebUIControllerFactory::UseWebUIBindingsForURL(
40     BrowserContext* browser_context, const GURL& url) const {
41   return UseWebUIForURL(browser_context, url);
42 }
43
44 WebUIController* ContentWebUIControllerFactory::CreateWebUIControllerForURL(
45     WebUI* web_ui, const GURL& url) const {
46   if (url.host() == kChromeUIWebRTCInternalsHost)
47     return new WebRTCInternalsUI(web_ui);
48   if (url.host() == kChromeUIGpuHost)
49     return new GpuInternalsUI(web_ui);
50   if (url.host() == kChromeUIIndexedDBInternalsHost)
51     return new IndexedDBInternalsUI(web_ui);
52   if (url.host() == kChromeUIMediaInternalsHost)
53     return new MediaInternalsUI(web_ui);
54   if (url.host() == kChromeUIAccessibilityHost)
55     return new AccessibilityUI(web_ui);
56 #if !defined(OS_ANDROID)
57   if (url.host() == kChromeUITracingHost)
58     return new TracingUI(web_ui);
59 #endif
60
61   return NULL;
62 }
63
64 // static
65 ContentWebUIControllerFactory* ContentWebUIControllerFactory::GetInstance() {
66   return Singleton<ContentWebUIControllerFactory>::get();
67 }
68
69 ContentWebUIControllerFactory::ContentWebUIControllerFactory() {
70 }
71
72 ContentWebUIControllerFactory::~ContentWebUIControllerFactory() {
73 }
74
75 }  // namespace content