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

Unified Diff: chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc

Issue 2343013002: [Presentation API] (MR side) 1-UA: notify receiver page when receiver connection becomes available (Closed)
Patch Set: resolve code review comments from Derek Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc
diff --git a/chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc b/chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..43b15ac33d9e2163f522802bcbaecfa08dfe2700
--- /dev/null
+++ b/chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc
@@ -0,0 +1,171 @@
+// 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.
+
+#include "chrome/browser/media/router/receiver_presentation_service_delegate_impl.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_process_host.h"
+
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(
+ media_router::ReceiverPresentationServiceDelegateImpl);
+
+using content::PresentationServiceDelegate;
+using content::RenderFrameHost;
+
+namespace media_router {
+
+// static
+void ReceiverPresentationServiceDelegateImpl::CreateForWebContents(
+ content::WebContents* web_contents,
+ const std::string& presentation_id) {
+ DCHECK(web_contents);
+
+ if (FromWebContents(web_contents))
+ return;
+
+ web_contents->SetUserData(UserDataKey(),
+ new ReceiverPresentationServiceDelegateImpl(
+ web_contents, presentation_id));
+}
+
+ReceiverPresentationServiceDelegateImpl::
+ ~ReceiverPresentationServiceDelegateImpl() {
+ for (auto& observer_pair : observers_)
+ observer_pair.second->OnDelegateDestroyed();
+}
+
+void ReceiverPresentationServiceDelegateImpl::AddObserver(
+ int render_process_id,
+ int render_frame_id,
+ content::PresentationServiceDelegate::Observer* observer) {
+ DCHECK(observer);
+
+ RenderFrameHostId rfh_id(render_process_id, render_frame_id);
+ DCHECK(!base::ContainsKey(observers_, rfh_id));
+ observers_[rfh_id] = observer;
+}
+
+void ReceiverPresentationServiceDelegateImpl::RemoveObserver(
+ int render_process_id,
+ int render_frame_id) {
+ observers_.erase(RenderFrameHostId(render_process_id, render_frame_id));
+}
+
+bool ReceiverPresentationServiceDelegateImpl::AddScreenAvailabilityListener(
+ int render_process_id,
+ int render_frame_id,
+ content::PresentationScreenAvailabilityListener* listener) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void ReceiverPresentationServiceDelegateImpl::RemoveScreenAvailabilityListener(
+ int render_process_id,
+ int render_frame_id,
+ content::PresentationScreenAvailabilityListener* listener) {
+ NOTIMPLEMENTED();
+}
+
+void ReceiverPresentationServiceDelegateImpl::Reset(int render_process_id,
+ int render_frame_id) {
+ DVLOG(2) << __FUNCTION__ << render_process_id << ", " << render_frame_id;
+ offscreen_presentation_manager_->UnregisterOffscreenPresentationReceiver(
+ presentation_id_);
+}
+
+void ReceiverPresentationServiceDelegateImpl::SetDefaultPresentationUrls(
+ int render_process_id,
+ int render_frame_id,
+ const std::vector<std::string>& default_presentation_urls,
+ const content::PresentationSessionStartedCallback& callback) {
+ NOTIMPLEMENTED();
+}
+
+void ReceiverPresentationServiceDelegateImpl::StartSession(
+ int render_process_id,
+ int render_frame_id,
+ const std::vector<std::string>& presentation_urls,
+ const content::PresentationSessionStartedCallback& success_cb,
+ const content::PresentationSessionErrorCallback& error_cb) {
+ NOTIMPLEMENTED();
+ error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN,
+ "Not implemented"));
+}
+
+void ReceiverPresentationServiceDelegateImpl::JoinSession(
+ int render_process_id,
+ int render_frame_id,
+ const std::vector<std::string>& presentation_urls,
+ const std::string& presentation_id,
+ const content::PresentationSessionStartedCallback& success_cb,
+ const content::PresentationSessionErrorCallback& error_cb) {
+ NOTIMPLEMENTED();
+ error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN,
+ "Not implemented"));
+}
+
+void ReceiverPresentationServiceDelegateImpl::CloseConnection(
+ int render_process_id,
+ int render_frame_id,
+ const std::string& presentation_id) {
+ NOTIMPLEMENTED();
+}
+
+void ReceiverPresentationServiceDelegateImpl::Terminate(
+ int render_process_id,
+ int render_frame_id,
+ const std::string& presentation_id) {
+ NOTIMPLEMENTED();
+}
+
+void ReceiverPresentationServiceDelegateImpl::ListenForSessionMessages(
+ int render_process_id,
+ int render_frame_id,
+ const content::PresentationSessionInfo& session_info,
+ const content::PresentationSessionMessageCallback& message_cb) {
+ NOTIMPLEMENTED();
+}
+
+void ReceiverPresentationServiceDelegateImpl::SendMessage(
+ int render_process_id,
+ int render_frame_id,
+ const content::PresentationSessionInfo& session_info,
+ std::unique_ptr<content::PresentationSessionMessage> message,
+ const SendMessageCallback& send_message_cb) {
+ NOTIMPLEMENTED();
+}
+
+void ReceiverPresentationServiceDelegateImpl::ListenForConnectionStateChange(
+ int render_process_id,
+ int render_frame_id,
+ const content::PresentationSessionInfo& connection,
+ const content::PresentationConnectionStateChangedCallback&
+ state_changed_cb) {
+ NOTIMPLEMENTED();
+}
+
+ReceiverPresentationServiceDelegateImpl::
+ ReceiverPresentationServiceDelegateImpl(content::WebContents* web_contents,
+ const std::string& presentation_id)
+ : web_contents_(web_contents),
+ presentation_id_(presentation_id),
+ offscreen_presentation_manager_(
+ OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext(
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext())
+ ->GetOriginalProfile())) {
+ DCHECK(web_contents_);
+ DCHECK(!presentation_id.empty());
+ DCHECK(offscreen_presentation_manager_);
+ DCHECK(web_contents_->GetBrowserContext()->IsOffTheRecord());
+}
+
+void ReceiverPresentationServiceDelegateImpl::RegisterReceiverAvailableCallback(
+ const content::ReceiverConnectionAvailableCallback&
+ receiver_available_callback) {
+ offscreen_presentation_manager_->RegisterOffscreenPresentationReceiver(
+ presentation_id_, receiver_available_callback);
+}
+
+} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698