1 // Copyright 2014 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.
5 #include "components/dom_distiller/content/dom_distiller_viewer_source.h"
9 #include "base/memory/ref_counted_memory.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/browser/render_frame_host.h"
12 #include "content/public/browser/render_view_host.h"
13 #include "net/url_request/url_request.h"
16 namespace dom_distiller {
18 DomDistillerViewerSource::DomDistillerViewerSource(const std::string& scheme)
21 DomDistillerViewerSource::~DomDistillerViewerSource() {}
23 std::string DomDistillerViewerSource::GetSource() const { return scheme_; }
25 void DomDistillerViewerSource::StartDataRequest(
26 const std::string& path,
27 int render_process_id,
29 const content::URLDataSource::GotDataCallback& callback) {
30 content::RenderFrameHost* render_frame_host =
31 content::RenderFrameHost::FromID(render_process_id, render_frame_id);
32 DCHECK(render_frame_host);
33 content::RenderViewHost* render_view_host =
34 render_frame_host->GetRenderViewHost();
35 DCHECK(render_view_host);
36 CHECK_EQ(0, render_view_host->GetEnabledBindings());
38 std::string page_template = "Aloha!";
39 callback.Run(base::RefCountedString::TakeString(&page_template));
42 std::string DomDistillerViewerSource::GetMimeType(const std::string& path)
47 bool DomDistillerViewerSource::ShouldServiceRequest(
48 const net::URLRequest* request) const {
49 return request->url().SchemeIs(scheme_.c_str());
52 } // namespace dom_distiller