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

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

Issue 105723002: Add the scheme chrome-distiller:// and hook up data source. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unnecessary dependency on DomDistillerService 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/content/dom_distiller_service_factory.h"
58 #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" 59 #include "components/dom_distiller/core/dom_distiller_service.h"
60 #include "components/dom_distiller/webui/dom_distiller_ui.h" 60 #include "components/dom_distiller/webui/dom_distiller_ui.h"
61 #include "components/dom_distiller/webui/dom_distiller_viewer_ui.h"
61 #include "content/public/browser/web_contents.h" 62 #include "content/public/browser/web_contents.h"
62 #include "content/public/browser/web_ui.h" 63 #include "content/public/browser/web_ui.h"
63 #include "content/public/common/content_client.h" 64 #include "content/public/common/content_client.h"
64 #include "content/public/common/url_utils.h" 65 #include "content/public/common/url_utils.h"
65 #include "extensions/common/constants.h" 66 #include "extensions/common/constants.h"
66 #include "extensions/common/feature_switch.h" 67 #include "extensions/common/feature_switch.h"
67 #include "ui/gfx/favicon_size.h" 68 #include "ui/gfx/favicon_size.h"
68 #include "ui/web_dialogs/web_dialog_ui.h" 69 #include "ui/web_dialogs/web_dialog_ui.h"
69 #include "url/gurl.h" 70 #include "url/gurl.h"
70 71
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 template<> 193 template<>
193 WebUIController* NewWebUI<dom_distiller::DomDistillerUi>(WebUI* web_ui, 194 WebUIController* NewWebUI<dom_distiller::DomDistillerUi>(WebUI* web_ui,
194 const GURL& url) { 195 const GURL& url) {
195 // The DomDistillerUi can not depend on components/dom_distiller/content, 196 // The DomDistillerUi can not depend on components/dom_distiller/content,
196 // so inject the correct DomDistillerService from chrome/. 197 // so inject the correct DomDistillerService from chrome/.
197 content::BrowserContext* browser_context = 198 content::BrowserContext* browser_context =
198 web_ui->GetWebContents()->GetBrowserContext(); 199 web_ui->GetWebContents()->GetBrowserContext();
199 dom_distiller::DomDistillerService* service = 200 dom_distiller::DomDistillerService* service =
200 dom_distiller::DomDistillerServiceFactory::GetForBrowserContext( 201 dom_distiller::DomDistillerServiceFactory::GetForBrowserContext(
201 browser_context); 202 browser_context);
202 // TODO(nyquist): Add real scheme. 203 return new dom_distiller::DomDistillerUi(web_ui,
203 return new dom_distiller::DomDistillerUi(web_ui, service, "dummy"); 204 service,
205 chrome::kDomDistillerScheme);
204 } 206 }
205 207
206 // Only create ExtensionWebUI for URLs that are allowed extension bindings, 208 // Only create ExtensionWebUI for URLs that are allowed extension bindings,
207 // hosted by actual tabs. 209 // hosted by actual tabs.
208 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) { 210 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) {
209 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; 211 ExtensionService* service = profile ? profile->GetExtensionService() : NULL;
210 return service && service->ExtensionBindingsAllowed(url); 212 return service && service->ExtensionBindingsAllowed(url);
211 } 213 }
212 214
213 // Returns a function that can be used to create the right type of WebUI for a 215 // Returns a function that can be used to create the right type of WebUI for a
214 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated 216 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated
215 // with it. 217 // with it.
216 WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, 218 WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
217 Profile* profile, 219 Profile* profile,
218 const GURL& url) { 220 const GURL& url) {
219 #if defined(ENABLE_EXTENSIONS) 221 #if defined(ENABLE_EXTENSIONS)
220 if (NeedsExtensionWebUI(profile, url)) 222 if (NeedsExtensionWebUI(profile, url))
221 return &NewWebUI<ExtensionWebUI>; 223 return &NewWebUI<ExtensionWebUI>;
222 #endif 224 #endif
223 225
224 // This will get called a lot to check all URLs, so do a quick check of other 226 // This will get called a lot to check all URLs, so do a quick check of other
225 // schemes to filter out most URLs. 227 // schemes to filter out most URLs.
226 if (!url.SchemeIs(chrome::kChromeDevToolsScheme) && 228 if (!url.SchemeIs(chrome::kChromeDevToolsScheme) &&
227 !url.SchemeIs(chrome::kChromeInternalScheme) && 229 !url.SchemeIs(chrome::kChromeInternalScheme) &&
228 !url.SchemeIs(chrome::kChromeUIScheme)) { 230 !url.SchemeIs(chrome::kChromeUIScheme) &&
231 !url.SchemeIs(chrome::kDomDistillerScheme)) {
229 return NULL; 232 return NULL;
230 } 233 }
231 234
232 // Special case the new tab page. In older versions of Chrome, the new tab 235 // Special case the new tab page. In older versions of Chrome, the new tab
233 // page was hosted at chrome-internal:<blah>. This might be in people's saved 236 // page was hosted at chrome-internal:<blah>. This might be in people's saved
234 // sessions or bookmarks, so we say any URL with that scheme triggers the new 237 // sessions or bookmarks, so we say any URL with that scheme triggers the new
235 // tab page. 238 // tab page.
236 if (url.host() == chrome::kChromeUINewTabHost || 239 if (url.host() == chrome::kChromeUINewTabHost ||
237 url.SchemeIs(chrome::kChromeInternalScheme)) { 240 url.SchemeIs(chrome::kChromeInternalScheme)) {
238 return &NewWebUI<NewTabUI>; 241 return &NewWebUI<NewTabUI>;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 return &NewWebUI<extensions::ExtensionsUI>; 490 return &NewWebUI<extensions::ExtensionsUI>;
488 #endif 491 #endif
489 #if defined(ENABLE_FULL_PRINTING) 492 #if defined(ENABLE_FULL_PRINTING)
490 if (url.host() == chrome::kChromeUIPrintHost && 493 if (url.host() == chrome::kChromeUIPrintHost &&
491 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) 494 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled))
492 return &NewWebUI<PrintPreviewUI>; 495 return &NewWebUI<PrintPreviewUI>;
493 #endif 496 #endif
494 497
495 if (CommandLine::ForCurrentProcess()->HasSwitch( 498 if (CommandLine::ForCurrentProcess()->HasSwitch(
496 switches::kEnableDomDistiller)) { 499 switches::kEnableDomDistiller)) {
497 if (url.host() == dom_distiller::kChromeUIDomDistillerHost) { 500 if (url.SchemeIs(chrome::kDomDistillerScheme)) {
501 return &NewWebUI<dom_distiller::DomDistillerViewerUi>;
502 } else if (url.host() == dom_distiller::kChromeUIDomDistillerHost) {
498 return &NewWebUI<dom_distiller::DomDistillerUi>; 503 return &NewWebUI<dom_distiller::DomDistillerUi>;
499 } 504 }
500 } 505 }
501 506
502 return NULL; 507 return NULL;
503 } 508 }
504 509
505 void RunFaviconCallbackAsync( 510 void RunFaviconCallbackAsync(
506 const FaviconService::FaviconResultsCallback& callback, 511 const FaviconService::FaviconResultsCallback& callback,
507 const std::vector<chrome::FaviconBitmapResult>* results) { 512 const std::vector<chrome::FaviconBitmapResult>* results) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 if (page_url.host() == chrome::kChromeUIPluginsHost) 670 if (page_url.host() == chrome::kChromeUIPluginsHost)
666 return PluginsUI::GetFaviconResourceBytes(scale_factor); 671 return PluginsUI::GetFaviconResourceBytes(scale_factor);
667 672
668 // Android doesn't use the components pages. 673 // Android doesn't use the components pages.
669 if (page_url.host() == chrome::kChromeUIComponentsHost) 674 if (page_url.host() == chrome::kChromeUIComponentsHost)
670 return ComponentsUI::GetFaviconResourceBytes(scale_factor); 675 return ComponentsUI::GetFaviconResourceBytes(scale_factor);
671 #endif 676 #endif
672 677
673 return NULL; 678 return NULL;
674 } 679 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698