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

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

Issue 12843009: Replace screen capture confirmation infobar with a message box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
« no previous file with comments | « chrome/browser/media/media_capture_devices_dispatcher.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/media_capture_devices_dispatcher.cc
diff --git a/chrome/browser/media/media_capture_devices_dispatcher.cc b/chrome/browser/media/media_capture_devices_dispatcher.cc
index 5c223849626a46338b2a6e3498843a0828b28b1e..ab2291ca4a35af1284c06dd33ea48a640091279a 100644
--- a/chrome/browser/media/media_capture_devices_dispatcher.cc
+++ b/chrome/browser/media/media_capture_devices_dispatcher.cc
@@ -4,16 +4,24 @@
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
+#include "base/command_line.h"
+#include "base/logging.h"
#include "base/prefs/pref_service.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/media/audio_stream_indicator.h"
#include "chrome/browser/media/media_stream_capture_indicator.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/media_stream_infobar_delegate.h"
+#include "chrome/browser/ui/simple_message_box.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_devices_monitor.h"
#include "content/public/common/media_stream_request.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
using content::BrowserThread;
using content::MediaStreamDevices;
@@ -36,8 +44,19 @@ const content::MediaStreamDevice* FindDefaultDeviceWithId(
return &(*devices.begin());
};
-} // namespace
+// This is a short-term solution to allow testing of the the Screen Capture API
+// with Google Hangouts in M27.
+// TODO(sergeyu): Remove this whitelist as soon as possible.
+bool IsOriginWhitelistedForScreenCapture(const GURL& origin) {
+#if defined(OFFICIAL_BUILD)
+ return origin.spec() == "https://staging.talkgadget.google.com/" ||
+ origin.spec() == "https://plus.google.com/";
+#else
+ return false;
+#endif
+}
+} // namespace
MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
return Singleton<MediaCaptureDevicesDispatcher>::get();
@@ -95,6 +114,48 @@ MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
return video_devices_;
}
+void MediaCaptureDevicesDispatcher::RequestAccess(
+ content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // Handle regular media requests first.
+ if (request.video_type != content::MEDIA_SCREEN_VIDEO_CAPTURE) {
+ MediaStreamInfoBarDelegate::Create(web_contents, request, callback);
+ return;
+ }
+
+ content::MediaStreamDevices devices;
+
+ bool screen_capture_enabled = CommandLine::ForCurrentProcess()->HasSwitch(
Peter Kasting 2013/03/23 19:08:40 Nit: Just for readability you might want to break
Sergey Ulanov 2013/03/23 19:16:05 Done.
+ switches::kEnableUserMediaScreenCapturing) ||
+ IsOriginWhitelistedForScreenCapture(request.security_origin);
+ // Deny request automatically in the following cases:
+ // 1. Screen capturing is not enabled via command line switch.
+ // 2. Audio capture was requested (it's not supported yet).
+ // 3. Request from a page that was not loaded from a secure origin.
+ if (screen_capture_enabled &&
+ request.audio_type == content::MEDIA_NO_SERVICE &&
+ request.security_origin.SchemeIsSecure()) {
+ string16 application_name = UTF8ToUTF16(request.security_origin.spec());
+ chrome::MessageBoxResult result = chrome::ShowMessageBox(
+ NULL,
+ l10n_util::GetStringFUTF16(IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TITLE,
+ application_name),
+ l10n_util::GetStringFUTF16(IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TEXT,
+ application_name),
+ chrome::MESSAGE_BOX_TYPE_QUESTION);
+
Peter Kasting 2013/03/23 19:08:40 Nit: Extra blank line
Sergey Ulanov 2013/03/23 19:16:05 Done.
+ if (result == chrome::MESSAGE_BOX_RESULT_YES) {
+ devices.push_back(content::MediaStreamDevice(
+ content::MEDIA_SCREEN_VIDEO_CAPTURE, std::string(), "Screen"));
+ }
+ }
+
+ callback.Run(devices);
+}
+
void MediaCaptureDevicesDispatcher::GetDefaultDevicesForProfile(
Profile* profile,
bool audio,
« no previous file with comments | « chrome/browser/media/media_capture_devices_dispatcher.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698