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_stream_devices_controller_browsertest.cc

Issue 1318173002: Integrate MediaPermission with PermissionManager by using PermissionContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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_browsertest.cc
diff --git a/chrome/browser/media/media_stream_devices_controller_browsertest.cc b/chrome/browser/media/media_stream_devices_controller_browsertest.cc
index 3aa3fa65c9991416788048715dd302be31efdfd2..b4c217125954abeae7eba88eaf6acd5491bae7a0 100644
--- a/chrome/browser/media/media_stream_devices_controller_browsertest.cc
+++ b/chrome/browser/media/media_stream_devices_controller_browsertest.cc
@@ -124,24 +124,25 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase {
// Creates a MediaStreamRequest, asking for those media types, which have a
// non-empty id string.
- content::MediaStreamRequest CreateRequest(const std::string& audio_id,
- const std::string& video_id) {
+ content::MediaStreamRequest CreateRequestWithType(
+ const std::string& audio_id,
+ const std::string& video_id,
+ content::MediaStreamRequestType request_type) {
content::MediaStreamType audio_type =
audio_id.empty() ? content::MEDIA_NO_SERVICE
: content::MEDIA_DEVICE_AUDIO_CAPTURE;
content::MediaStreamType video_type =
video_id.empty() ? content::MEDIA_NO_SERVICE
: content::MEDIA_DEVICE_VIDEO_CAPTURE;
- return content::MediaStreamRequest(0,
- 0,
- 0,
- example_url(),
- false,
- content::MEDIA_DEVICE_ACCESS,
- audio_id,
- video_id,
- audio_type,
- video_type);
+ return content::MediaStreamRequest(0, 0, 0, example_url(), false,
+ request_type, audio_id, video_id,
+ audio_type, video_type);
+ }
+
+ content::MediaStreamRequest CreateRequest(const std::string& audio_id,
+ const std::string& video_id) {
+ return CreateRequestWithType(audio_id, video_id,
+ content::MEDIA_DEVICE_ACCESS);
}
void InitWithUrl(const GURL& url) {
@@ -680,3 +681,34 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest,
ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result());
ASSERT_TRUE(DevicesContains(true, true));
}
+
+// For Pepper request from insecure origin, even if it's ALLOW, it won't be
+// changed to ASK.
+IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest,
+ PepperRequestInsecure) {
+ InitWithUrl(GURL("http://www.example.com"));
+ SetContentSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW);
+
+ MediaStreamDevicesController controller(
+ GetWebContents(), CreateRequestWithType(example_audio_id(), std::string(),
+ content::MEDIA_OPEN_DEVICE),
+ base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse,
+ this));
+ ASSERT_FALSE(controller.IsAskingForAudio());
+ ASSERT_FALSE(controller.IsAskingForVideo());
+}
+
+// For non-Pepper request from insecure origin, if it's ALLOW, it will be
+// changed to ASK.
+IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest,
+ NonPepperRequestInsecure) {
+ InitWithUrl(GURL("http://www.example.com"));
+ SetContentSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW);
+
+ MediaStreamDevicesController controller(
+ GetWebContents(), CreateRequest(example_audio_id(), example_video_id()),
+ base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse,
+ this));
+ ASSERT_TRUE(controller.IsAskingForAudio());
+ ASSERT_TRUE(controller.IsAskingForVideo());
+}

Powered by Google App Engine
This is Rietveld 408576698