| Index: components/dom_distiller/webui/dom_distiller_viewer_ui.cc
|
| diff --git a/components/dom_distiller/webui/dom_distiller_viewer_ui.cc b/components/dom_distiller/webui/dom_distiller_viewer_ui.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..35359fec83044edb52e627b19ffcba00b9b966a7
|
| --- /dev/null
|
| +++ b/components/dom_distiller/webui/dom_distiller_viewer_ui.cc
|
| @@ -0,0 +1,45 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/dom_distiller/webui/dom_distiller_viewer_ui.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_viewer_handler.h"
|
| +#include "content/public/browser/browser_context.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#include "content/public/browser/web_ui.h"
|
| +#include "content/public/browser/web_ui_data_source.h"
|
| +#include "grit/component_strings.h"
|
| +#include "grit/dom_distiller_resources.h"
|
| +
|
| +namespace dom_distiller {
|
| +
|
| +DomDistillerViewerUi::DomDistillerViewerUi(content::WebUI* web_ui)
|
| + : content::WebUIController(web_ui) {
|
| + content::WebContents* web_contents = web_ui->GetWebContents();
|
| + GURL url = web_contents->GetVisibleURL();
|
| + // Set up WebUIDataSource.
|
| + content::WebUIDataSource* source =
|
| + content::WebUIDataSource::Create(url.host());
|
| + source->SetDefaultResource(IDR_DOM_DISTILLER_VIEWER_HTML);
|
| + source->AddResourcePath("dom_distiller_viewer.css",
|
| + IDR_DOM_DISTILLER_VIEWER_CSS);
|
| + source->AddResourcePath("dom_distiller_viewer.js",
|
| + IDR_DOM_DISTILLER_VIEWER_JS);
|
| +
|
| + source->SetUseJsonJSFormatV2();
|
| + content::BrowserContext* browser_context =
|
| + web_ui->GetWebContents()->GetBrowserContext();
|
| + content::WebUIDataSource::Add(browser_context, source);
|
| +
|
| + // Add message handler.
|
| + DomDistillerViewerHandler* handler =
|
| + new DomDistillerViewerHandler(url, web_contents);
|
| + web_ui->AddMessageHandler(handler);
|
| +}
|
| +
|
| +DomDistillerViewerUi::~DomDistillerViewerUi() {}
|
| +
|
| +} // namespace dom_distiller
|
|
|