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/renderer/distiller_native_javascript.
h" | 5 #include "components/dom_distiller/content/renderer/distiller_native_javascript.
h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 v8::Local<v8::Object> distiller_obj = | 39 v8::Local<v8::Object> distiller_obj = |
40 GetOrCreateDistillerObject(isolate, context->Global()); | 40 GetOrCreateDistillerObject(isolate, context->Global()); |
41 | 41 |
42 EnsureServiceConnected(); | 42 EnsureServiceConnected(); |
43 | 43 |
44 // Many functions can simply call the Mojo interface directly and have no | 44 // Many functions can simply call the Mojo interface directly and have no |
45 // wrapper function for binding. Note that calling distiller_js_service.get() | 45 // wrapper function for binding. Note that calling distiller_js_service.get() |
46 // does not transfer ownership of the interface. | 46 // does not transfer ownership of the interface. |
47 BindFunctionToObject( | 47 BindFunctionToObject( |
48 distiller_obj, "closePanel", | |
49 base::Bind( | |
50 &mojom::DistillerJavaScriptService::HandleDistillerClosePanelCall, | |
51 base::Unretained(distiller_js_service_.get()))); | |
52 | |
53 BindFunctionToObject( | |
54 distiller_obj, "openSettings", | 48 distiller_obj, "openSettings", |
55 base::Bind( | 49 base::Bind( |
56 &mojom::DistillerJavaScriptService::HandleDistillerOpenSettingsCall, | 50 &mojom::DistillerJavaScriptService::HandleDistillerOpenSettingsCall, |
57 base::Unretained(distiller_js_service_.get()))); | 51 base::Unretained(distiller_js_service_.get()))); |
58 } | 52 } |
59 | 53 |
60 template<typename Sig> | 54 template<typename Sig> |
61 void DistillerNativeJavaScript::BindFunctionToObject( | 55 void DistillerNativeJavaScript::BindFunctionToObject( |
62 v8::Local<v8::Object> javascript_object, | 56 v8::Local<v8::Object> javascript_object, |
63 const std::string& name, | 57 const std::string& name, |
(...skipping 20 matching lines...) Expand all Loading... |
84 if (distiller_value.IsEmpty() || !distiller_value->IsObject()) { | 78 if (distiller_value.IsEmpty() || !distiller_value->IsObject()) { |
85 distiller_obj = v8::Object::New(isolate); | 79 distiller_obj = v8::Object::New(isolate); |
86 global->Set(gin::StringToSymbol(isolate, "distiller"), distiller_obj); | 80 global->Set(gin::StringToSymbol(isolate, "distiller"), distiller_obj); |
87 } else { | 81 } else { |
88 distiller_obj = v8::Local<v8::Object>::Cast(distiller_value); | 82 distiller_obj = v8::Local<v8::Object>::Cast(distiller_value); |
89 } | 83 } |
90 return distiller_obj; | 84 return distiller_obj; |
91 } | 85 } |
92 | 86 |
93 } // namespace dom_distiller | 87 } // namespace dom_distiller |
OLD | NEW |