Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc

Issue 105623002: Debug UI for DOM distiller supports distillation and lists articles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup after the mechanical-style move in patch set 1 Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "chrome/browser/ui/webui/signin/user_manager_ui.h" 47 #include "chrome/browser/ui/webui/signin/user_manager_ui.h"
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/pref_names.h" 55 #include "chrome/common/pref_names.h"
56 #include "chrome/common/url_constants.h" 56 #include "chrome/common/url_constants.h"
57 #include "components/dom_distiller/content/dom_distiller_service_factory.h"
57 #include "components/dom_distiller/core/dom_distiller_constants.h" 58 #include "components/dom_distiller/core/dom_distiller_constants.h"
59 #include "components/dom_distiller/core/dom_distiller_service.h"
58 #include "components/dom_distiller/webui/dom_distiller_ui.h" 60 #include "components/dom_distiller/webui/dom_distiller_ui.h"
59 #include "content/public/browser/web_contents.h" 61 #include "content/public/browser/web_contents.h"
60 #include "content/public/browser/web_ui.h" 62 #include "content/public/browser/web_ui.h"
61 #include "content/public/common/content_client.h" 63 #include "content/public/common/content_client.h"
62 #include "content/public/common/url_utils.h" 64 #include "content/public/common/url_utils.h"
63 #include "extensions/common/constants.h" 65 #include "extensions/common/constants.h"
64 #include "extensions/common/feature_switch.h" 66 #include "extensions/common/feature_switch.h"
65 #include "ui/gfx/favicon_size.h" 67 #include "ui/gfx/favicon_size.h"
66 #include "ui/web_dialogs/web_dialog_ui.h" 68 #include "ui/web_dialogs/web_dialog_ui.h"
67 #include "url/gurl.h" 69 #include "url/gurl.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 return new AboutUI(web_ui, url.host()); 181 return new AboutUI(web_ui, url.host());
180 } 182 }
181 183
182 #if defined(OS_CHROMEOS) 184 #if defined(OS_CHROMEOS)
183 template<> 185 template<>
184 WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) { 186 WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) {
185 return new chromeos::OobeUI(web_ui, url); 187 return new chromeos::OobeUI(web_ui, url);
186 } 188 }
187 #endif 189 #endif
188 190
191 // Special cases for DOM distiller.
192 template<>
193 WebUIController* NewWebUI<dom_distiller::DomDistillerUi>(WebUI* web_ui,
194 const GURL& url) {
195 // The DomDistillerUi can not depend on components/dom_distiller/content,
196 // so inject the correct DomDistillerService from chrome/.
197 content::BrowserContext* browser_context =
198 web_ui->GetWebContents()->GetBrowserContext();
199 dom_distiller::DomDistillerService* service =
200 dom_distiller::DomDistillerServiceFactory::GetForBrowserContext(
201 browser_context);
202 return new dom_distiller::DomDistillerUi(web_ui, service, "dummy");
Nico 2013/12/05 00:03:58 Add "//TODO: add real scheme"
nyquist 2013/12/05 00:24:02 Done.
203 }
204
189 // Only create ExtensionWebUI for URLs that are allowed extension bindings, 205 // Only create ExtensionWebUI for URLs that are allowed extension bindings,
190 // hosted by actual tabs. 206 // hosted by actual tabs.
191 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) { 207 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) {
192 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; 208 ExtensionService* service = profile ? profile->GetExtensionService() : NULL;
193 return service && service->ExtensionBindingsAllowed(url); 209 return service && service->ExtensionBindingsAllowed(url);
194 } 210 }
195 211
196 // Returns a function that can be used to create the right type of WebUI for a 212 // Returns a function that can be used to create the right type of WebUI for a
197 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated 213 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated
198 // with it. 214 // with it.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return &NewWebUI<ConstrainedWebDialogUI>; 254 return &NewWebUI<ConstrainedWebDialogUI>;
239 if (url.host() == chrome::kChromeUICrashesHost) 255 if (url.host() == chrome::kChromeUICrashesHost)
240 return &NewWebUI<CrashesUI>; 256 return &NewWebUI<CrashesUI>;
241 #if defined(ENABLE_MDNS) 257 #if defined(ENABLE_MDNS)
242 if (url.host() == chrome::kChromeUIDevicesHost && 258 if (url.host() == chrome::kChromeUIDevicesHost &&
243 !CommandLine::ForCurrentProcess()->HasSwitch( 259 !CommandLine::ForCurrentProcess()->HasSwitch(
244 switches::kDisableDeviceDiscovery)) { 260 switches::kDisableDeviceDiscovery)) {
245 return &NewWebUI<LocalDiscoveryUI>; 261 return &NewWebUI<LocalDiscoveryUI>;
246 } 262 }
247 #endif 263 #endif
248 if (CommandLine::ForCurrentProcess()->HasSwitch(
249 switches::kEnableDomDistiller) &&
250 url.host() == dom_distiller::kChromeUIDomDistillerHost) {
251 return &NewWebUI<dom_distiller::DomDistillerUI>;
252 }
253 if (url.host() == chrome::kChromeUIFlagsHost) 264 if (url.host() == chrome::kChromeUIFlagsHost)
254 return &NewWebUI<FlagsUI>; 265 return &NewWebUI<FlagsUI>;
255 if (url.host() == chrome::kChromeUIHistoryFrameHost) 266 if (url.host() == chrome::kChromeUIHistoryFrameHost)
256 return &NewWebUI<HistoryUI>; 267 return &NewWebUI<HistoryUI>;
257 if (url.host() == chrome::kChromeUIChromeSigninHost) 268 if (url.host() == chrome::kChromeUIChromeSigninHost)
258 return &NewWebUI<InlineLoginUI>; 269 return &NewWebUI<InlineLoginUI>;
259 if (url.host() == chrome::kChromeUIInstantHost) 270 if (url.host() == chrome::kChromeUIInstantHost)
260 return &NewWebUI<InstantUI>; 271 return &NewWebUI<InstantUI>;
261 if (url.host() == chrome::kChromeUIManagedUserPassphrasePageHost) 272 if (url.host() == chrome::kChromeUIManagedUserPassphrasePageHost)
262 return &NewWebUI<ConstrainedWebDialogUI>; 273 return &NewWebUI<ConstrainedWebDialogUI>;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } 482 }
472 if (url.host() == chrome::kChromeUIExtensionsFrameHost) 483 if (url.host() == chrome::kChromeUIExtensionsFrameHost)
473 return &NewWebUI<extensions::ExtensionsUI>; 484 return &NewWebUI<extensions::ExtensionsUI>;
474 #endif 485 #endif
475 #if defined(ENABLE_FULL_PRINTING) 486 #if defined(ENABLE_FULL_PRINTING)
476 if (url.host() == chrome::kChromeUIPrintHost && 487 if (url.host() == chrome::kChromeUIPrintHost &&
477 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) 488 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled))
478 return &NewWebUI<PrintPreviewUI>; 489 return &NewWebUI<PrintPreviewUI>;
479 #endif 490 #endif
480 491
492 if (CommandLine::ForCurrentProcess()->HasSwitch(
493 switches::kEnableDomDistiller)) {
494 if (url.host() == dom_distiller::kChromeUIDomDistillerHost) {
495 return &NewWebUI<dom_distiller::DomDistillerUi>;
496 }
497 }
498
481 return NULL; 499 return NULL;
482 } 500 }
483 501
484 void RunFaviconCallbackAsync( 502 void RunFaviconCallbackAsync(
485 const FaviconService::FaviconResultsCallback& callback, 503 const FaviconService::FaviconResultsCallback& callback,
486 const std::vector<chrome::FaviconBitmapResult>* results) { 504 const std::vector<chrome::FaviconBitmapResult>* results) {
487 base::MessageLoopProxy::current()->PostTask( 505 base::MessageLoopProxy::current()->PostTask(
488 FROM_HERE, 506 FROM_HERE,
489 base::Bind(&FaviconService::FaviconResultsCallbackRunner, 507 base::Bind(&FaviconService::FaviconResultsCallbackRunner,
490 callback, base::Owned(results))); 508 callback, base::Owned(results)));
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 if (page_url.host() == chrome::kChromeUIPluginsHost) 662 if (page_url.host() == chrome::kChromeUIPluginsHost)
645 return PluginsUI::GetFaviconResourceBytes(scale_factor); 663 return PluginsUI::GetFaviconResourceBytes(scale_factor);
646 664
647 // Android doesn't use the components pages. 665 // Android doesn't use the components pages.
648 if (page_url.host() == chrome::kChromeUIComponentsHost) 666 if (page_url.host() == chrome::kChromeUIComponentsHost)
649 return ComponentsUI::GetFaviconResourceBytes(scale_factor); 667 return ComponentsUI::GetFaviconResourceBytes(scale_factor);
650 #endif 668 #endif
651 669
652 return NULL; 670 return NULL;
653 } 671 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698