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

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

Issue 1231083007: Expose distiller functions to JavaScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-content
Patch Set: Move dependencies to correct files 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.h
diff --git a/components/dom_distiller/content/renderer/distiller_native_javascript.h b/components/dom_distiller/content/renderer/distiller_native_javascript.h
new file mode 100644
index 0000000000000000000000000000000000000000..180ef9fcb08e26ed93db4792e169d890ea0a758c
--- /dev/null
+++ b/components/dom_distiller/content/renderer/distiller_native_javascript.h
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_DOM_DISTILLER_CONTENT_RENDERER_DISTILLER_NATIVE_JAVASCRIPT_H_
+#define COMPONENTS_DOM_DISTILLER_CONTENT_RENDERER_DISTILLER_NATIVE_JAVASCRIPT_H_
+
+#include "components/dom_distiller/content/common/distiller_javascript_service.mojom.h"
+#include "content/public/renderer/render_frame.h"
+#include "content/public/renderer/render_frame_observer.h"
+#include "v8/include/v8.h"
+
+namespace dom_distiller {
+
+// This class is the primary interface for custom JavaScript introduced by the
+// dom-distiller. Callbacks for JavaScript functionality and the communication
+// channel to the browser process are maintained here.
+class DistillerNativeJavaScript {
+ public:
+ explicit DistillerNativeJavaScript(content::RenderFrame* render_frame);
+ ~DistillerNativeJavaScript();
+
+ // Add the "distiller" JavaScript object and its functions to the current
+ // |RenderFrame|.
+ void AddJavaScriptObjectToFrame(v8::Local<v8::Context> context);
+
+ private:
+ // Native code for "distiller.echo" in JavaScript. This simply returns the
+ // provided string.
+ std::string DistillerEcho(const std::string& message);
+
+ content::RenderFrame* render_frame_;
+ DistillerJavaScriptServicePtr distiller_js_service_;
+};
+
+// static
+v8::Local<v8::Object> GetOrCreateDistillerObject(v8::Isolate* isolate,
+ v8::Local<v8::Object> global);
+
+} // namespace dom_distiller
+
+#endif // COMPONENTS_DOM_DISTILLER_CONTENT_RENDERER_DISTILLER_NATIVE_JAVASCRIPT_H_

Powered by Google App Engine
This is Rietveld 408576698