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

Unified Diff: headless/public/headless_tab_socket.h

Issue 2813953002: Add HeadlessTabSocket (Closed)
Patch Set: Change HeadlessTabSocketImpl::SetListener Created 3 years, 8 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
« no previous file with comments | « headless/public/headless_browser_context.h ('k') | headless/public/headless_web_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/headless_tab_socket.h
diff --git a/headless/public/headless_tab_socket.h b/headless/public/headless_tab_socket.h
new file mode 100644
index 0000000000000000000000000000000000000000..b8f0fa22288da1dfa07f348957ca8347e0807cf5
--- /dev/null
+++ b/headless/public/headless_tab_socket.h
@@ -0,0 +1,45 @@
+// Copyright 2017 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 HEADLESS_PUBLIC_HEADLESS_TAB_SOCKET_H_
+#define HEADLESS_PUBLIC_HEADLESS_TAB_SOCKET_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "headless/public/headless_export.h"
+
+namespace headless {
+
+// A bidirectional communications channel between C++ and JS.
+class HEADLESS_EXPORT HeadlessTabSocket {
+ public:
+ class HEADLESS_EXPORT Listener {
+ public:
+ Listener() {}
+ virtual ~Listener() {}
+
+ // The |message| may be potentially sent by untrusted web content so it
+ // should be validated carefully.
+ virtual void OnMessageFromTab(const std::string& message) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Listener);
+ };
+
+ virtual void SendMessageToTab(const std::string& message) = 0;
+
+ virtual void SetListener(Listener* listener) = 0;
+
+ protected:
+ HeadlessTabSocket() {}
+ virtual ~HeadlessTabSocket() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(HeadlessTabSocket);
+};
+
+} // namespace headless
+
+#endif // HEADLESS_PUBLIC_HEADLESS_TAB_SOCKET_H_
« no previous file with comments | « headless/public/headless_browser_context.h ('k') | headless/public/headless_web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698