OLD | NEW |
---|---|
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 "components/dom_distiller/content/browser/distiller_javascript_service_ impl.h" | 5 #include "components/dom_distiller/content/browser/distiller_javascript_service_ impl.h" |
6 #include "components/dom_distiller/content/browser/external_feedback_reporter.h" | |
7 #include "components/dom_distiller/core/feedback_reporter.h" | |
6 #include "third_party/mojo/src/mojo/public/cpp/bindings/string.h" | 8 #include "third_party/mojo/src/mojo/public/cpp/bindings/string.h" |
7 | 9 |
8 namespace dom_distiller { | 10 namespace dom_distiller { |
9 | 11 |
10 DistillerJavaScriptServiceImpl::DistillerJavaScriptServiceImpl( | 12 DistillerJavaScriptServiceImpl::DistillerJavaScriptServiceImpl( |
11 mojo::InterfaceRequest<DistillerJavaScriptService> request) | 13 content::RenderFrameHost* render_frame_host, |
12 : binding_(this, request.Pass()) {} | 14 ExternalFeedbackReporter* external_feedback_reporter, |
15 mojo::InterfaceRequest<DistillerJavaScriptService> request) | |
16 : binding_(this, request.Pass()), | |
17 render_frame_host_(render_frame_host), | |
18 external_feedback_reporter_(external_feedback_reporter) {} | |
13 | 19 |
14 DistillerJavaScriptServiceImpl::~DistillerJavaScriptServiceImpl() {} | 20 DistillerJavaScriptServiceImpl::~DistillerJavaScriptServiceImpl() {} |
15 | 21 |
16 void DistillerJavaScriptServiceImpl::HandleDistillerEchoCall( | 22 void DistillerJavaScriptServiceImpl::HandleDistillerEchoCall( |
17 const mojo::String& message) {} | 23 const mojo::String& message) {} |
18 | 24 |
25 void DistillerJavaScriptServiceImpl::HandleDistillerFeedbackCall( | |
26 bool good) { | |
27 if (good) { | |
28 FeedbackReporter::ReportQuality(true); | |
29 return; | |
30 } | |
31 | |
32 // If feedback is bad, report it and try to start up external feedback. | |
33 FeedbackReporter::ReportQuality(false); | |
nyquist
2015/09/10 19:04:13
Could we just do:
###
FeedbackReporter::ReportQual
mdjones
2015/09/11 16:50:13
Done.
| |
34 if (!external_feedback_reporter_) { | |
35 return; | |
36 } | |
37 content::WebContents* contents = | |
38 content::WebContents::FromRenderFrameHost(render_frame_host_); | |
39 external_feedback_reporter_->ReportExternalFeedback( | |
40 contents, contents->GetURL(), false); | |
41 return; | |
42 } | |
43 | |
19 void CreateDistillerJavaScriptService( | 44 void CreateDistillerJavaScriptService( |
45 content::RenderFrameHost* render_frame_host, | |
46 ExternalFeedbackReporter* feedback_reporter, | |
20 mojo::InterfaceRequest<DistillerJavaScriptService> request) { | 47 mojo::InterfaceRequest<DistillerJavaScriptService> request) { |
21 // This is strongly bound and owned by the pipe. | 48 // This is strongly bound and owned by the pipe. |
22 new DistillerJavaScriptServiceImpl(request.Pass()); | 49 new DistillerJavaScriptServiceImpl(render_frame_host, feedback_reporter, |
50 request.Pass()); | |
23 } | 51 } |
24 | 52 |
25 } // namespace dom_distiller | 53 } // namespace dom_distiller |
OLD | NEW |