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