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

Side by Side Diff: chrome/browser/extensions/api/tab_capture/offscreen_tab.cc

Issue 2471573005: [Presentation API] (5th) (1-UA) integrate controller and receiver side for 1-UA messaging (Closed)
Patch Set: rebase 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/tab_capture/offscreen_tab.h" 5 #include "chrome/browser/extensions/api/tab_capture/offscreen_tab.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory>
9 #include <utility>
mark a. foltz 2016/11/16 01:25:37 Are these missing #includes from existing code, or
zhaobin 2016/11/23 01:29:25 Done.
8 10
9 #include "base/bind.h" 11 #include "base/bind.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" 14 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h"
15 #include "chrome/browser/media/router/receiver_presentation_service_delegate_imp l.h"
13 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/web_contents_sizer.h" 17 #include "chrome/browser/ui/web_contents_sizer.h"
15 #include "content/public/browser/render_widget_host_view.h" 18 #include "content/public/browser/render_widget_host_view.h"
16 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
17 #include "extensions/browser/extension_host.h" 20 #include "extensions/browser/extension_host.h"
18 #include "extensions/browser/process_manager.h" 21 #include "extensions/browser/process_manager.h"
19 22
20 using content::WebContents; 23 using content::WebContents;
21 24
22 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::OffscreenTabsOwner); 25 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::OffscreenTabsOwner);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 DVLOG(1) << "Destroying OffscreenTab for start_url=" << start_url_.spec(); 95 DVLOG(1) << "Destroying OffscreenTab for start_url=" << start_url_.spec();
93 } 96 }
94 97
95 void OffscreenTab::Start(const GURL& start_url, 98 void OffscreenTab::Start(const GURL& start_url,
96 const gfx::Size& initial_size, 99 const gfx::Size& initial_size,
97 const std::string& optional_presentation_id) { 100 const std::string& optional_presentation_id) {
98 DCHECK(start_time_.is_null()); 101 DCHECK(start_time_.is_null());
99 start_url_ = start_url; 102 start_url_ = start_url;
100 DVLOG(1) << "Starting OffscreenTab with initial size of " 103 DVLOG(1) << "Starting OffscreenTab with initial size of "
101 << initial_size.ToString() << " for start_url=" << start_url_.spec(); 104 << initial_size.ToString() << " for start_url=" << start_url_.spec();
102
103 // Create the WebContents to contain the off-screen tab's page. 105 // Create the WebContents to contain the off-screen tab's page.
104 offscreen_tab_web_contents_.reset( 106 offscreen_tab_web_contents_.reset(
105 WebContents::Create(WebContents::CreateParams(profile_.get()))); 107 WebContents::Create(WebContents::CreateParams(profile_.get())));
106 offscreen_tab_web_contents_->SetDelegate(this); 108 offscreen_tab_web_contents_->SetDelegate(this);
107 WebContentsObserver::Observe(offscreen_tab_web_contents_.get()); 109 WebContentsObserver::Observe(offscreen_tab_web_contents_.get());
108 110
109 // Set initial size, if specified. 111 // Set initial size, if specified.
110 if (!initial_size.IsEmpty()) 112 if (!initial_size.IsEmpty())
111 ResizeWebContents(offscreen_tab_web_contents_.get(), 113 ResizeWebContents(offscreen_tab_web_contents_.get(),
112 gfx::Rect(initial_size)); 114 gfx::Rect(initial_size));
113 115
114 // Mute audio output. When tab capture starts, the audio will be 116 // Mute audio output. When tab capture starts, the audio will be
115 // automatically unmuted, but will be captured into the MediaStream. 117 // automatically unmuted, but will be captured into the MediaStream.
116 offscreen_tab_web_contents_->SetAudioMuted(true); 118 offscreen_tab_web_contents_->SetAudioMuted(true);
117 119
118 // TODO(imcheng): If |optional_presentation_id| is not empty, register it with
119 // the PresentationRouter. http://crbug.com/513859
120 if (!optional_presentation_id.empty()) { 120 if (!optional_presentation_id.empty()) {
121 NOTIMPLEMENTED() 121 DVLOG(1) << " Register with ReceiverPresentationServiceDelegateImpl, id="
122 << "Register with PresentationRouter, id=" << optional_presentation_id; 122 << optional_presentation_id;
123 // Register the offscreen tab as the receiver of the offscreen presentation.
124 media_router::ReceiverPresentationServiceDelegateImpl::CreateForWebContents(
125 offscreen_tab_web_contents_.get(), optional_presentation_id);
123 } 126 }
124 127
125 // Navigate to the initial URL. 128 // Navigate to the initial URL.
126 content::NavigationController::LoadURLParams load_params(start_url_); 129 content::NavigationController::LoadURLParams load_params(start_url_);
127 load_params.should_replace_current_entry = true; 130 load_params.should_replace_current_entry = true;
128 load_params.should_clear_history_list = true; 131 load_params.should_clear_history_list = true;
129 offscreen_tab_web_contents_->GetController().LoadURLWithParams(load_params); 132 offscreen_tab_web_contents_->GetController().LoadURLWithParams(load_params);
130 133
131 start_time_ = base::TimeTicks::Now(); 134 start_time_ = base::TimeTicks::Now();
132 DieIfContentCaptureEnded(); 135 DieIfContentCaptureEnded();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 365
363 // Schedule the timer to check again in a second. 366 // Schedule the timer to check again in a second.
364 capture_poll_timer_.Start( 367 capture_poll_timer_.Start(
365 FROM_HERE, 368 FROM_HERE,
366 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), 369 base::TimeDelta::FromSeconds(kPollIntervalInSeconds),
367 base::Bind(&OffscreenTab::DieIfContentCaptureEnded, 370 base::Bind(&OffscreenTab::DieIfContentCaptureEnded,
368 base::Unretained(this))); 371 base::Unretained(this)));
369 } 372 }
370 373
371 } // namespace extensions 374 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698