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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/dom_distiller/content/dom_distiller_viewer_source.cc
diff --git a/components/dom_distiller/content/dom_distiller_viewer_source.cc b/components/dom_distiller/content/dom_distiller_viewer_source.cc
new file mode 100644
index 0000000000000000000000000000000000000000..790a2e590b6cab7e3510b4c97461808d1bc8997b
--- /dev/null
+++ b/components/dom_distiller/content/dom_distiller_viewer_source.cc
@@ -0,0 +1,58 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/dom_distiller/content/dom_distiller_viewer_source.h"
+
+#include <string>
+
+#include "base/memory/ref_counted_memory.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/common/url_constants.h"
+#include "net/url_request/url_request.h"
+#include "url/gurl.h"
+
+namespace dom_distiller {
+
+DomDistillerViewerSource::DomDistillerViewerSource() {}
+
+DomDistillerViewerSource::~DomDistillerViewerSource() {}
+
+std::string DomDistillerViewerSource::GetSource() const {
+ return chrome::kDomDistillerScheme;
+}
+
+void DomDistillerViewerSource::StartDataRequest(
+ const std::string& path,
+ int render_process_id,
+ int render_frame_id,
+ const content::URLDataSource::GotDataCallback& callback) {
+ content::RenderFrameHost* render_frame_host =
+ content::RenderFrameHost::FromID(render_process_id, render_frame_id);
+ DCHECK(render_frame_host);
+ content::RenderViewHost* render_view_host =
+ render_frame_host->GetRenderViewHost();
+ DCHECK(render_view_host);
+ CHECK_EQ(0, render_view_host->GetEnabledBindings());
+
+ std::string page_template = "Aloha!";
+ callback.Run(base::RefCountedString::TakeString(&page_template));
+};
+
+std::string DomDistillerViewerSource::GetMimeType(const std::string& path)
+ 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
+ return "text/html";
+}
+
+bool DomDistillerViewerSource::ShouldServiceRequest(
+ const net::URLRequest* request) const {
+ return request->url().SchemeIs(chrome::kDomDistillerScheme);
+}
+
+std::string DomDistillerViewerSource::GetContentSecurityPolicyFrameSrc() const {
+ return "frame-src none;";
+}
+
+} // namespace dom_distiller

Powered by Google App Engine
This is Rietveld 408576698