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

Unified Diff: chrome/browser/media/media_stream_devices_controller.cc

Issue 2123863004: ScreenCapture for Android phase1, part II (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UI tweaking and rebase Created 4 years, 4 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/media_stream_devices_controller.cc
diff --git a/chrome/browser/media/media_stream_devices_controller.cc b/chrome/browser/media/media_stream_devices_controller.cc
index 11d6df9543535a0caf3181bbc1b53d847fec3ef2..97aa1f33a20810b503be350af781392e4f7dcf6a 100644
--- a/chrome/browser/media/media_stream_devices_controller.cc
+++ b/chrome/browser/media/media_stream_devices_controller.cc
@@ -15,6 +15,7 @@
#include "base/values.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
+#include "chrome/browser/media/desktop_streams_registry.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/media_permission.h"
#include "chrome/browser/media/media_stream_capture_indicator.h"
@@ -40,6 +41,7 @@
#include "content/public/common/origin_util.h"
#include "extensions/common/constants.h"
#include "grit/theme_resources.h"
+#include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h"
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(ANDROID_JAVA_UI)
@@ -204,6 +206,10 @@ MediaStreamDevicesController::MediaStreamDevicesController(
web_contents, content_settings_types)) {
return;
}
+
+ // Always show infobar for screen capture on Android.
+ if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE)
+ return;
#endif
// Otherwise we can run the callback immediately.
@@ -245,12 +251,20 @@ bool MediaStreamDevicesController::IsAskingForVideo() const {
return old_video_setting_ == CONTENT_SETTING_ASK;
}
+bool MediaStreamDevicesController::IsAskingForScreenCapture() const {
+ return request_.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE;
+}
+
base::string16 MediaStreamDevicesController::GetMessageText() const {
int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO;
- if (!IsAskingForAudio())
+ if (IsAskingForScreenCapture()) {
+ message_id = IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TEXT;
+ } else if (!IsAskingForAudio()) {
message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY;
- else if (!IsAskingForVideo())
+ } else if (!IsAskingForVideo()) {
message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY;
+ }
+
return l10n_util::GetStringFUTF16(
message_id,
url_formatter::FormatUrlForSecurityDisplay(
@@ -290,21 +304,31 @@ GURL MediaStreamDevicesController::GetOrigin() const {
void MediaStreamDevicesController::PermissionGranted() {
RecordPermissionAction(request_, profile_,
base::Bind(PermissionUmaUtil::PermissionGranted));
- RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
- old_audio_setting_, CONTENT_SETTING_ALLOW),
- GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
- old_video_setting_, CONTENT_SETTING_ALLOW),
- content::MEDIA_DEVICE_PERMISSION_DENIED);
+ if (IsAskingForScreenCapture()) {
+ RunCallback(old_audio_setting_, old_video_setting_,
+ content::MEDIA_DEVICE_OK);
+ } else {
+ RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
+ old_audio_setting_, CONTENT_SETTING_ALLOW),
+ GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
+ old_video_setting_, CONTENT_SETTING_ALLOW),
+ content::MEDIA_DEVICE_PERMISSION_DENIED);
+ }
}
void MediaStreamDevicesController::PermissionDenied() {
RecordPermissionAction(request_, profile_,
base::Bind(PermissionUmaUtil::PermissionDenied));
- RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
- old_audio_setting_, CONTENT_SETTING_BLOCK),
- GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
- old_video_setting_, CONTENT_SETTING_BLOCK),
- content::MEDIA_DEVICE_PERMISSION_DENIED);
+ if (IsAskingForScreenCapture()) {
+ RunCallback(old_audio_setting_, old_video_setting_,
+ content::MEDIA_DEVICE_PERMISSION_DENIED);
+ } else {
+ RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
+ old_audio_setting_, CONTENT_SETTING_BLOCK),
+ GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
+ old_video_setting_, CONTENT_SETTING_BLOCK),
+ content::MEDIA_DEVICE_PERMISSION_DENIED);
+ }
}
void MediaStreamDevicesController::GroupedRequestFinished(bool audio_accepted,
@@ -471,11 +495,21 @@ void MediaStreamDevicesController::RunCallback(
content::MediaStreamDevices devices =
GetDevices(audio_setting, video_setting);
- // If either audio or video are allowed then the callback should report
- // success, otherwise we report |denial_reason|.
content::MediaStreamRequestResult request_result = content::MEDIA_DEVICE_OK;
- if (audio_setting != CONTENT_SETTING_ALLOW &&
- video_setting != CONTENT_SETTING_ALLOW) {
+ if (IsAskingForScreenCapture()) {
+ request_result = denial_reason;
+ if (request_result == content::MEDIA_DEVICE_OK) {
+ content::DesktopMediaID screen_id;
+ screen_id = content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN,
+ webrtc::kFullDesktopScreenId);
+ devices.push_back(
+ content::MediaStreamDevice(content::MEDIA_DESKTOP_VIDEO_CAPTURE,
+ screen_id.ToString(), "Screen"));
+ }
+ } else if (audio_setting != CONTENT_SETTING_ALLOW &&
+ video_setting != CONTENT_SETTING_ALLOW) {
+ // If either audio or video are allowed then the callback should report
+ // success, otherwise we report |denial_reason|.
DCHECK_NE(content::MEDIA_DEVICE_OK, denial_reason);
request_result = denial_reason;
} else if (devices.empty()) {

Powered by Google App Engine
This is Rietveld 408576698