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

Side by Side Diff: components/dom_distiller/content/dom_distiller_viewer_source.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: Add more verification that the scheme is correctly registered and loading page works. Created 6 years, 11 months 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 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.
4
5 #include "components/dom_distiller/content/dom_distiller_viewer_source.h"
6
7 #include <string>
8
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 "content/public/common/url_constants.h"
14 #include "net/url_request/url_request.h"
15 #include "url/gurl.h"
16
17 namespace dom_distiller {
18
19 DomDistillerViewerSource::DomDistillerViewerSource() {}
20
21 DomDistillerViewerSource::~DomDistillerViewerSource() {}
22
23 std::string DomDistillerViewerSource::GetSource() const {
24 return chrome::kDomDistillerScheme;
25 }
26
27 void DomDistillerViewerSource::StartDataRequest(
28 const std::string& path,
29 int render_process_id,
30 int render_frame_id,
31 const content::URLDataSource::GotDataCallback& callback) {
32 content::RenderFrameHost* render_frame_host =
33 content::RenderFrameHost::FromID(render_process_id, render_frame_id);
34 DCHECK(render_frame_host);
35 content::RenderViewHost* render_view_host =
36 render_frame_host->GetRenderViewHost();
37 DCHECK(render_view_host);
38 CHECK_EQ(0, render_view_host->GetEnabledBindings());
39
40 std::string page_template = "Aloha!";
41 callback.Run(base::RefCountedString::TakeString(&page_template));
42 };
43
44 std::string DomDistillerViewerSource::GetMimeType(const std::string& path)
45 const {
nasko 2014/01/23 16:37:04 style: const shouldn't be on its own line.
nyquist 2014/01/24 03:03:07 This is being done by our clang-format I am afraid
jam 2014/01/24 22:07:54 seems like until clang-format is fixed, this shoul
Nico 2014/01/24 22:16:35 How'd you format this? clang-format is used widel
jam 2014/01/24 22:29:25 Oh, I was under the impression that clang-format s
46 return "text/html";
47 }
48
49 bool DomDistillerViewerSource::ShouldServiceRequest(
50 const net::URLRequest* request) const {
51 return request->url().SchemeIs(chrome::kDomDistillerScheme);
52 }
53
54 std::string DomDistillerViewerSource::GetContentSecurityPolicyFrameSrc() const {
55 return "frame-src none;";
56 }
57
58 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698