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 |