| OLD | NEW |
| 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_presentation.h" | 5 #include "chrome/browser/extensions/api/tab_capture/offscreen_presentation.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 10 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 DCHECK_EQ(presentation_web_contents_.get(), contents); | 374 DCHECK_EQ(presentation_web_contents_.get(), contents); |
| 375 | 375 |
| 376 // This method is being called to check whether an extension is permitted to | 376 // This method is being called to check whether an extension is permitted to |
| 377 // capture the page. Verify that the request is being made by the extension | 377 // capture the page. Verify that the request is being made by the extension |
| 378 // that spawned this OffscreenPresentation. | 378 // that spawned this OffscreenPresentation. |
| 379 | 379 |
| 380 // Find the extension ID associated with the extension background page's | 380 // Find the extension ID associated with the extension background page's |
| 381 // WebContents. | 381 // WebContents. |
| 382 content::BrowserContext* const extension_browser_context = | 382 content::BrowserContext* const extension_browser_context = |
| 383 owner_->extension_web_contents()->GetBrowserContext(); | 383 owner_->extension_web_contents()->GetBrowserContext(); |
| 384 std::string extension_id; | 384 const extensions::Extension* const extension = |
| 385 for (const ExtensionHost* host : | 385 ProcessManager::Get(extension_browser_context)-> |
| 386 ProcessManager::Get(extension_browser_context)->background_hosts()) { | 386 GetExtensionForWebContents(owner_->extension_web_contents()); |
| 387 if (host->host_contents() == owner_->extension_web_contents()) { | 387 const std::string extension_id = extension ? extension->id() : ""; |
| 388 extension_id = host->extension_id(); | 388 LOG_IF(DFATAL, extension_id.empty()) |
| 389 break; | 389 << "Extension that started this OffscreenPresentation was not found."; |
| 390 } | |
| 391 } | |
| 392 | 390 |
| 393 // If verified, allow any tab capture audio/video devices that were requested. | 391 // If verified, allow any tab capture audio/video devices that were requested. |
| 394 extensions::TabCaptureRegistry* const tab_capture_registry = | 392 extensions::TabCaptureRegistry* const tab_capture_registry = |
| 395 extensions::TabCaptureRegistry::Get(extension_browser_context); | 393 extensions::TabCaptureRegistry::Get(extension_browser_context); |
| 396 content::MediaStreamDevices devices; | 394 content::MediaStreamDevices devices; |
| 397 if (tab_capture_registry && tab_capture_registry->VerifyRequest( | 395 if (tab_capture_registry && tab_capture_registry->VerifyRequest( |
| 398 request.render_process_id, | 396 request.render_process_id, |
| 399 request.render_frame_id, | 397 request.render_frame_id, |
| 400 extension_id)) { | 398 extension_id)) { |
| 401 if (request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) { | 399 if (request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 466 |
| 469 // Schedule the timer to check again in a second. | 467 // Schedule the timer to check again in a second. |
| 470 capture_poll_timer_.Start( | 468 capture_poll_timer_.Start( |
| 471 FROM_HERE, | 469 FROM_HERE, |
| 472 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), | 470 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), |
| 473 base::Bind(&OffscreenPresentation::DieIfContentCaptureEnded, | 471 base::Bind(&OffscreenPresentation::DieIfContentCaptureEnded, |
| 474 base::Unretained(this))); | 472 base::Unretained(this))); |
| 475 } | 473 } |
| 476 | 474 |
| 477 } // namespace extensions | 475 } // namespace extensions |
| OLD | NEW |