OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/dom_distiller/webui/dom_distiller_viewer_ui.h" |
| 6 |
| 7 #include "components/dom_distiller/core/dom_distiller_constants.h" |
| 8 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 9 #include "components/dom_distiller/webui/dom_distiller_viewer_handler.h" |
| 10 #include "content/public/browser/browser_context.h" |
| 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/browser/web_ui.h" |
| 13 #include "content/public/browser/web_ui_data_source.h" |
| 14 #include "grit/component_strings.h" |
| 15 #include "grit/dom_distiller_resources.h" |
| 16 |
| 17 namespace dom_distiller { |
| 18 |
| 19 DomDistillerViewerUi::DomDistillerViewerUi(content::WebUI* web_ui) |
| 20 : content::WebUIController(web_ui) { |
| 21 content::WebContents* web_contents = web_ui->GetWebContents(); |
| 22 GURL url = web_contents->GetVisibleURL(); |
| 23 // Set up WebUIDataSource. |
| 24 content::WebUIDataSource* source = |
| 25 content::WebUIDataSource::Create(url.host()); |
| 26 source->SetDefaultResource(IDR_DOM_DISTILLER_VIEWER_HTML); |
| 27 source->AddResourcePath("dom_distiller_viewer.css", |
| 28 IDR_DOM_DISTILLER_VIEWER_CSS); |
| 29 source->AddResourcePath("dom_distiller_viewer.js", |
| 30 IDR_DOM_DISTILLER_VIEWER_JS); |
| 31 |
| 32 source->SetUseJsonJSFormatV2(); |
| 33 content::BrowserContext* browser_context = |
| 34 web_ui->GetWebContents()->GetBrowserContext(); |
| 35 content::WebUIDataSource::Add(browser_context, source); |
| 36 |
| 37 // Add message handler. |
| 38 DomDistillerViewerHandler* handler = |
| 39 new DomDistillerViewerHandler(url, web_contents); |
| 40 web_ui->AddMessageHandler(handler); |
| 41 } |
| 42 |
| 43 DomDistillerViewerUi::~DomDistillerViewerUi() {} |
| 44 |
| 45 } // namespace dom_distiller |
OLD | NEW |