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

Side by Side Diff: components/dom_distiller/content/renderer/distillability_agent.cc

Issue 1891643002: Reader Mode distillability uses Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add web contents check Created 4 years, 8 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
« no previous file with comments | « components/dom_distiller/content/renderer/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/histogram.h" 5 #include "base/metrics/histogram.h"
6 #include "base/strings/string_util.h"
6 7
7 #include "components/dom_distiller/content/common/distiller_messages.h" 8 #include "components/dom_distiller/content/common/distillability_service.mojom.h "
8 #include "components/dom_distiller/content/renderer/distillability_agent.h" 9 #include "components/dom_distiller/content/renderer/distillability_agent.h"
9 #include "components/dom_distiller/core/distillable_page_detector.h" 10 #include "components/dom_distiller/core/distillable_page_detector.h"
10 #include "components/dom_distiller/core/experiments.h" 11 #include "components/dom_distiller/core/experiments.h"
11 #include "components/dom_distiller/core/page_features.h" 12 #include "components/dom_distiller/core/page_features.h"
12 #include "components/dom_distiller/core/url_utils.h" 13 #include "components/dom_distiller/core/url_utils.h"
14 #include "content/public/common/service_registry.h"
13 #include "content/public/renderer/render_frame.h" 15 #include "content/public/renderer/render_frame.h"
14 16
15 #include "third_party/WebKit/public/platform/WebDistillability.h" 17 #include "third_party/WebKit/public/platform/WebDistillability.h"
16 #include "third_party/WebKit/public/web/WebDocument.h" 18 #include "third_party/WebKit/public/web/WebDocument.h"
17 #include "third_party/WebKit/public/web/WebElement.h" 19 #include "third_party/WebKit/public/web/WebElement.h"
18 #include "third_party/WebKit/public/web/WebLocalFrame.h" 20 #include "third_party/WebKit/public/web/WebLocalFrame.h"
19 21
20 namespace dom_distiller { 22 namespace dom_distiller {
21 23
22 using namespace blink; 24 using namespace blink;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if (!render_frame()->IsMainFrame()) return; 141 if (!render_frame()->IsMainFrame()) return;
140 DCHECK(render_frame()->GetWebFrame()); 142 DCHECK(render_frame()->GetWebFrame());
141 WebDocument doc = render_frame()->GetWebFrame()->document(); 143 WebDocument doc = render_frame()->GetWebFrame()->document();
142 if (doc.isNull() || doc.body().isNull()) return; 144 if (doc.isNull() || doc.body().isNull()) return;
143 if (!url_utils::IsUrlDistillable(doc.url())) return; 145 if (!url_utils::IsUrlDistillable(doc.url())) return;
144 146
145 bool is_loaded = layout_type == WebMeaningfulLayout::FinishedLoading; 147 bool is_loaded = layout_type == WebMeaningfulLayout::FinishedLoading;
146 if (!NeedToUpdate(is_loaded)) return; 148 if (!NeedToUpdate(is_loaded)) return;
147 149
148 bool is_last = IsLast(is_loaded); 150 bool is_last = IsLast(is_loaded);
149 Send(new FrameHostMsg_Distillability(routing_id(), 151 // Connect to Mojo service on browser to notify page distillability.
150 IsDistillablePage(doc, is_last), is_last)); 152 DistillabilityServicePtr distillability_service;
153 render_frame()->GetServiceRegistry()->ConnectToRemoteService(
154 mojo::GetProxy(&distillability_service));
155 DCHECK(distillability_service);
156 distillability_service->NotifyIsDistillable(
157 IsDistillablePage(doc, is_last), is_last);
151 } 158 }
152 159
153
154 DistillabilityAgent::~DistillabilityAgent() {} 160 DistillabilityAgent::~DistillabilityAgent() {}
155 161
156 } // namespace dom_distiller 162 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/content/renderer/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698