| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 5 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "chrome/browser/ui/webui/signin_internals_ui.h" | 48 #include "chrome/browser/ui/webui/signin_internals_ui.h" |
| 49 #include "chrome/browser/ui/webui/sync_internals_ui.h" | 49 #include "chrome/browser/ui/webui/sync_internals_ui.h" |
| 50 #include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h" | 50 #include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h" |
| 51 #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" | 51 #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" |
| 52 #include "chrome/browser/ui/webui/version_ui.h" | 52 #include "chrome/browser/ui/webui/version_ui.h" |
| 53 #include "chrome/common/chrome_switches.h" | 53 #include "chrome/common/chrome_switches.h" |
| 54 #include "chrome/common/extensions/extension_constants.h" | 54 #include "chrome/common/extensions/extension_constants.h" |
| 55 #include "chrome/common/extensions/feature_switch.h" | 55 #include "chrome/common/extensions/feature_switch.h" |
| 56 #include "chrome/common/pref_names.h" | 56 #include "chrome/common/pref_names.h" |
| 57 #include "chrome/common/url_constants.h" | 57 #include "chrome/common/url_constants.h" |
| 58 #include "components/dom_distiller/core/dom_distiller_constants.h" |
| 59 #include "components/dom_distiller/webui/dom_distiller_ui.h" |
| 58 #include "content/public/browser/web_contents.h" | 60 #include "content/public/browser/web_contents.h" |
| 59 #include "content/public/browser/web_ui.h" | 61 #include "content/public/browser/web_ui.h" |
| 60 #include "content/public/common/content_client.h" | 62 #include "content/public/common/content_client.h" |
| 61 #include "content/public/common/url_utils.h" | 63 #include "content/public/common/url_utils.h" |
| 62 #include "extensions/common/constants.h" | 64 #include "extensions/common/constants.h" |
| 63 #include "ui/gfx/favicon_size.h" | 65 #include "ui/gfx/favicon_size.h" |
| 64 #include "ui/web_dialogs/web_dialog_ui.h" | 66 #include "ui/web_dialogs/web_dialog_ui.h" |
| 65 #include "url/gurl.h" | 67 #include "url/gurl.h" |
| 66 | 68 |
| 67 #if !defined(DISABLE_NACL) | 69 #if !defined(DISABLE_NACL) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 return new AboutUI(web_ui, url.host()); | 173 return new AboutUI(web_ui, url.host()); |
| 172 } | 174 } |
| 173 | 175 |
| 174 #if defined(OS_CHROMEOS) | 176 #if defined(OS_CHROMEOS) |
| 175 template<> | 177 template<> |
| 176 WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) { | 178 WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) { |
| 177 return new chromeos::OobeUI(web_ui, url); | 179 return new chromeos::OobeUI(web_ui, url); |
| 178 } | 180 } |
| 179 #endif | 181 #endif |
| 180 | 182 |
| 183 // Special case for DOM distiller. |
| 184 template<> |
| 185 WebUIController* NewWebUI<dom_distiller::DomDistillerUI>(WebUI* web_ui, |
| 186 const GURL& url) { |
| 187 return new dom_distiller::DomDistillerUI(web_ui, url); |
| 188 } |
| 189 |
| 181 // Only create ExtensionWebUI for URLs that are allowed extension bindings, | 190 // Only create ExtensionWebUI for URLs that are allowed extension bindings, |
| 182 // hosted by actual tabs. | 191 // hosted by actual tabs. |
| 183 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) { | 192 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) { |
| 184 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; | 193 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; |
| 185 return service && service->ExtensionBindingsAllowed(url); | 194 return service && service->ExtensionBindingsAllowed(url); |
| 186 } | 195 } |
| 187 | 196 |
| 188 // Returns a function that can be used to create the right type of WebUI for a | 197 // Returns a function that can be used to create the right type of WebUI for a |
| 189 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated | 198 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated |
| 190 // with it. | 199 // with it. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return &NewWebUI<ConstrainedWebDialogUI>; | 239 return &NewWebUI<ConstrainedWebDialogUI>; |
| 231 if (url.host() == chrome::kChromeUICrashesHost) | 240 if (url.host() == chrome::kChromeUICrashesHost) |
| 232 return &NewWebUI<CrashesUI>; | 241 return &NewWebUI<CrashesUI>; |
| 233 #if defined(ENABLE_MDNS) | 242 #if defined(ENABLE_MDNS) |
| 234 if (url.host() == chrome::kChromeUIDevicesFrameHost && | 243 if (url.host() == chrome::kChromeUIDevicesFrameHost && |
| 235 !CommandLine::ForCurrentProcess()->HasSwitch( | 244 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 236 switches::kDisableDeviceDiscovery)) { | 245 switches::kDisableDeviceDiscovery)) { |
| 237 return &NewWebUI<LocalDiscoveryUI>; | 246 return &NewWebUI<LocalDiscoveryUI>; |
| 238 } | 247 } |
| 239 #endif | 248 #endif |
| 249 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 250 switches::kEnableDomDistiller) && |
| 251 url.host() == dom_distiller::kChromeUIDomDistillerHost) { |
| 252 return &NewWebUI<dom_distiller::DomDistillerUI>; |
| 253 } |
| 240 if (url.host() == chrome::kChromeUIFlagsHost) | 254 if (url.host() == chrome::kChromeUIFlagsHost) |
| 241 return &NewWebUI<FlagsUI>; | 255 return &NewWebUI<FlagsUI>; |
| 242 if (url.host() == chrome::kChromeUIHistoryFrameHost) | 256 if (url.host() == chrome::kChromeUIHistoryFrameHost) |
| 243 return &NewWebUI<HistoryUI>; | 257 return &NewWebUI<HistoryUI>; |
| 244 if (url.host() == chrome::kChromeUIInlineLoginHost) | 258 if (url.host() == chrome::kChromeUIInlineLoginHost) |
| 245 return &NewWebUI<InlineLoginUI>; | 259 return &NewWebUI<InlineLoginUI>; |
| 246 if (url.host() == chrome::kChromeUIInstantHost) | 260 if (url.host() == chrome::kChromeUIInstantHost) |
| 247 return &NewWebUI<InstantUI>; | 261 return &NewWebUI<InstantUI>; |
| 248 if (url.host() == chrome::kChromeUIManagedUserPassphrasePageHost) | 262 if (url.host() == chrome::kChromeUIManagedUserPassphrasePageHost) |
| 249 return &NewWebUI<ConstrainedWebDialogUI>; | 263 return &NewWebUI<ConstrainedWebDialogUI>; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 if (page_url.host() == chrome::kChromeUIPluginsHost) | 636 if (page_url.host() == chrome::kChromeUIPluginsHost) |
| 623 return PluginsUI::GetFaviconResourceBytes(scale_factor); | 637 return PluginsUI::GetFaviconResourceBytes(scale_factor); |
| 624 | 638 |
| 625 // Android doesn't use the components pages. | 639 // Android doesn't use the components pages. |
| 626 if (page_url.host() == chrome::kChromeUIComponentsHost) | 640 if (page_url.host() == chrome::kChromeUIComponentsHost) |
| 627 return ComponentsUI::GetFaviconResourceBytes(scale_factor); | 641 return ComponentsUI::GetFaviconResourceBytes(scale_factor); |
| 628 #endif | 642 #endif |
| 629 | 643 |
| 630 return NULL; | 644 return NULL; |
| 631 } | 645 } |
| OLD | NEW |