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

Unified Diff: components/dom_distiller/content/renderer/distillability_agent.cc

Issue 1248643004: Test distillability without JavaScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@early
Patch Set: fix oopsies Created 5 years, 2 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/renderer/distillability_agent.cc
diff --git a/components/dom_distiller/content/renderer/distillability_agent.cc b/components/dom_distiller/content/renderer/distillability_agent.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cece0234091456fb1c663db8af95d1e5e8fcc7b8
--- /dev/null
+++ b/components/dom_distiller/content/renderer/distillability_agent.cc
@@ -0,0 +1,48 @@
+// Copyright 2015 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/common/distiller_messages.h"
+#include "components/dom_distiller/content/renderer/distillability_agent.h"
+
+#include "content/public/renderer/render_frame.h"
+
+#include "third_party/WebKit/public/platform/WebDistillability.h"
+#include "third_party/WebKit/public/web/WebDocument.h"
+#include "third_party/WebKit/public/web/WebElement.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
+#include "third_party/WebKit/public/web/WebNode.h"
+#include "third_party/WebKit/public/web/WebNodeList.h"
+
+namespace dom_distiller {
+
+namespace {
+
+} // namespace
+
+using namespace blink;
+
+DistillabilityAgent::DistillabilityAgent(
+ content::RenderFrame* render_frame)
+ : RenderFrameObserver(render_frame) {
+}
+
+void DistillabilityAgent::DidMeaningfulLayout(
+ WebMeaningfulLayout layout_type) {
+
+ if (layout_type == WebMeaningfulLayout::FinishedParsing ||
+ layout_type == WebMeaningfulLayout::FinishedLoading) {
+ DCHECK(render_frame());
+ DCHECK(render_frame()->GetWebFrame());
+ WebDocument doc = render_frame()->GetWebFrame()->document();
+ DCHECK(!doc.isNull());
+ WebDistillabilityFeatures features = doc.distillabilityFeatures();
+
+ // FIXME: get flags, model, derived features, and calculate results
+ Send(new FrameHostMsg_Distillability(routing_id(), features.openGraph));
+ }
+}
+
+DistillabilityAgent::~DistillabilityAgent() {}
+
+} // namespace dom_distiller

Powered by Google App Engine
This is Rietveld 408576698