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

Side by Side Diff: chrome/browser/chromeos/login/saml/saml_browsertest.cc

Issue 2746873004: Move ChromeOS login media access logic into a MediaAccessHandler (Closed)
Patch Set: Move ChromeOS login media access logic into a MediaAccessHandler 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/BUILD.gn ('k') | chrome/browser/chromeos/login/ui/webui_login_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <cstring> 5 #include <cstring>
6 #include <memory> 6 #include <memory>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 24 matching lines...) Expand all
35 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" 35 #include "chrome/browser/chromeos/login/ui/webui_login_display.h"
36 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 36 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
37 #include "chrome/browser/chromeos/login/wizard_controller.h" 37 #include "chrome/browser/chromeos/login/wizard_controller.h"
38 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" 38 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h"
39 #include "chrome/browser/chromeos/policy/device_policy_builder.h" 39 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
40 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 40 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
41 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 41 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
42 #include "chrome/browser/chromeos/profiles/profile_helper.h" 42 #include "chrome/browser/chromeos/profiles/profile_helper.h"
43 #include "chrome/browser/chromeos/settings/cros_settings.h" 43 #include "chrome/browser/chromeos/settings/cros_settings.h"
44 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 44 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
45 #include "chrome/browser/media/webrtc/media_permission.h" 45 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
46 #include "chrome/browser/policy/test/local_policy_test_server.h" 46 #include "chrome/browser/policy/test/local_policy_test_server.h"
47 #include "chrome/browser/profiles/profile.h" 47 #include "chrome/browser/profiles/profile.h"
48 #include "chrome/browser/ui/webui/signin/signin_utils.h" 48 #include "chrome/browser/ui/webui/signin/signin_utils.h"
49 #include "chrome/common/chrome_constants.h" 49 #include "chrome/common/chrome_constants.h"
50 #include "chrome/common/chrome_paths.h" 50 #include "chrome/common/chrome_paths.h"
51 #include "chrome/common/chrome_switches.h" 51 #include "chrome/common/chrome_switches.h"
52 #include "chrome/grit/generated_resources.h" 52 #include "chrome/grit/generated_resources.h"
53 #include "chrome/test/base/in_process_browser_test.h" 53 #include "chrome/test/base/in_process_browser_test.h"
54 #include "chromeos/chromeos_switches.h" 54 #include "chromeos/chromeos_switches.h"
55 #include "chromeos/cryptohome/system_salt_getter.h" 55 #include "chromeos/cryptohome/system_salt_getter.h"
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, TestLoginMediaPermission) { 1435 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, TestLoginMediaPermission) {
1436 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); 1436 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html");
1437 1437
1438 const GURL url1("https://google.com"); 1438 const GURL url1("https://google.com");
1439 const GURL url2("https://example.com"); 1439 const GURL url2("https://example.com");
1440 const GURL url3("https://not-allowed.com"); 1440 const GURL url3("https://not-allowed.com");
1441 SetLoginVideoCaptureAllowedUrls({url1, url2}); 1441 SetLoginVideoCaptureAllowedUrls({url1, url2});
1442 WaitForSigninScreen(); 1442 WaitForSigninScreen();
1443 1443
1444 content::WebContents* web_contents = GetLoginUI()->GetWebContents(); 1444 content::WebContents* web_contents = GetLoginUI()->GetWebContents();
1445 Profile* profile =
1446 Profile::FromBrowserContext(web_contents->GetBrowserContext());
1447 content::MediaStreamRequestResult reason;
1448 1445
1449 // Mic should always be blocked. 1446 // Mic should always be blocked.
1450 { 1447 EXPECT_FALSE(
1451 MediaPermission permission(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, url1, 1448 MediaCaptureDevicesDispatcher::GetInstance()->CheckMediaAccessPermission(
1452 url1, profile, web_contents); 1449 web_contents, url1, content::MEDIA_DEVICE_AUDIO_CAPTURE));
1453 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission.GetPermissionStatus(&reason));
1454 }
1455 1450
1456 // Camera should be allowed if allowed by the whitelist, otherwise blocked. 1451 // Camera should be allowed if allowed by the whitelist, otherwise blocked.
1457 { 1452 EXPECT_TRUE(
1458 MediaPermission permission(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, url1, 1453 MediaCaptureDevicesDispatcher::GetInstance()->CheckMediaAccessPermission(
1459 url1, profile, web_contents); 1454 web_contents, url1, content::MEDIA_DEVICE_VIDEO_CAPTURE));
1460 EXPECT_EQ(CONTENT_SETTING_ALLOW, permission.GetPermissionStatus(&reason));
1461 }
1462 1455
1463 { 1456 EXPECT_TRUE(
1464 MediaPermission permission(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, url2, 1457 MediaCaptureDevicesDispatcher::GetInstance()->CheckMediaAccessPermission(
1465 url2, profile, web_contents); 1458 web_contents, url2, content::MEDIA_DEVICE_VIDEO_CAPTURE));
1466 EXPECT_EQ(CONTENT_SETTING_ALLOW, permission.GetPermissionStatus(&reason));
1467 }
1468 1459
1469 { 1460 EXPECT_FALSE(
1470 MediaPermission permission(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, url3, 1461 MediaCaptureDevicesDispatcher::GetInstance()->CheckMediaAccessPermission(
1471 url3, profile, web_contents); 1462 web_contents, url3, content::MEDIA_DEVICE_VIDEO_CAPTURE));
1472 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission.GetPermissionStatus(&reason));
1473 }
1474 1463
1475 // Camera should be blocked in the login screen, even if it's allowed via 1464 // Camera should be blocked in the login screen, even if it's allowed via
1476 // content setting. 1465 // content setting.
1477 { 1466 Profile* profile =
1478 HostContentSettingsMapFactory::GetForProfile(profile) 1467 Profile::FromBrowserContext(web_contents->GetBrowserContext());
1479 ->SetContentSettingDefaultScope( 1468 HostContentSettingsMapFactory::GetForProfile(profile)
1480 url3, url3, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), 1469 ->SetContentSettingDefaultScope(url3, url3,
1481 CONTENT_SETTING_ALLOW); 1470 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
1471 std::string(), CONTENT_SETTING_ALLOW);
1482 1472
1483 MediaPermission permission(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, url3, 1473 EXPECT_FALSE(
1484 url3, profile, web_contents); 1474 MediaCaptureDevicesDispatcher::GetInstance()->CheckMediaAccessPermission(
1485 EXPECT_EQ(CONTENT_SETTING_BLOCK, permission.GetPermissionStatus(&reason)); 1475 web_contents, url3, content::MEDIA_DEVICE_VIDEO_CAPTURE));
1486 }
1487 } 1476 }
1488 1477
1489 } // namespace chromeos 1478 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/chromeos/login/ui/webui_login_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698