Chromium Code Reviews| 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..721bfddb59b061f9b85123711ea7ffa0085cff21 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( |
|
nyquist
2015/09/10 19:04:13
Is this a blocking call?
mdjones
2015/09/11 16:50:13
No, from my understanding you immediately get back
nyquist
2015/09/11 17:14:23
So if it's not blocking, what will happen when you
mdjones
2015/09/11 18:25:54
It fails quietly. It is possible to check for an e
|
| 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. |