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

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

Powered by Google App Engine
This is Rietveld 408576698