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