 Chromium Code Reviews
 Chromium Code Reviews Issue 23503042:
  Initial WebUI for DOM Distiller.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 23503042:
  Initial WebUI for DOM Distiller.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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/webui/dom_distiller_ui.h" | |
| 58 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" | 
| 59 #include "content/public/browser/web_ui.h" | 60 #include "content/public/browser/web_ui.h" | 
| 60 #include "content/public/common/content_client.h" | 61 #include "content/public/common/content_client.h" | 
| 61 #include "content/public/common/url_utils.h" | 62 #include "content/public/common/url_utils.h" | 
| 62 #include "extensions/common/constants.h" | 63 #include "extensions/common/constants.h" | 
| 63 #include "ui/gfx/favicon_size.h" | 64 #include "ui/gfx/favicon_size.h" | 
| 64 #include "ui/web_dialogs/web_dialog_ui.h" | 65 #include "ui/web_dialogs/web_dialog_ui.h" | 
| 65 #include "url/gurl.h" | 66 #include "url/gurl.h" | 
| 66 | 67 | 
| 67 #if !defined(DISABLE_NACL) | 68 #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()); | 172 return new AboutUI(web_ui, url.host()); | 
| 172 } | 173 } | 
| 173 | 174 | 
| 174 #if defined(OS_CHROMEOS) | 175 #if defined(OS_CHROMEOS) | 
| 175 template<> | 176 template<> | 
| 176 WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) { | 177 WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) { | 
| 177 return new chromeos::OobeUI(web_ui, url); | 178 return new chromeos::OobeUI(web_ui, url); | 
| 178 } | 179 } | 
| 179 #endif | 180 #endif | 
| 180 | 181 | 
| 182 // Special case for DOM distiller. | |
| 183 template<> | |
| 184 WebUIController* NewWebUI<dom_distiller::DomDistillerUI>(WebUI* web_ui, | |
| 
Evan Stade
2013/09/11 01:44:01
I actually don't see why you even need this. The u
 
nyquist
2013/09/12 17:42:12
Moved the constant to the component. The plan is t
 | |
| 185 const GURL& url) { | |
| 186 return new dom_distiller::DomDistillerUI(web_ui, | |
| 187 url, | |
| 188 chrome::kChromeUIDomDistillerHost); | |
| 189 } | |
| 190 | |
| 181 // Only create ExtensionWebUI for URLs that are allowed extension bindings, | 191 // Only create ExtensionWebUI for URLs that are allowed extension bindings, | 
| 182 // hosted by actual tabs. | 192 // hosted by actual tabs. | 
| 183 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) { | 193 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) { | 
| 184 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; | 194 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; | 
| 185 return service && service->ExtensionBindingsAllowed(url); | 195 return service && service->ExtensionBindingsAllowed(url); | 
| 186 } | 196 } | 
| 187 | 197 | 
| 188 // Returns a function that can be used to create the right type of WebUI for a | 198 // 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 | 199 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated | 
| 190 // with it. | 200 // with it. | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 return &NewWebUI<ConstrainedWebDialogUI>; | 240 return &NewWebUI<ConstrainedWebDialogUI>; | 
| 231 if (url.host() == chrome::kChromeUICrashesHost) | 241 if (url.host() == chrome::kChromeUICrashesHost) | 
| 232 return &NewWebUI<CrashesUI>; | 242 return &NewWebUI<CrashesUI>; | 
| 233 #if defined(ENABLE_MDNS) | 243 #if defined(ENABLE_MDNS) | 
| 234 if (url.host() == chrome::kChromeUIDevicesFrameHost && | 244 if (url.host() == chrome::kChromeUIDevicesFrameHost && | 
| 235 !CommandLine::ForCurrentProcess()->HasSwitch( | 245 !CommandLine::ForCurrentProcess()->HasSwitch( | 
| 236 switches::kDisableDeviceDiscovery)) { | 246 switches::kDisableDeviceDiscovery)) { | 
| 237 return &NewWebUI<LocalDiscoveryUI>; | 247 return &NewWebUI<LocalDiscoveryUI>; | 
| 238 } | 248 } | 
| 239 #endif | 249 #endif | 
| 250 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 251 switches::kEnableDomDistiller) && | |
| 252 url.host() == chrome::kChromeUIDomDistillerHost) { | |
| 253 return &NewWebUI<dom_distiller::DomDistillerUI>; | |
| 254 } | |
| 240 if (url.host() == chrome::kChromeUIFlagsHost) | 255 if (url.host() == chrome::kChromeUIFlagsHost) | 
| 241 return &NewWebUI<FlagsUI>; | 256 return &NewWebUI<FlagsUI>; | 
| 242 if (url.host() == chrome::kChromeUIHistoryFrameHost) | 257 if (url.host() == chrome::kChromeUIHistoryFrameHost) | 
| 243 return &NewWebUI<HistoryUI>; | 258 return &NewWebUI<HistoryUI>; | 
| 244 if (url.host() == chrome::kChromeUIInlineLoginHost) | 259 if (url.host() == chrome::kChromeUIInlineLoginHost) | 
| 245 return &NewWebUI<InlineLoginUI>; | 260 return &NewWebUI<InlineLoginUI>; | 
| 246 if (url.host() == chrome::kChromeUIInstantHost) | 261 if (url.host() == chrome::kChromeUIInstantHost) | 
| 247 return &NewWebUI<InstantUI>; | 262 return &NewWebUI<InstantUI>; | 
| 248 if (url.host() == chrome::kChromeUIManagedUserPassphrasePageHost) | 263 if (url.host() == chrome::kChromeUIManagedUserPassphrasePageHost) | 
| 249 return &NewWebUI<ConstrainedWebDialogUI>; | 264 return &NewWebUI<ConstrainedWebDialogUI>; | 
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 if (page_url.host() == chrome::kChromeUIPluginsHost) | 637 if (page_url.host() == chrome::kChromeUIPluginsHost) | 
| 623 return PluginsUI::GetFaviconResourceBytes(scale_factor); | 638 return PluginsUI::GetFaviconResourceBytes(scale_factor); | 
| 624 | 639 | 
| 625 // Android doesn't use the components pages. | 640 // Android doesn't use the components pages. | 
| 626 if (page_url.host() == chrome::kChromeUIComponentsHost) | 641 if (page_url.host() == chrome::kChromeUIComponentsHost) | 
| 627 return ComponentsUI::GetFaviconResourceBytes(scale_factor); | 642 return ComponentsUI::GetFaviconResourceBytes(scale_factor); | 
| 628 #endif | 643 #endif | 
| 629 | 644 | 
| 630 return NULL; | 645 return NULL; | 
| 631 } | 646 } | 
| OLD | NEW |