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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 10 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 return needs_mic == has_mic && needs_cam == has_cam; 118 return needs_mic == has_mic && needs_cam == has_cam;
119 } 119 }
120 120
121 content::WebContents* GetWebContents() { 121 content::WebContents* GetWebContents() {
122 return browser()->tab_strip_model()->GetActiveWebContents(); 122 return browser()->tab_strip_model()->GetActiveWebContents();
123 } 123 }
124 124
125 // Creates a MediaStreamRequest, asking for those media types, which have a 125 // Creates a MediaStreamRequest, asking for those media types, which have a
126 // non-empty id string. 126 // non-empty id string.
127 content::MediaStreamRequest CreateRequest(const std::string& audio_id, 127 content::MediaStreamRequest CreateRequestWithType(
128 const std::string& video_id) { 128 const std::string& audio_id,
129 const std::string& video_id,
130 content::MediaStreamRequestType request_type) {
129 content::MediaStreamType audio_type = 131 content::MediaStreamType audio_type =
130 audio_id.empty() ? content::MEDIA_NO_SERVICE 132 audio_id.empty() ? content::MEDIA_NO_SERVICE
131 : content::MEDIA_DEVICE_AUDIO_CAPTURE; 133 : content::MEDIA_DEVICE_AUDIO_CAPTURE;
132 content::MediaStreamType video_type = 134 content::MediaStreamType video_type =
133 video_id.empty() ? content::MEDIA_NO_SERVICE 135 video_id.empty() ? content::MEDIA_NO_SERVICE
134 : content::MEDIA_DEVICE_VIDEO_CAPTURE; 136 : content::MEDIA_DEVICE_VIDEO_CAPTURE;
135 return content::MediaStreamRequest(0, 137 return content::MediaStreamRequest(0, 0, 0, example_url(), false,
136 0, 138 request_type, audio_id, video_id,
137 0, 139 audio_type, video_type);
138 example_url(), 140 }
139 false, 141
140 content::MEDIA_DEVICE_ACCESS, 142 content::MediaStreamRequest CreateRequest(const std::string& audio_id,
141 audio_id, 143 const std::string& video_id) {
142 video_id, 144 return CreateRequestWithType(audio_id, video_id,
143 audio_type, 145 content::MEDIA_DEVICE_ACCESS);
144 video_type);
145 } 146 }
146 147
147 void InitWithUrl(const GURL& url) { 148 void InitWithUrl(const GURL& url) {
148 DCHECK(example_url_.is_empty()); 149 DCHECK(example_url_.is_empty());
149 example_url_ = url; 150 example_url_ = url;
150 ui_test_utils::NavigateToURL(browser(), example_url_); 151 ui_test_utils::NavigateToURL(browser(), example_url_);
151 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED, 152 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED,
152 GetContentSettings()->GetMicrophoneCameraState()); 153 GetContentSettings()->GetMicrophoneCameraState());
153 } 154 }
154 155
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 MediaStreamDevicesController controller2( 674 MediaStreamDevicesController controller2(
674 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), 675 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()),
675 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, 676 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse,
676 this)); 677 this));
677 ASSERT_FALSE(controller2.IsAskingForAudio()); 678 ASSERT_FALSE(controller2.IsAskingForAudio());
678 ASSERT_FALSE(controller2.IsAskingForVideo()); 679 ASSERT_FALSE(controller2.IsAskingForVideo());
679 680
680 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); 681 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result());
681 ASSERT_TRUE(DevicesContains(true, true)); 682 ASSERT_TRUE(DevicesContains(true, true));
682 } 683 }
684
685 // For Pepper request from insecure origin, even if it's ALLOW, it won't be
686 // changed to ASK.
687 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest,
688 PepperRequestInsecure) {
689 InitWithUrl(GURL("http://www.example.com"));
690 SetContentSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW);
691
692 MediaStreamDevicesController controller(
693 GetWebContents(), CreateRequestWithType(example_audio_id(), std::string(),
694 content::MEDIA_OPEN_DEVICE),
695 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse,
696 this));
697 ASSERT_FALSE(controller.IsAskingForAudio());
698 ASSERT_FALSE(controller.IsAskingForVideo());
699 }
700
701 // For non-Pepper request from insecure origin, if it's ALLOW, it will be
702 // changed to ASK.
703 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest,
704 NonPepperRequestInsecure) {
705 InitWithUrl(GURL("http://www.example.com"));
706 SetContentSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW);
707
708 MediaStreamDevicesController controller(
709 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()),
710 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse,
711 this));
712 ASSERT_TRUE(controller.IsAskingForAudio());
713 ASSERT_TRUE(controller.IsAskingForVideo());
714 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698