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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index f18f52b661c367e5cc5cc7c7b9de8136b56ec3b4..bc20047a9cbf49311879520a4e9f2210d5cc2dea 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -54,7 +54,9 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "components/dom_distiller/content/dom_distiller_service_factory.h"
#include "components/dom_distiller/core/dom_distiller_constants.h"
+#include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/dom_distiller/webui/dom_distiller_ui.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -186,6 +188,21 @@ WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) {
}
#endif
+// Special cases for DOM distiller.
+template<>
+WebUIController* NewWebUI<dom_distiller::DomDistillerUi>(WebUI* web_ui,
+ const GURL& url) {
+ // The DomDistillerUi can not depend on components/dom_distiller/content,
+ // so inject the correct DomDistillerService from chrome/.
+ content::BrowserContext* browser_context =
+ web_ui->GetWebContents()->GetBrowserContext();
+ dom_distiller::DomDistillerService* service =
+ dom_distiller::DomDistillerServiceFactory::GetForBrowserContext(
+ browser_context);
+ // TODO(nyquist): Add real scheme.
+ return new dom_distiller::DomDistillerUi(web_ui, service, "dummy");
+}
+
// Only create ExtensionWebUI for URLs that are allowed extension bindings,
// hosted by actual tabs.
bool NeedsExtensionWebUI(Profile* profile, const GURL& url) {
@@ -245,11 +262,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<LocalDiscoveryUI>;
}
#endif
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableDomDistiller) &&
- url.host() == dom_distiller::kChromeUIDomDistillerHost) {
- return &NewWebUI<dom_distiller::DomDistillerUI>;
- }
if (url.host() == chrome::kChromeUIFlagsHost)
return &NewWebUI<FlagsUI>;
if (url.host() == chrome::kChromeUIHistoryFrameHost)
@@ -480,6 +492,13 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<PrintPreviewUI>;
#endif
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableDomDistiller)) {
+ if (url.host() == dom_distiller::kChromeUIDomDistillerHost) {
+ return &NewWebUI<dom_distiller::DomDistillerUi>;
+ }
+ }
+
return NULL;
}

Powered by Google App Engine
This is Rietveld 408576698