Chromium Code Reviews| OLD | NEW |
|---|---|
| (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. | |
|
mark a. foltz
2016/11/08 23:40:52
nit: Presentation
zhaobin
2016/11/10 04:14:00
Done.
| |
| 32 // Created under the offscreen tab WebContents when the tab is created for an | |
|
mark a. foltz
2016/11/08 23:40:52
There's currently no "tab" or visual indicator in
zhaobin
2016/11/10 04:14:00
Done.
| |
| 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 | |
|
mark a. foltz
2016/11/08 23:40:52
offscreen WebContents
zhaobin
2016/11/10 04:14:00
Done.
| |
| 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|. | |
|
mark a. foltz
2016/11/08 23:40:51
Document that this does not take ownership of |web
zhaobin
2016/11/10 04:14:00
Done.
| |
| 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_; | |
|
mark a. foltz
2016/11/08 23:40:52
There is a risk you will call into |web_contents_|
zhaobin
2016/11/10 04:14:00
Did some manual tests, ~ReceiverPSDImpl() always h
| |
| 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_ | |
| OLD | NEW |