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

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: 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 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
16 #include "chrome/browser/media/router/offscreen_presentation_manager.h"
17 #include "chrome/browser/media/router/offscreen_presentation_manager_factory.h"
18 #include "chrome/browser/media/router/render_frame_host_id.h"
19 #include "content/public/browser/presentation_service_delegate.h"
20 #include "content/public/browser/web_contents_user_data.h"
21
22 namespace content {
23 class RenderFrameHost;
24 class WebContents;
25 struct PresentationSessionInfo;
26 struct PresentationSessionMessage;
27 } // namespace content
28
29 namespace media_router {
30
31 // Implements the receiver side of presentation API for offscreen presentations.
32 // Created under the offscreen tab WebContents when the tab is created for an
33 // offscreen presentation. Each instance is tied to a single offscreen
34 // presentation whose ID is given during construction. As such, the receiver
35 // APIs are contextual with the offscreen presentation.
36 // Only the main frame of the offscreen tab is allowed to make receiver
37 // Presentation API requests; requests made from any other frame will be
38 // rejected.
39 class ReceiverPresentationServiceDelegateImpl
40 : public content::WebContentsUserData<
41 ReceiverPresentationServiceDelegateImpl>,
42 public content::ReceiverPresentationServiceDelegate {
43 public:
44 // Creates an instance of ReceiverPresentationServiceDelegateImpl under
45 // |web_contents| and registers it as the receiver of the offscreen
46 // presentation |presentation_id| with OffscreenPresentationManager.
47 // No-op if a ReceiverPresentationServiceDelegateImpl instance already
48 // exists under |web_contents|.
49 static void CreateForWebContents(content::WebContents* web_contents,
50 const std::string& presentation_id);
51
52 ~ReceiverPresentationServiceDelegateImpl() override;
53
54 // content::PresentationServiceDelegateBase implementation.
55 void AddObserver(
56 int render_process_id,
57 int render_frame_id,
58 content::PresentationServiceDelegateBase::Observer* observer) override;
59 void RemoveObserver(int render_process_id, int render_frame_id) override;
60 void Reset(int render_process_id, int render_frame_id) override;
61
62 // content::ReceiverPresentationServiceDelegate implementation.
63 void RegisterReceiverConnectionAvailableCallback(
64 const content::ReceiverConnectionAvailableCallback&
65 receiver_available_callback) override;
66
67 private:
68 friend class content::WebContentsUserData<
69 ReceiverPresentationServiceDelegateImpl>;
70
71 ReceiverPresentationServiceDelegateImpl(content::WebContents* web_contents,
72 const std::string& presentation_id);
73
74 // Reference to the WebContents that owns this instance.
75 content::WebContents* const web_contents_;
76
77 const std::string presentation_id_;
78 OffscreenPresentationManager* const offscreen_presentation_manager_;
79 std::map<RenderFrameHostId,
80 content::PresentationServiceDelegateBase::Observer*>
81 observers_;
82
83 DISALLOW_COPY_AND_ASSIGN(ReceiverPresentationServiceDelegateImpl);
84 };
85
86 } // namespace media_router
87
88 #endif // CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IM PL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698