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