Index: chrome/browser/media/router/incognito_presentation_service_delegate.h |
diff --git a/chrome/browser/media/router/incognito_presentation_service_delegate.h b/chrome/browser/media/router/incognito_presentation_service_delegate.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..03c910b200b36878c5e4db153e24548cb17ea197 |
--- /dev/null |
+++ b/chrome/browser/media/router/incognito_presentation_service_delegate.h |
@@ -0,0 +1,132 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_MEDIA_ROUTER_INCOGNITO_PRESENTATION_SERVICE_DELEGATE_H_ |
+#define CHROME_BROWSER_MEDIA_ROUTER_INCOGNITO_PRESENTATION_SERVICE_DELEGATE_H_ |
+ |
+#include <map> |
+ |
+#include "base/observer_list.h" |
+#include "chrome/browser/media/router/render_frame_host_helper.h" |
+#include "content/public/browser/presentation_service_delegate.h" |
+#include "content/public/browser/web_contents_user_data.h" |
+ |
+namespace content { |
+class RenderFrameHost; |
+class PresentationScreenAvailabilityListener; |
+class WebContents; |
+struct PresentationSessionInfo; |
+struct PresentationSessionMessage; |
+} // namespace content |
+ |
+namespace media_router { |
+ |
+class MediaRoute; |
+class MediaSinksObserver; |
+class OneUAPresentationRouter; |
+class PresentationFrameManager; |
+class PresentationSessionStateObserver; |
+ |
+// TODO(imcheng): We may be able to merge this class with PSDImpl if we decide |
+// to re-enable presentation API in incognito mode with similar behavior in the |
+// future. |
+// PresentationServiceDelegate implementation for incognito tabs. |
+// Currently, most request-type APIs are disabled, with the exception of |
+// presenter APIs for 1-UA presentation, since we use an offscreen tab spawned |
+// from an off-the-record profile for 1-UA mode. Messaging and state change APIs |
+// are available for the 1-UA presenter session. |
+// It is scoped to the lifetime of a WebContents, and is managed by the |
+// associated WebContents. |
+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
|
+ : public content::WebContentsUserData<IncognitoPresentationServiceDelegate>, |
+ public content::PresentationServiceDelegate { |
+ public: |
+ // Retrieves the instance of IncognitoPresentationServiceDelegate that was |
+ // attached |
+ // to the specified WebContents. If no instance was attached, creates one, |
+ // and attaches it to the specified WebContents. |
+ static IncognitoPresentationServiceDelegate* GetOrCreateForWebContents( |
+ content::WebContents* web_contents); |
+ |
+ ~IncognitoPresentationServiceDelegate() override; |
+ |
+ // content::PresentationServiceDelegate implementation. |
+ void AddObserver( |
+ int render_process_id, |
+ int render_frame_id, |
+ content::PresentationServiceDelegate::Observer* observer) override; |
+ void RemoveObserver(int render_process_id, int render_frame_id) override; |
+ bool AddScreenAvailabilityListener( |
+ int render_process_id, |
+ int render_frame_id, |
+ content::PresentationScreenAvailabilityListener* listener) override; |
+ void RemoveScreenAvailabilityListener( |
+ int render_process_id, |
+ int render_frame_id, |
+ content::PresentationScreenAvailabilityListener* listener) override; |
+ void Reset(int render_process_id, int render_frame_id) override; |
+ void SetDefaultPresentationUrl( |
+ int render_process_id, |
+ int render_frame_id, |
+ const std::string& default_presentation_url) override; |
+ void StartSession(int render_process_id, |
+ int render_frame_id, |
+ const std::string& presentation_url, |
+ const PresentationSessionSuccessCallback& success_cb, |
+ const PresentationSessionErrorCallback& error_cb) override; |
+ void JoinSession(int render_process_id, |
+ int render_frame_id, |
+ const std::string& presentation_url, |
+ const std::string& presentation_id, |
+ const PresentationSessionSuccessCallback& success_cb, |
+ const PresentationSessionErrorCallback& error_cb) override; |
+ void CloseSession(int render_process_id, |
+ int render_frame_id, |
+ const std::string& presentation_id) override; |
+ void ListenForSessionMessages( |
+ int render_process_id, |
+ int render_frame_id, |
+ const content::PresentationSessionInfo& session, |
+ const content::PresentationSessionMessageCallback& message_cb) override; |
+ void SendMessage( |
+ int render_process_id, |
+ int render_frame_id, |
+ const content::PresentationSessionInfo& session, |
+ scoped_ptr<content::PresentationSessionMessage> message, |
+ const content::SendMessageCallback& send_message_cb) override; |
+ void ListenForSessionStateChange( |
+ int render_process_id, |
+ int render_frame_id, |
+ const content::SessionStateChangedCallback& state_changed_cb) override; |
+ void GetPresenterSession( |
+ int render_process_id, |
+ int render_frame_id, |
+ const content::PresenterSessionAvailableCallback& success_callback, |
+ const base::Callback<void(const std::string&)>& error_callback) override; |
+ std::vector<content::PresentationSessionInfo> GetPresenterSessions( |
+ int render_process_id, |
+ int render_frame_id) override; |
+ |
+ private: |
+ explicit IncognitoPresentationServiceDelegate( |
+ content::WebContents* web_contents); |
+ friend class content::WebContentsUserData< |
+ IncognitoPresentationServiceDelegate>; |
+ |
+ // Reference to the WebContents that owns this instance. |
+ 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
|
+ |
+ // Reference to OneUAPresentationRouter keyed off the original Profile of |
+ // the incognito Profile associated with |web_contents_|. |
+ OneUAPresentationRouter* const one_ua_presentation_router_; |
+ |
+ std::map<RenderFrameHostId, content::PresentationServiceDelegate::Observer*> |
+ observers_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(IncognitoPresentationServiceDelegate); |
+}; |
+ |
+} // namespace media_router |
+ |
+#endif // CHROME_BROWSER_MEDIA_ROUTER_INCOGNITO_PRESENTATION_SERVICE_DELEGATE_H_ |