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

Side by Side Diff: chrome/browser/media/router/receiver_presentation_service_delegate_impl.h

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: resolve code review comments from Mark Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
mark a. foltz 2016/10/08 00:33:42 Update copyright
zhaobin 2016/10/12 02:27:33 Done.
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 CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_ H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_ H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11 #include <utility>
12 #include <vector>
13
14 #include "base/observer_list.h"
15 #include "chrome/browser/media/router/offscreen_presentation_manager.h"
16 #include "chrome/browser/media/router/offscreen_presentation_manager_factory.h"
17 #include "chrome/browser/media/router/render_frame_host_id.h"
18 #include "content/public/browser/presentation_service_delegate.h"
19 #include "content/public/browser/web_contents_user_data.h"
20
21 namespace content {
22 class RenderFrameHost;
23 class WebContents;
24 struct PresentationSessionInfo;
25 struct PresentationSessionMessage;
26 } // namespace content
27
28 namespace media_router {
29
30 // Implements the receiver side of presentation API for offscreen presentations.
31 // Created under the offscreen tab WebContents when the tab is created for an
32 // offscreen presentation. Each instance is tied to a single offscreen
33 // presentation whose ID is given during construction. As such, the receiver
34 // APIs are contextual with the offscreen presentation.
35 // Only the main frame of the offscreen tab is allowed to make receiver
36 // Presentation API requests; requests made from any other frame will be
37 // rejected.
mark a. foltz 2016/10/08 00:33:42 Nice :)
zhaobin 2016/10/12 02:27:33 Derek writes this :)
38 class ReceiverPresentationServiceDelegateImpl
39 : public content::WebContentsUserData<
40 ReceiverPresentationServiceDelegateImpl>,
41 public content::PresentationServiceDelegate {
42 public:
43 // Creates an instance of ReceiverPresentationServiceDelegateImpl under
44 // |web_contents| and registers it as the receiver of the offscreen
45 // presentation |presentation_id| with OffscreenPresentationManager.
46 // No-op if a ReceiverPresentationServiceDelegateImpl instance already
47 // exists under |web_contents|.
48 static void CreateForWebContents(content::WebContents* web_contents,
49 const std::string& presentation_id);
50
51 ~ReceiverPresentationServiceDelegateImpl() override;
52
53 // content::PresentationServiceDelegate implementation.
54 void AddObserver(
55 int render_process_id,
56 int render_frame_id,
57 content::PresentationServiceDelegate::Observer* observer) override;
58 void RemoveObserver(int render_process_id, int render_frame_id) override;
59 bool AddScreenAvailabilityListener(
mark a. foltz 2016/10/08 00:33:42 None of these (through JoinSession) are really req
zhaobin 2016/10/12 02:27:33 Will not split presentation service for now. May d
60 int render_process_id,
61 int render_frame_id,
62 content::PresentationScreenAvailabilityListener* listener) override;
63 void RemoveScreenAvailabilityListener(
64 int render_process_id,
65 int render_frame_id,
66 content::PresentationScreenAvailabilityListener* listener) override;
67 void Reset(int render_process_id, int render_frame_id) override;
68 void SetDefaultPresentationUrls(
69 int render_process_id,
70 int render_frame_id,
71 const std::vector<std::string>& default_presentation_urls,
72 const content::PresentationSessionStartedCallback& callback) override;
73 void StartSession(
74 int render_process_id,
75 int render_frame_id,
76 const std::vector<std::string>& presentation_urls,
77 const content::PresentationSessionStartedCallback& success_cb,
78 const content::PresentationSessionErrorCallback& error_cb) override;
79 void JoinSession(
80 int render_process_id,
81 int render_frame_id,
82 const std::vector<std::string>& presentation_urls,
83 const std::string& presentation_id,
84 const content::PresentationSessionStartedCallback& success_cb,
85 const content::PresentationSessionErrorCallback& error_cb) override;
86 void CloseConnection(int render_process_id,
87 int render_frame_id,
88 const std::string& presentation_id) override;
89 void Terminate(int render_process_id,
90 int render_frame_id,
91 const std::string& presentation_id) override;
92 void ListenForSessionMessages(
93 int render_process_id,
94 int render_frame_id,
95 const content::PresentationSessionInfo& session_info,
96 const content::PresentationSessionMessageCallback& message_cb) override;
97 void SendMessage(int render_process_id,
98 int render_frame_id,
99 const content::PresentationSessionInfo& session_info,
100 std::unique_ptr<content::PresentationSessionMessage> message,
101 const SendMessageCallback& send_message_cb) override;
102 void ListenForConnectionStateChange(
103 int render_process_id,
104 int render_frame_id,
105 const content::PresentationSessionInfo& connection,
106 const content::PresentationConnectionStateChangedCallback&
107 state_changed_cb) override;
108 void RegisterReceiverAvailableCallback(
109 const content::ReceiverConnectionAvailableCallback&
110 receiver_available_callback) override;
111 void RegisterOffscreenPresentationConnection(
112 int render_process_id,
113 int render_frame_id,
114 const content::PresentationSessionInfo& session,
115 content::PresentationConnectionPtr connection) override;
116
117 private:
118 friend class content::WebContentsUserData<
119 ReceiverPresentationServiceDelegateImpl>;
120
121 explicit ReceiverPresentationServiceDelegateImpl(
122 content::WebContents* web_contents,
123 const std::string& presentation_id);
124
125 // Reference to the WebContents that owns this instance.
126 content::WebContents* const web_contents_;
127
128 const std::string presentation_id_;
129 OffscreenPresentationManager* const offscreen_presentation_manager_;
130 std::map<RenderFrameHostId, content::PresentationServiceDelegate::Observer*>
131 observers_;
132
133 DISALLOW_COPY_AND_ASSIGN(ReceiverPresentationServiceDelegateImpl);
134 };
135
136 } // namespace media_router
137
138 #endif // CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IM PL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698