OLD | NEW |
---|---|
(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_INCOGNITO_PRESENTATION_SERVICE_DELEGATE_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_INCOGNITO_PRESENTATION_SERVICE_DELEGATE_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 OneUAPresentationRouter; | |
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 1-UA presentation, since we use an offscreen tab spawned | |
37 // from an off-the-record profile for 1-UA mode. Messaging and state change APIs | |
38 // are available for the 1-UA presenter session. | |
39 // It is scoped to the lifetime of a WebContents, and is managed by the | |
40 // associated WebContents. | |
41 class IncognitoPresentationServiceDelegate | |
whywhat
2015/09/14 15:20:39
Maybe this shoud be something like ReceiverPresent
miu
2015/09/17 00:09:20
FYI--Ben Kalman in recent meeting proposed we used
imcheng
2015/09/26 01:21:57
Will go with ReceiverPresentationServiceDelegateIm
imcheng
2015/09/26 01:21:57
Ok, I will go with ReceiverPresentationServiceDele
| |
42 : public content::WebContentsUserData<IncognitoPresentationServiceDelegate>, | |
43 public content::PresentationServiceDelegate { | |
44 public: | |
45 // Retrieves the instance of IncognitoPresentationServiceDelegate that was | |
46 // attached | |
47 // to the specified WebContents. If no instance was attached, creates one, | |
48 // and attaches it to the specified WebContents. | |
49 static IncognitoPresentationServiceDelegate* GetOrCreateForWebContents( | |
50 content::WebContents* web_contents); | |
51 | |
52 ~IncognitoPresentationServiceDelegate() override; | |
53 | |
54 // content::PresentationServiceDelegate implementation. | |
55 void AddObserver( | |
56 int render_process_id, | |
57 int render_frame_id, | |
58 content::PresentationServiceDelegate::Observer* observer) override; | |
59 void RemoveObserver(int render_process_id, int render_frame_id) override; | |
60 bool AddScreenAvailabilityListener( | |
61 int render_process_id, | |
62 int render_frame_id, | |
63 content::PresentationScreenAvailabilityListener* listener) override; | |
64 void RemoveScreenAvailabilityListener( | |
65 int render_process_id, | |
66 int render_frame_id, | |
67 content::PresentationScreenAvailabilityListener* listener) override; | |
68 void Reset(int render_process_id, int render_frame_id) override; | |
69 void SetDefaultPresentationUrl( | |
70 int render_process_id, | |
71 int render_frame_id, | |
72 const std::string& default_presentation_url) override; | |
73 void StartSession(int render_process_id, | |
74 int render_frame_id, | |
75 const std::string& presentation_url, | |
76 const PresentationSessionSuccessCallback& success_cb, | |
77 const PresentationSessionErrorCallback& error_cb) override; | |
78 void JoinSession(int render_process_id, | |
79 int render_frame_id, | |
80 const std::string& presentation_url, | |
81 const std::string& presentation_id, | |
82 const PresentationSessionSuccessCallback& success_cb, | |
83 const PresentationSessionErrorCallback& error_cb) override; | |
84 void CloseSession(int render_process_id, | |
85 int render_frame_id, | |
86 const std::string& presentation_id) override; | |
87 void ListenForSessionMessages( | |
88 int render_process_id, | |
89 int render_frame_id, | |
90 const content::PresentationSessionInfo& session, | |
91 const content::PresentationSessionMessageCallback& message_cb) override; | |
92 void SendMessage( | |
93 int render_process_id, | |
94 int render_frame_id, | |
95 const content::PresentationSessionInfo& session, | |
96 scoped_ptr<content::PresentationSessionMessage> message, | |
97 const content::SendMessageCallback& send_message_cb) override; | |
98 void ListenForSessionStateChange( | |
99 int render_process_id, | |
100 int render_frame_id, | |
101 const content::SessionStateChangedCallback& state_changed_cb) override; | |
102 void GetPresenterSession( | |
103 int render_process_id, | |
104 int render_frame_id, | |
105 const content::PresenterSessionAvailableCallback& success_callback, | |
106 const base::Callback<void(const std::string&)>& error_callback) override; | |
107 std::vector<content::PresentationSessionInfo> GetPresenterSessions( | |
108 int render_process_id, | |
109 int render_frame_id) override; | |
110 | |
111 private: | |
112 explicit IncognitoPresentationServiceDelegate( | |
113 content::WebContents* web_contents); | |
114 friend class content::WebContentsUserData< | |
115 IncognitoPresentationServiceDelegate>; | |
116 | |
117 // Reference to the WebContents that owns this instance. | |
118 content::WebContents* const web_contents_; | |
whywhat
2015/09/14 15:20:39
Do you think there might be a BasePresentationServ
imcheng
2015/09/26 01:21:57
It looks like the only common logic is web_content
| |
119 | |
120 // Reference to OneUAPresentationRouter keyed off the original Profile of | |
121 // the incognito Profile associated with |web_contents_|. | |
122 OneUAPresentationRouter* const one_ua_presentation_router_; | |
123 | |
124 std::map<RenderFrameHostId, content::PresentationServiceDelegate::Observer*> | |
125 observers_; | |
126 | |
127 DISALLOW_COPY_AND_ASSIGN(IncognitoPresentationServiceDelegate); | |
128 }; | |
129 | |
130 } // namespace media_router | |
131 | |
132 #endif // CHROME_BROWSER_MEDIA_ROUTER_INCOGNITO_PRESENTATION_SERVICE_DELEGATE_H _ | |
OLD | NEW |