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

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

Issue 1221483002: New tabCapture.captureOffscreenTab API, initially for Presentation API 1UA mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mostly revert to Patch Set 6, plus minor tweaks. [and REBASE] Created 5 years, 2 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..f83a6f6d1520c8672001a0f5d7656cbf6467fad0 100644
--- a/chrome/browser/extensions/api/tab_capture/offscreen_presentation.cc
+++ b/chrome/browser/extensions/api/tab_capture/offscreen_presentation.cc
@@ -138,25 +138,17 @@ OffscreenPresentationsOwner* OffscreenPresentationsOwner::Get(
return FromWebContents(extension_web_contents);
}
-OffscreenPresentation* OffscreenPresentationsOwner::FindOrStartPresentation(
+OffscreenPresentation* OffscreenPresentationsOwner::StartPresentation(
const GURL& start_url,
const std::string& presentation_id,
const gfx::Size& initial_size) {
- OffscreenPresentation* presentation =
- FindPresentation(start_url, presentation_id);
- if (presentation) {
- DVLOG(1) << "Returning already-running OffscreenPresentation for start_url="
- << presentation->start_url();
- return presentation;
- }
-
if (presentations_.size() >= kMaxPresentationsPerExtension)
return nullptr; // Maximum number of presentations reached.
- presentation = new OffscreenPresentation(this, start_url, presentation_id);
- presentations_.push_back(presentation);
- presentation->Start(initial_size);
- return presentation;
+ presentations_.push_back(
+ new OffscreenPresentation(this, start_url, presentation_id));
+ presentations_.back()->Start(initial_size);
+ return presentations_.back();
}
void OffscreenPresentationsOwner::ClosePresentation(
@@ -167,16 +159,6 @@ void OffscreenPresentationsOwner::ClosePresentation(
presentations_.erase(it);
}
-OffscreenPresentation* OffscreenPresentationsOwner::FindPresentation(
- const GURL& start_url, const std::string& presentation_id) const {
- for (OffscreenPresentation* presentation : presentations_) {
- if (presentation->start_url() == start_url &&
- presentation->presentation_id() == presentation_id)
- return presentation;
- }
- return nullptr;
-}
-
OffscreenPresentation::OffscreenPresentation(OffscreenPresentationsOwner* owner,
const GURL& start_url,
const std::string& id)
@@ -219,6 +201,13 @@ void OffscreenPresentation::Start(const gfx::Size& initial_size) {
// automatically unmuted, but will be captured into the MediaStream.
presentation_web_contents_->SetAudioMuted(true);
+ // TODO(imcheng): If |presentation_id_| is not empty, register it with the
+ // PresentationRouter. http://crbug.com/513859
+ if (!presentation_id_.empty()) {
+ NOTIMPLEMENTED()
+ << "Register with PresentationRouter, id=" << presentation_id_;
+ }
+
// Navigate to the initial URL of the presentation.
content::NavigationController::LoadURLParams load_params(start_url_);
load_params.should_replace_current_entry = true;
@@ -381,14 +370,12 @@ void OffscreenPresentation::RequestMediaAccessPermission(
// WebContents.
content::BrowserContext* const extension_browser_context =
owner_->extension_web_contents()->GetBrowserContext();
- std::string extension_id;
- for (const ExtensionHost* host :
- ProcessManager::Get(extension_browser_context)->background_hosts()) {
- if (host->host_contents() == owner_->extension_web_contents()) {
- extension_id = host->extension_id();
- break;
- }
- }
+ const extensions::Extension* const extension =
+ ProcessManager::Get(extension_browser_context)->
+ GetExtensionForWebContents(owner_->extension_web_contents());
+ const std::string extension_id = extension ? extension->id() : "";
+ LOG_IF(DFATAL, extension_id.empty())
+ << "Extension that started this OffscreenPresentation was not found.";
// If verified, allow any tab capture audio/video devices that were requested.
extensions::TabCaptureRegistry* const tab_capture_registry =

Powered by Google App Engine
This is Rietveld 408576698