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

Unified Diff: components/dom_distiller/content/renderer/distiller_native_javascript.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: impl comments 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/renderer/distiller_native_javascript.cc
diff --git a/components/dom_distiller/content/renderer/distiller_native_javascript.cc b/components/dom_distiller/content/renderer/distiller_native_javascript.cc
index 767dac67ef3d11ccc1a3803702463641308bd8b4..aa6619b22adbcb6a6bfefc2785ac24d0f195ca02 100644
--- a/components/dom_distiller/content/renderer/distiller_native_javascript.cc
+++ b/components/dom_distiller/content/renderer/distiller_native_javascript.cc
@@ -45,14 +45,30 @@ void DistillerNativeJavaScript::AddJavaScriptObjectToFrame(
isolate, base::Bind(&DistillerNativeJavaScript::DistillerEcho,
base::Unretained(this)))
->GetFunction());
+
+ distiller_obj->Set(
+ gin::StringToSymbol(isolate, "sendFeedback"),
+ gin::CreateFunctionTemplate(
+ isolate, base::Bind(&DistillerNativeJavaScript::DistillerSendFeedback,
+ base::Unretained(this)))
+ ->GetFunction());
}
-std::string DistillerNativeJavaScript::DistillerEcho(
- const std::string& message) {
+void DistillerNativeJavaScript::EnsureServiceConnected() {
if (!distiller_js_service_) {
render_frame_->GetServiceRegistry()->ConnectToRemoteService(
mojo::GetProxy(&distiller_js_service_));
}
+}
+
+void DistillerNativeJavaScript::DistillerSendFeedback(bool good) {
+ EnsureServiceConnected();
+ distiller_js_service_->HandleDistillerFeedbackCall(good);
+}
+
+std::string DistillerNativeJavaScript::DistillerEcho(
+ const std::string& message) {
+ EnsureServiceConnected();
// TODO(mdjones): It is possible and beneficial to have information
// returned from the browser process with these calls. The problem
// is waiting blocks this process.

Powered by Google App Engine
This is Rietveld 408576698