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

Unified Diff: components/dom_distiller/content/renderer/distiller_native_javascript.cc

Issue 1386043002: Open distiller UI setting through JavaScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing file Created 5 years, 2 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 02a14dd1a0c45252e0d7f23b574cd27ce84eab5d..14a3411548155a95502af6d04f334c3f0bb7ebac 100644
--- a/components/dom_distiller/content/renderer/distiller_native_javascript.cc
+++ b/components/dom_distiller/content/renderer/distiller_native_javascript.cc
@@ -39,25 +39,39 @@ void DistillerNativeJavaScript::AddJavaScriptObjectToFrame(
v8::Local<v8::Object> distiller_obj =
GetOrCreateDistillerObject(isolate, context->Global());
+ EnsureServiceConnected();
+
+ // Some of the JavaScript functions require extra work to be done when it is
+ // called, so they have wrapper functions maintained in this class.
BindFunctionToObject(
distiller_obj,
"echo",
base::Bind(
&DistillerNativeJavaScript::DistillerEcho, base::Unretained(this)));
+ // Many functions can simply call the Mojo interface directly and have no
+ // wrapper function for binding. Note that calling distiller_js_service.get()
+ // does not transfer ownership of the interface.
BindFunctionToObject(
distiller_obj,
"sendFeedback",
base::Bind(
- &DistillerNativeJavaScript::DistillerSendFeedback,
- base::Unretained(this)));
+ &DistillerJavaScriptService::HandleDistillerFeedbackCall,
+ base::Unretained(distiller_js_service_.get())));
BindFunctionToObject(
distiller_obj,
"closePanel",
base::Bind(
- &DistillerNativeJavaScript::DistillerClosePanel,
- base::Unretained(this)));
+ &DistillerJavaScriptService::HandleDistillerClosePanelCall,
+ base::Unretained(distiller_js_service_.get())));
+
+ BindFunctionToObject(
+ distiller_obj,
+ "openSettings",
+ base::Bind(
+ &DistillerJavaScriptService::HandleDistillerOpenSettingsCall,
+ base::Unretained(distiller_js_service_.get())));
}
template<typename Sig>
@@ -73,22 +87,12 @@ void DistillerNativeJavaScript::BindFunctionToObject(
}
void DistillerNativeJavaScript::EnsureServiceConnected() {
- if (!distiller_js_service_) {
+ if (!distiller_js_service_ || !distiller_js_service_.is_bound()) {
render_frame_->GetServiceRegistry()->ConnectToRemoteService(
mojo::GetProxy(&distiller_js_service_));
}
}
-void DistillerNativeJavaScript::DistillerSendFeedback(bool good) {
- EnsureServiceConnected();
- distiller_js_service_->HandleDistillerFeedbackCall(good);
-}
-
-void DistillerNativeJavaScript::DistillerClosePanel() {
- EnsureServiceConnected();
- distiller_js_service_->HandleDistillerClosePanelCall();
-}
-
std::string DistillerNativeJavaScript::DistillerEcho(
const std::string& message) {
EnsureServiceConnected();

Powered by Google App Engine
This is Rietveld 408576698