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

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

Issue 1314413005: [Presentation API] 1-UA presentation support + presenter APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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.
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
10 #include "base/observer_list.h"
11 #include "chrome/browser/media/router/render_frame_host_helper.h"
12 #include "content/public/browser/presentation_service_delegate.h"
13 #include "content/public/browser/web_contents_user_data.h"
14
15 namespace content {
16 class RenderFrameHost;
17 class PresentationScreenAvailabilityListener;
18 class WebContents;
19 struct PresentationSessionInfo;
20 struct PresentationSessionMessage;
21 } // namespace content
22
23 namespace media_router {
24
25 class MediaRoute;
26 class MediaSinksObserver;
27 class OffscreenPresenterContext;
28 class PresentationFrameManager;
29 class PresentationSessionStateObserver;
30
31 // TODO(imcheng): We may be able to merge this class with PSDImpl if we decide
32 // to re-enable presentation API in incognito mode with similar behavior in the
33 // future.
34 // PresentationServiceDelegate implementation for incognito tabs.
35 // Currently, most request-type APIs are disabled, with the exception of
36 // presenter APIs for offscreen presentation, since we use an offscreen tab
37 // spawned
38 // from an off-the-record profile for 1-UA mode. Messaging and state change APIs
39 // are available for the offscreen presenter session.
40 // It is scoped to the lifetime of a WebContents, and is managed by the
41 // associated WebContents.
42 class ReceiverPresentationServiceDelegateImpl
miu 2015/09/27 00:22:09 naming: Personally, I disagree with the other revi
imcheng 2015/09/30 01:13:42 I don't feel strongly either way regarding Impl. I
43 : public content::WebContentsUserData<
44 ReceiverPresentationServiceDelegateImpl>,
45 public content::PresentationServiceDelegate {
46 public:
47 // Retrieves the instance of ReceiverPresentationServiceDelegateImpl that was
48 // attached
49 // to the specified WebContents. If no instance was attached, creates one,
50 // and attaches it to the specified WebContents.
51 static ReceiverPresentationServiceDelegateImpl* GetOrCreateForWebContents(
52 content::WebContents* web_contents);
53
54 ~ReceiverPresentationServiceDelegateImpl() override;
55
56 // content::PresentationServiceDelegate implementation.
57 void AddObserver(
58 int render_process_id,
59 int render_frame_id,
60 content::PresentationServiceDelegate::Observer* observer) override;
61 void RemoveObserver(int render_process_id, int render_frame_id) override;
62 bool AddScreenAvailabilityListener(
63 int render_process_id,
64 int render_frame_id,
65 content::PresentationScreenAvailabilityListener* listener) override;
66 void RemoveScreenAvailabilityListener(
67 int render_process_id,
68 int render_frame_id,
69 content::PresentationScreenAvailabilityListener* listener) override;
70 void Reset(int render_process_id, int render_frame_id) override;
71 void SetDefaultPresentationUrl(
72 int render_process_id,
73 int render_frame_id,
74 const std::string& default_presentation_url) override;
75 void StartSession(int render_process_id,
76 int render_frame_id,
77 const std::string& presentation_url,
78 const PresentationSessionSuccessCallback& success_cb,
79 const PresentationSessionErrorCallback& error_cb) override;
80 void JoinSession(int render_process_id,
81 int render_frame_id,
82 const std::string& presentation_url,
83 const std::string& presentation_id,
84 const PresentationSessionSuccessCallback& success_cb,
85 const PresentationSessionErrorCallback& error_cb) override;
86 void CloseSession(int render_process_id,
87 int render_frame_id,
88 const std::string& presentation_id) override;
89 void ListenForSessionMessages(
90 int render_process_id,
91 int render_frame_id,
92 const content::PresentationSessionInfo& session,
93 const content::PresentationSessionMessageCallback& message_cb) override;
94 void SendMessage(
95 int render_process_id,
96 int render_frame_id,
97 const content::PresentationSessionInfo& session,
98 scoped_ptr<content::PresentationSessionMessage> message,
99 const content::SendMessageCallback& send_message_cb) override;
100 bool ListenForSessionStateChange(
101 int render_process_id,
102 int render_frame_id,
103 content::PresentationSessionStateListener* listener) override;
104 void GetPresentationReceiverSession(
105 int render_process_id,
106 int render_frame_id,
107 const content::PresentationReceiverSessionAvailableCallback&
108 success_callback,
109 const base::Callback<void(const std::string&)>& error_callback) override;
110 std::vector<content::PresentationSessionInfo> GetPresentationReceiverSessions(
111 int render_process_id,
112 int render_frame_id) override;
113
114 private:
115 explicit ReceiverPresentationServiceDelegateImpl(
116 content::WebContents* web_contents);
117 friend class content::WebContentsUserData<
118 ReceiverPresentationServiceDelegateImpl>;
119
120 // Reference to the WebContents that owns this instance.
121 content::WebContents* const web_contents_;
122
123 // Initalized on construction. Destroyed when |Reset()| is called on the
124 // main frame of |web_contents_| (i.e., navigation or other events that would
125 // invalidate the context).
126 scoped_ptr<OffscreenPresenterContext> offscreen_presenter_context_;
127
128 std::map<RenderFrameHostId, content::PresentationServiceDelegate::Observer*>
129 observers_;
130
131 DISALLOW_COPY_AND_ASSIGN(ReceiverPresentationServiceDelegateImpl);
132 };
133
134 } // namespace media_router
135
136 #endif // CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IM PL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698