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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 2746853002: Change MediaStreamDevicesController::RequestPermissions to use the requesting WebContents (Closed)
Patch Set: Change MediaStreamDevicesController::RequestPermissions to use the requesting WebContents Created 3 years, 8 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
« no previous file with comments | « chrome/browser/permissions/permission_request_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 3140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 }; 3151 };
3152 3152
3153 MediaStreamDevicesControllerBrowserTest() 3153 MediaStreamDevicesControllerBrowserTest()
3154 : request_url_allowed_via_whitelist_(false), 3154 : request_url_allowed_via_whitelist_(false),
3155 request_url_("https://www.example.com/foo") { 3155 request_url_("https://www.example.com/foo") {
3156 policy_value_ = GetParam(); 3156 policy_value_ = GetParam();
3157 prompt_delegate_.set_response_type(PermissionRequestManager::ACCEPT_ALL); 3157 prompt_delegate_.set_response_type(PermissionRequestManager::ACCEPT_ALL);
3158 } 3158 }
3159 virtual ~MediaStreamDevicesControllerBrowserTest() {} 3159 virtual ~MediaStreamDevicesControllerBrowserTest() {}
3160 3160
3161 void SetUpOnMainThread() override {
3162 PolicyTest::SetUpOnMainThread();
3163 ui_test_utils::NavigateToURL(browser(), request_url_);
3164 }
3165
3166 content::MediaStreamRequest CreateRequest(
3167 content::MediaStreamType audio_request_type,
3168 content::MediaStreamType video_request_type) {
3169 content::WebContents* web_contents =
3170 browser()->tab_strip_model()->GetActiveWebContents();
3171 EXPECT_EQ(request_url_,
3172 web_contents->GetMainFrame()->GetLastCommittedURL());
3173 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
3174 int render_frame_id = web_contents->GetMainFrame()->GetRoutingID();
3175 return content::MediaStreamRequest(
3176 render_process_id, render_frame_id, 0, request_url_.GetOrigin(), false,
3177 content::MEDIA_DEVICE_ACCESS, std::string(), std::string(),
3178 audio_request_type, video_request_type, false);
3179 }
3180
3161 // Configure a given policy map. The |policy_name| is the name of either the 3181 // Configure a given policy map. The |policy_name| is the name of either the
3162 // audio or video capture allow policy and must never be NULL. 3182 // audio or video capture allow policy and must never be NULL.
3163 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist 3183 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist
3164 // policy is set. If non-NULL, the whitelist policy is set to contain either 3184 // policy is set. If non-NULL, the whitelist policy is set to contain either
3165 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. 3185 // the |allow_rule| (if non-NULL) or an "allow all" wildcard.
3166 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, 3186 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name,
3167 const char* whitelist_policy, 3187 const char* whitelist_policy,
3168 const char* allow_rule) { 3188 const char* allow_rule) {
3169 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 3189 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
3170 POLICY_SOURCE_CLOUD, 3190 POLICY_SOURCE_CLOUD,
(...skipping 23 matching lines...) Expand all
3194 std::unique_ptr<content::MediaStreamUI> ui) { 3214 std::unique_ptr<content::MediaStreamUI> ui) {
3195 if (policy_value_ || request_url_allowed_via_whitelist_) { 3215 if (policy_value_ || request_url_allowed_via_whitelist_) {
3196 ASSERT_EQ(1U, devices.size()); 3216 ASSERT_EQ(1U, devices.size());
3197 ASSERT_EQ("fake_dev", devices[0].id); 3217 ASSERT_EQ("fake_dev", devices[0].id);
3198 } else { 3218 } else {
3199 ASSERT_EQ(0U, devices.size()); 3219 ASSERT_EQ(0U, devices.size());
3200 } 3220 }
3201 } 3221 }
3202 3222
3203 void FinishAudioTest() { 3223 void FinishAudioTest() {
3204 content::MediaStreamRequest request( 3224 content::MediaStreamRequest request(CreateRequest(
3205 0, 0, 0, request_url_.GetOrigin(), false, content::MEDIA_DEVICE_ACCESS, 3225 content::MEDIA_DEVICE_AUDIO_CAPTURE, content::MEDIA_NO_SERVICE));
3206 std::string(), std::string(), content::MEDIA_DEVICE_AUDIO_CAPTURE,
3207 content::MEDIA_NO_SERVICE, false);
3208 // TODO(raymes): Test MEDIA_DEVICE_OPEN (Pepper) which grants both webcam 3226 // TODO(raymes): Test MEDIA_DEVICE_OPEN (Pepper) which grants both webcam
3209 // and microphone permissions at the same time. 3227 // and microphone permissions at the same time.
3210 MediaStreamDevicesController::RequestPermissionsWithDelegate( 3228 MediaStreamDevicesController::RequestPermissionsWithDelegate(
3211 browser()->tab_strip_model()->GetActiveWebContents(), request, 3229 request,
3212 base::Bind(&MediaStreamDevicesControllerBrowserTest::Accept, 3230 base::Bind(&MediaStreamDevicesControllerBrowserTest::Accept,
3213 base::Unretained(this)), 3231 base::Unretained(this)),
3214 &prompt_delegate_); 3232 &prompt_delegate_);
3215 3233
3216 base::MessageLoop::current()->QuitWhenIdle(); 3234 base::MessageLoop::current()->QuitWhenIdle();
3217 } 3235 }
3218 3236
3219 void FinishVideoTest() { 3237 void FinishVideoTest() {
3220 content::MediaStreamRequest request( 3238 content::MediaStreamRequest request(CreateRequest(
3221 0, 0, 0, request_url_.GetOrigin(), false, content::MEDIA_DEVICE_ACCESS, 3239 content::MEDIA_NO_SERVICE, content::MEDIA_DEVICE_VIDEO_CAPTURE));
3222 std::string(), std::string(), content::MEDIA_NO_SERVICE,
3223 content::MEDIA_DEVICE_VIDEO_CAPTURE, false);
3224 // TODO(raymes): Test MEDIA_DEVICE_OPEN (Pepper) which grants both webcam 3240 // TODO(raymes): Test MEDIA_DEVICE_OPEN (Pepper) which grants both webcam
3225 // and microphone permissions at the same time. 3241 // and microphone permissions at the same time.
3226 MediaStreamDevicesController::RequestPermissionsWithDelegate( 3242 MediaStreamDevicesController::RequestPermissionsWithDelegate(
3227 browser()->tab_strip_model()->GetActiveWebContents(), request, 3243 request,
3228 base::Bind(&MediaStreamDevicesControllerBrowserTest::Accept, 3244 base::Bind(&MediaStreamDevicesControllerBrowserTest::Accept,
3229 base::Unretained(this)), 3245 base::Unretained(this)),
3230 &prompt_delegate_); 3246 &prompt_delegate_);
3231 3247
3232 base::MessageLoop::current()->QuitWhenIdle(); 3248 base::MessageLoop::current()->QuitWhenIdle();
3233 } 3249 }
3234 3250
3235 TestPermissionPromptDelegate prompt_delegate_; 3251 TestPermissionPromptDelegate prompt_delegate_;
3236 bool policy_value_; 3252 bool policy_value_;
3237 bool request_url_allowed_via_whitelist_; 3253 bool request_url_allowed_via_whitelist_;
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
4469 4485
4470 SetEmptyPolicy(); 4486 SetEmptyPolicy();
4471 // Policy not set. 4487 // Policy not set.
4472 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4488 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4473 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4489 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4474 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4490 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4475 } 4491 }
4476 #endif // defined(OS_CHROMEOS) 4492 #endif // defined(OS_CHROMEOS)
4477 4493
4478 } // namespace policy 4494 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_request_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698