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

Side by Side Diff: content/renderer/presentation/presentation_connection_proxy.h

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: merge with master Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
7
8 #include "base/callback.h"
9 #include "mojo/public/cpp/bindings/binding.h"
10 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nConnection.h"
11 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nConnectionProxy.h"
12 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h"
13
14 namespace content {
15
16 // This class connects PresentationConnection owned by one frame with
17 // PresentationConnection owned by a different frame.
18 //
19 // |SetSourceConnection| sets |source_connection_| to PresentationConnection
20 // object owned by current frame.
21 // |SetTargetConnection| sets |target_connection_| to mojo handle of
22 // PresentationConnection object owned by a different frame.
23 //
24 // When both |source_connection_| and |target_connection_| are set,
25 // we can send message or notify state changes between controller and receiver.
26 //
27 // To send message from controlling frame to receiver frame:
28 // 1. Controlling frame invokes connection.sendMessage();
29 // 2. This call is delegated to controller presentation connection proxy's
30 // SendString().
31 // PresentationConnectionProxy::SendString() {
32 // target_connection_->OnConnectionMessageReceived();
33 // }
34 // 3. Receiver PresentationConnectionProxy::OnConnectionMessageReceived() is
35 // invoked.
36 // 4. connection.onmessage event on receiver frame is fired.
37 //
38 // Sending message from receiver frame to controlling frame and notifying state
39 // changes works the same.
40 //
41 // Instance of this class is only created for offscreen presentations.
42 class PresentationConnectionProxy
43 : public blink::WebPresentationConnectionProxy,
44 public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) {
45 public:
46 PresentationConnectionProxy();
47 ~PresentationConnectionProxy() override;
48
49 blink::mojom::PresentationConnectionPtr Bind();
50
51 // WebPresentationConnectionProxy Implementation
52 void SetSourceConnection(
53 blink::WebPresentationConnection* connection) override;
54 void SendString(const blink::WebString& message) override;
55 void SendArrayBuffer(const uint8_t* data, size_t length) override;
56
57 // blink::mojom::PresentationConnection implementation
58 void SetTargetConnection(
59 blink::mojom::PresentationConnectionPtr connection) override;
60 void OnMessage(blink::mojom::SessionMessagePtr message) override;
61
62 private:
63 mojo::Binding<blink::mojom::PresentationConnection> binding_;
64 blink::mojom::PresentationConnectionPtr target_connection_;
65 blink::WebPresentationConnection* source_connection_;
66 };
67
68 } // namespace content
69
70 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698