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

Unified Diff: chrome/browser/extensions/api/tab_capture/offscreen_presentation.cc

Issue 1314413005: [Presentation API] 1-UA presentation support + presenter APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/extensions/api/tab_capture/offscreen_presentation.cc
diff --git a/chrome/browser/extensions/api/tab_capture/offscreen_presentation.cc b/chrome/browser/extensions/api/tab_capture/offscreen_presentation.cc
index 2ccd614b8035321582aac9c7c12777da22d06bdf..dd4c6f6fb8f5d192db4b8df80297e49b7f895fc1 100644
--- a/chrome/browser/extensions/api/tab_capture/offscreen_presentation.cc
+++ b/chrome/browser/extensions/api/tab_capture/offscreen_presentation.cc
@@ -8,8 +8,12 @@
#include "base/bind.h"
#include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h"
+#include "chrome/browser/media/router/one_ua_presentation_router.h"
+#include "chrome/browser/media/router/one_ua_presentation_router_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/web_contents_sizer.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_host.h"
@@ -183,12 +187,17 @@ OffscreenPresentation::OffscreenPresentation(OffscreenPresentationsOwner* owner,
: owner_(owner),
start_url_(start_url),
presentation_id_(id),
- profile_(Profile::FromBrowserContext(
- owner->extension_web_contents()->GetBrowserContext())
- ->CreateOffTheRecordProfile()),
+ profile_(Profile::FromBrowserContext(owner->extension_web_contents()
+ ->GetBrowserContext())
+ ->CreateOffTheRecordProfile()),
+ one_ua_presentation_router_(
miu 2015/09/17 00:09:20 IMO, you should not store a pointer to the router
imcheng 2015/09/26 01:21:56 Done.
+ media_router::OneUAPresentationRouterFactory::
+ GetOrCreateForBrowserContext(owner_->extension_web_contents()
+ ->GetBrowserContext())),
capture_poll_timer_(false, false),
content_capture_was_detected_(false) {
DCHECK(profile_);
+ DCHECK(one_ua_presentation_router_);
}
OffscreenPresentation::~OffscreenPresentation() {
@@ -225,6 +234,19 @@ void OffscreenPresentation::Start(const gfx::Size& initial_size) {
load_params.should_clear_history_list = true;
presentation_web_contents_->GetController().LoadURLWithParams(load_params);
+ // If the offscreen tab is for a 1-UA presentation, register the tab's main
+ // frame as a presenter frame in OneUAPresentationRouter.
+ // Use the OneUAPresentationRouter keyed off the owner's BrowserContext.
+ // We assume that the presentation's potential controllers will be using the
+ // same OneUAPresentationRouter instance to connect with the presenter.
+ content::RenderFrameHost* render_frame_host =
+ presentation_web_contents_->GetMainFrame();
+ DCHECK(render_frame_host);
+ std::pair<int, int> rfh_id(render_frame_host->GetProcess()->GetID(),
+ render_frame_host->GetRoutingID());
+
+ one_ua_presentation_router_->RegisterPresenter(presentation_id(), rfh_id);
mark a. foltz 2015/09/11 23:24:20 Can RegisterPresenter() just take the (id, WebCont
miu 2015/09/17 00:09:20 +1 to mfoltz's comment. Also, is registering the
imcheng 2015/09/26 01:21:56 Ok, looks like main frame should be initialized wh
imcheng 2015/09/26 01:21:56 Done.
miu 2015/09/27 00:22:08 Probably not, but there are multiple processes and
imcheng 2015/09/30 01:13:41 Acknowledged. Now I call ReceiverPresentationServi
+
start_time_ = base::TimeTicks::Now();
DieIfContentCaptureEnded();
}
@@ -234,7 +256,7 @@ void OffscreenPresentation::CloseContents(WebContents* source) {
// Javascript in the page called window.close().
DVLOG(1) << "OffscreenPresentation will die at renderer's request for "
"start_url=" << start_url_.spec();
- owner_->ClosePresentation(this);
+ Close();
}
bool OffscreenPresentation::ShouldSuppressDialogs(WebContents* source) {
@@ -444,7 +466,7 @@ void OffscreenPresentation::DieIfContentCaptureEnded() {
if (presentation_web_contents_->GetCapturerCount() == 0) {
DVLOG(2) << "Capture of OffscreenPresentation content has stopped for "
"start_url=" << start_url_.spec();
- owner_->ClosePresentation(this);
+ Close();
return;
} else {
DVLOG(3) << "Capture of OffscreenPresentation content continues for "
@@ -462,7 +484,7 @@ void OffscreenPresentation::DieIfContentCaptureEnded() {
// to free up resources.
LOG(WARNING) << "Capture of OffscreenPresentation content did not start "
"within timeout for start_url=" << start_url_.spec();
- owner_->ClosePresentation(this);
+ Close();
return;
}
@@ -474,4 +496,14 @@ void OffscreenPresentation::DieIfContentCaptureEnded() {
base::Unretained(this)));
}
+void OffscreenPresentation::Close() {
+ content::RenderFrameHost* render_frame_host =
+ presentation_web_contents_->GetMainFrame();
+ DCHECK(render_frame_host);
+ std::pair<int, int> rfh_id(render_frame_host->GetProcess()->GetID(),
+ render_frame_host->GetRoutingID());
+ one_ua_presentation_router_->UnregisterPresenter(rfh_id);
mark a. foltz 2015/09/11 23:24:20 UnregisterPresentation(WebContents*)
imcheng 2015/09/26 01:21:56 Done.
+ owner_->ClosePresentation(this);
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698