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

Side by Side Diff: components/dom_distiller/webui/dom_distiller_viewer_ui.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: Removed unnecessary dependency on DomDistillerService 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
(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();
nasko 2013/12/05 16:59:27 This should be GetLastCommittedURL. 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698