Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / browser / webui / content_web_ui_controller_factory.cc
blob95dedcb0dd4d4aae5e4e271c536a1ad291a58e4a
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/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/service_worker/service_worker_internals_ui.h"
12 #include "content/browser/tracing/tracing_ui.h"
13 #include "content/public/browser/storage_partition.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_ui.h"
16 #include "content/public/common/url_constants.h"
18 #if defined(ENABLE_WEBRTC)
19 #include "content/browser/media/webrtc_internals_ui.h"
20 #endif
22 namespace content {
24 WebUI::TypeID ContentWebUIControllerFactory::GetWebUIType(
25 BrowserContext* browser_context, const GURL& url) const {
26 if (!url.SchemeIs(kChromeUIScheme))
27 return WebUI::kNoWebUI;
29 if (url.host() == kChromeUIWebRTCInternalsHost ||
30 #if !defined(OS_ANDROID)
31 url.host() == kChromeUITracingHost ||
32 #endif
33 url.host() == kChromeUIGpuHost ||
34 url.host() == kChromeUIIndexedDBInternalsHost ||
35 url.host() == kChromeUIMediaInternalsHost ||
36 url.host() == kChromeUIServiceWorkerInternalsHost ||
37 url.host() == kChromeUIAccessibilityHost) {
38 return const_cast<ContentWebUIControllerFactory*>(this);
40 return WebUI::kNoWebUI;
43 bool ContentWebUIControllerFactory::UseWebUIForURL(
44 BrowserContext* browser_context, const GURL& url) const {
45 return GetWebUIType(browser_context, url) != WebUI::kNoWebUI;
48 bool ContentWebUIControllerFactory::UseWebUIBindingsForURL(
49 BrowserContext* browser_context, const GURL& url) const {
50 return UseWebUIForURL(browser_context, url);
53 WebUIController* ContentWebUIControllerFactory::CreateWebUIControllerForURL(
54 WebUI* web_ui, const GURL& url) const {
55 if (!url.SchemeIs(kChromeUIScheme))
56 return nullptr;
58 if (url.host() == kChromeUIGpuHost)
59 return new GpuInternalsUI(web_ui);
60 if (url.host() == kChromeUIIndexedDBInternalsHost)
61 return new IndexedDBInternalsUI(web_ui);
62 if (url.host() == kChromeUIMediaInternalsHost)
63 return new MediaInternalsUI(web_ui);
64 if (url.host() == kChromeUIAccessibilityHost)
65 return new AccessibilityUI(web_ui);
66 if (url.host() == kChromeUIServiceWorkerInternalsHost)
67 return new ServiceWorkerInternalsUI(web_ui);
68 #if !defined(OS_ANDROID)
69 if (url.host() == kChromeUITracingHost)
70 return new TracingUI(web_ui);
71 #endif
73 #if defined(ENABLE_WEBRTC)
74 if (url.host() == kChromeUIWebRTCInternalsHost)
75 return new WebRTCInternalsUI(web_ui);
76 #endif
78 return nullptr;
81 // static
82 ContentWebUIControllerFactory* ContentWebUIControllerFactory::GetInstance() {
83 return Singleton<ContentWebUIControllerFactory>::get();
86 ContentWebUIControllerFactory::ContentWebUIControllerFactory() {
89 ContentWebUIControllerFactory::~ContentWebUIControllerFactory() {
92 } // namespace content