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 DomDistillerService* service) |
| 21 : content::WebUIController(web_ui) { |
| 22 content::WebContents* web_contents = web_ui->GetWebContents(); |
| 23 GURL url = web_contents->GetVisibleURL(); |
| 24 // Set up WebUIDataSource. |
| 25 content::WebUIDataSource* source = |
| 26 content::WebUIDataSource::Create(url.host()); |
| 27 source->SetDefaultResource(IDR_DOM_DISTILLER_VIEWER_HTML); |
| 28 source->AddResourcePath("dom_distiller_viewer.css", |
| 29 IDR_DOM_DISTILLER_VIEWER_CSS); |
| 30 source->AddResourcePath("dom_distiller_viewer.js", |
| 31 IDR_DOM_DISTILLER_VIEWER_JS); |
| 32 |
| 33 source->SetUseJsonJSFormatV2(); |
| 34 content::BrowserContext* browser_context = |
| 35 web_ui->GetWebContents()->GetBrowserContext(); |
| 36 content::WebUIDataSource::Add(browser_context, source); |
| 37 |
| 38 // Add message handler. |
| 39 DomDistillerViewerHandler* handler = |
| 40 new DomDistillerViewerHandler(service, url, web_contents); |
| 41 web_ui->AddMessageHandler(handler); |
| 42 } |
| 43 |
| 44 DomDistillerViewerUi::~DomDistillerViewerUi() {} |
| 45 |
| 46 } // namespace dom_distiller |
OLD | NEW |