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 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_RENDERER_DISTILLER_NATIVE_JAVASCRIPT_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_RENDERER_DISTILLER_NATIVE_JAVASCRIPT_H_ |
6 #define COMPONENTS_DOM_DISTILLER_CONTENT_RENDERER_DISTILLER_NATIVE_JAVASCRIPT_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_RENDERER_DISTILLER_NATIVE_JAVASCRIPT_H_ |
7 | 7 |
8 #include "components/dom_distiller/content/common/distiller_javascript_service.m ojom.h" | 8 #include "components/dom_distiller/content/common/distiller_javascript_service.m ojom.h" |
9 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.h" |
10 #include "content/public/renderer/render_frame_observer.h" | 10 #include "content/public/renderer/render_frame_observer.h" |
11 #include "v8/include/v8.h" | 11 #include "v8/include/v8.h" |
12 | 12 |
13 namespace dom_distiller { | 13 namespace dom_distiller { |
14 | 14 |
15 // This class is the primary interface for custom JavaScript introduced by the | 15 // This class is the primary interface for custom JavaScript introduced by the |
16 // dom-distiller. Callbacks for JavaScript functionality and the communication | 16 // dom-distiller. Callbacks for JavaScript functionality and the communication |
17 // channel to the browser process are maintained here. | 17 // channel to the browser process are maintained here. |
18 class DistillerNativeJavaScript { | 18 class DistillerNativeJavaScript { |
19 public: | 19 public: |
20 explicit DistillerNativeJavaScript(content::RenderFrame* render_frame); | 20 explicit DistillerNativeJavaScript(content::RenderFrame* render_frame); |
21 ~DistillerNativeJavaScript(); | 21 ~DistillerNativeJavaScript(); |
22 | 22 |
23 // Add the "distiller" JavaScript object and its functions to the current | 23 // Add the "distiller" JavaScript object and its functions to the current |
24 // |RenderFrame|. | 24 // |RenderFrame|. |
25 void AddJavaScriptObjectToFrame(v8::Local<v8::Context> context); | 25 void AddJavaScriptObjectToFrame(v8::Local<v8::Context> context); |
26 | 26 |
27 private: | 27 private: |
28 // Make sure the mojo service is connected. | |
29 void ensureServiceConnected(); | |
nyquist
2015/09/10 19:04:13
EnsureServiceConnected
mdjones
2015/09/11 16:50:13
Done.
| |
30 | |
28 // Native code for "distiller.echo" in JavaScript. This simply returns the | 31 // Native code for "distiller.echo" in JavaScript. This simply returns the |
29 // provided string. | 32 // provided string. |
30 std::string DistillerEcho(const std::string& message); | 33 std::string DistillerEcho(const std::string& message); |
31 | 34 |
35 // Send feedback about distillation quality. | |
36 void DistillerSendFeedback(bool good); | |
37 | |
32 content::RenderFrame* render_frame_; | 38 content::RenderFrame* render_frame_; |
33 DistillerJavaScriptServicePtr distiller_js_service_; | 39 DistillerJavaScriptServicePtr distiller_js_service_; |
34 }; | 40 }; |
35 | 41 |
36 // static | 42 // static |
37 v8::Local<v8::Object> GetOrCreateDistillerObject(v8::Isolate* isolate, | 43 v8::Local<v8::Object> GetOrCreateDistillerObject(v8::Isolate* isolate, |
38 v8::Local<v8::Object> global); | 44 v8::Local<v8::Object> global); |
39 | 45 |
40 } // namespace dom_distiller | 46 } // namespace dom_distiller |
41 | 47 |
42 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_RENDERER_DISTILLER_NATIVE_JAVASCRIPT _H_ | 48 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_RENDERER_DISTILLER_NATIVE_JAVASCRIPT _H_ |
OLD | NEW |