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

Unified Diff: components/dom_distiller/content/browser/distiller_javascript_service_impl.cc

Issue 1265843005: Refactor feedback to use native JS object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@js-mojo-combine
Patch Set: Rebase Created 5 years, 3 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/browser/distiller_javascript_service_impl.cc
diff --git a/components/dom_distiller/content/browser/distiller_javascript_service_impl.cc b/components/dom_distiller/content/browser/distiller_javascript_service_impl.cc
index 16601d2c96fbcd91dd57f19f630b0f03682a118f..0d2a9a85e953ba86a609288ac750c7b7f9623e4b 100644
--- a/components/dom_distiller/content/browser/distiller_javascript_service_impl.cc
+++ b/components/dom_distiller/content/browser/distiller_javascript_service_impl.cc
@@ -3,23 +3,51 @@
// found in the LICENSE file.
#include "components/dom_distiller/content/browser/distiller_javascript_service_impl.h"
+#include "components/dom_distiller/content/browser/external_feedback_reporter.h"
+#include "components/dom_distiller/core/feedback_reporter.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/string.h"
namespace dom_distiller {
DistillerJavaScriptServiceImpl::DistillerJavaScriptServiceImpl(
- mojo::InterfaceRequest<DistillerJavaScriptService> request)
- : binding_(this, request.Pass()) {}
+ mojo::InterfaceRequest<DistillerJavaScriptService> request,
+ content::RenderFrameHost* render_frame_host,
+ ExternalFeedbackReporter* external_feedback_reporter)
+ : binding_(this, request.Pass()),
+ render_frame_host_(render_frame_host),
+ external_feedback_reporter_(external_feedback_reporter) {}
DistillerJavaScriptServiceImpl::~DistillerJavaScriptServiceImpl() {}
void DistillerJavaScriptServiceImpl::HandleDistillerEchoCall(
const mojo::String& message) {}
+void DistillerJavaScriptServiceImpl::HandleDistillerFeedbackCall(
+ bool good) {
+ if (good) {
+ FeedbackReporter::ReportQuality(true);
+ return;
+ }
+
+ // If feedback is bad, report it and try to start up external feedback.
+ FeedbackReporter::ReportQuality(false);
+ if (!external_feedback_reporter_) {
+ return;
+ }
+ content::WebContents* contents =
+ content::WebContents::FromRenderFrameHost(render_frame_host_);
+ external_feedback_reporter_->ReportExternalFeedback(
+ contents, contents->GetURL(), false);
+ return;
+}
+
void CreateDistillerJavaScriptService(
+ content::RenderFrameHost* render_frame_host,
+ ExternalFeedbackReporter* feedback_reporter,
mojo::InterfaceRequest<DistillerJavaScriptService> request) {
// This is strongly bound and owned by the pipe.
- new DistillerJavaScriptServiceImpl(request.Pass());
+ new DistillerJavaScriptServiceImpl(request.Pass(), render_frame_host,
+ feedback_reporter);
}
} // namespace dom_distiller

Powered by Google App Engine
This is Rietveld 408576698