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

Side by Side Diff: chrome/browser/geolocation/geolocation_permission_context_unittest.cc

Issue 2908133003: Split GetPermissionStatus into GetPermissionStatusForFrame/Worker
Patch Set: Split GetPermissionStatus into GetPermissionStatusForFrame/Worker Created 3 years, 6 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 (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 "chrome/browser/geolocation/geolocation_permission_context.h" 5 #include "chrome/browser/geolocation/geolocation_permission_context.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 GeolocationPermissionContextAndroid:: 831 GeolocationPermissionContextAndroid::
832 LocationSettingsDialogBackOff::kThreeMonths), 832 LocationSettingsDialogBackOff::kThreeMonths),
833 2); 833 2);
834 } 834 }
835 835
836 TEST_P(GeolocationPermissionContextTests, LSDBackOffPermissionStatus) { 836 TEST_P(GeolocationPermissionContextTests, LSDBackOffPermissionStatus) {
837 base::test::ScopedFeatureList scoped_feature_list; 837 base::test::ScopedFeatureList scoped_feature_list;
838 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt); 838 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt);
839 839
840 GURL requesting_frame("https://www.example.com/geolocation"); 840 GURL requesting_frame("https://www.example.com/geolocation");
841 NavigateAndCommit(requesting_frame);
841 SetGeolocationContentSetting(requesting_frame, requesting_frame, 842 SetGeolocationContentSetting(requesting_frame, requesting_frame,
842 CONTENT_SETTING_ALLOW); 843 CONTENT_SETTING_ALLOW);
843 844
844 // Turn off system location but allow the LSD to be shown, and denied. 845 // Turn off system location but allow the LSD to be shown, and denied.
845 MockLocationSettings::SetLocationStatus(true /* android */, 846 MockLocationSettings::SetLocationStatus(true /* android */,
846 false /* system */); 847 false /* system */);
847 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */, 848 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
848 DENIED); 849 DENIED);
849 850
850 // The permission status should reflect that the LSD will be shown. 851 // The permission status should reflect that the LSD will be shown.
851 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 852 ASSERT_EQ(
852 PermissionManager::Get(profile())->GetPermissionStatus( 853 blink::mojom::PermissionStatus::ASK,
853 content::PermissionType::GEOLOCATION, requesting_frame, 854 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
854 requesting_frame)); 855 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
855 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame)); 856 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
856 857
857 // Now that the LSD is in backoff, the permission status should reflect it. 858 // Now that the LSD is in backoff, the permission status should reflect it.
858 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame)); 859 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
859 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 860 ASSERT_EQ(
860 PermissionManager::Get(profile())->GetPermissionStatus( 861 blink::mojom::PermissionStatus::DENIED,
861 content::PermissionType::GEOLOCATION, requesting_frame, 862 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
862 requesting_frame)); 863 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
863 } 864 }
864 865
865 TEST_P(GeolocationPermissionContextTests, LSDBackOffAskPromptsDespiteBackOff) { 866 TEST_P(GeolocationPermissionContextTests, LSDBackOffAskPromptsDespiteBackOff) {
866 base::test::ScopedFeatureList scoped_feature_list; 867 base::test::ScopedFeatureList scoped_feature_list;
867 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt); 868 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt);
868 869
869 GURL requesting_frame("https://www.example.com/geolocation"); 870 GURL requesting_frame("https://www.example.com/geolocation");
871 NavigateAndCommit(requesting_frame);
870 SetGeolocationContentSetting(requesting_frame, requesting_frame, 872 SetGeolocationContentSetting(requesting_frame, requesting_frame,
871 CONTENT_SETTING_ALLOW); 873 CONTENT_SETTING_ALLOW);
872 874
873 // Turn off system location but allow the LSD to be shown, and denied. 875 // Turn off system location but allow the LSD to be shown, and denied.
874 MockLocationSettings::SetLocationStatus(true /* android */, 876 MockLocationSettings::SetLocationStatus(true /* android */,
875 false /* system */); 877 false /* system */);
876 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */, 878 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
877 DENIED); 879 DENIED);
878 880
879 // First, cancel a LSD prompt on the first non-DSE origin to go into backoff. 881 // First, cancel a LSD prompt on the first non-DSE origin to go into backoff.
880 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame)); 882 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
881 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame)); 883 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
882 884
883 // Set the content setting back to ASK. The permission status should be 885 // Set the content setting back to ASK. The permission status should be
884 // prompt, and the LSD prompt should now be shown. 886 // prompt, and the LSD prompt should now be shown.
885 SetGeolocationContentSetting(requesting_frame, requesting_frame, 887 SetGeolocationContentSetting(requesting_frame, requesting_frame,
886 CONTENT_SETTING_ASK); 888 CONTENT_SETTING_ASK);
887 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 889 ASSERT_EQ(
888 PermissionManager::Get(profile())->GetPermissionStatus( 890 blink::mojom::PermissionStatus::ASK,
889 content::PermissionType::GEOLOCATION, requesting_frame, 891 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
890 requesting_frame)); 892 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
891 EXPECT_TRUE( 893 EXPECT_TRUE(
892 RequestPermissionIsLSDShownWithPermissionPrompt(requesting_frame)); 894 RequestPermissionIsLSDShownWithPermissionPrompt(requesting_frame));
893 } 895 }
894 896
895 TEST_P(GeolocationPermissionContextTests, 897 TEST_P(GeolocationPermissionContextTests,
896 LSDBackOffAcceptPermissionResetsBackOff) { 898 LSDBackOffAcceptPermissionResetsBackOff) {
897 base::test::ScopedFeatureList scoped_feature_list; 899 base::test::ScopedFeatureList scoped_feature_list;
898 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt); 900 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt);
899 901
900 GURL requesting_frame("https://www.example.com/geolocation"); 902 GURL requesting_frame("https://www.example.com/geolocation");
903 NavigateAndCommit(requesting_frame);
901 SetGeolocationContentSetting(requesting_frame, requesting_frame, 904 SetGeolocationContentSetting(requesting_frame, requesting_frame,
902 CONTENT_SETTING_ALLOW); 905 CONTENT_SETTING_ALLOW);
903 906
904 // Turn off system location but allow the LSD to be shown, and denied. 907 // Turn off system location but allow the LSD to be shown, and denied.
905 MockLocationSettings::SetLocationStatus(true /* android */, 908 MockLocationSettings::SetLocationStatus(true /* android */,
906 false /* system */); 909 false /* system */);
907 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */, 910 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
908 DENIED); 911 DENIED);
909 912
910 // First, get into the highest backoff state. 913 // First, get into the highest backoff state.
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 CONTENT_SETTING_ASK, 1256 CONTENT_SETTING_ASK,
1254 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); 1257 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0));
1255 } 1258 }
1256 1259
1257 #if defined(OS_ANDROID) 1260 #if defined(OS_ANDROID)
1258 TEST_P(GeolocationPermissionContextTests, SearchGeolocationInIncognito) { 1261 TEST_P(GeolocationPermissionContextTests, SearchGeolocationInIncognito) {
1259 base::test::ScopedFeatureList scoped_feature_list; 1262 base::test::ScopedFeatureList scoped_feature_list;
1260 EnableFeature(&scoped_feature_list, features::kConsistentOmniboxGeolocation); 1263 EnableFeature(&scoped_feature_list, features::kConsistentOmniboxGeolocation);
1261 1264
1262 GURL requesting_frame(TestSearchEngineDelegate::kDSETestUrl); 1265 GURL requesting_frame(TestSearchEngineDelegate::kDSETestUrl);
1266 NavigateAndCommit(requesting_frame);
1263 // The DSE Geolocation setting should be used in incognito if it is BLOCK, 1267 // The DSE Geolocation setting should be used in incognito if it is BLOCK,
1264 // but not if it is ALLOW. 1268 // but not if it is ALLOW.
1265 SearchGeolocationService* geo_service = 1269 SearchGeolocationService* geo_service =
1266 SearchGeolocationService::Factory::GetForBrowserContext(profile()); 1270 SearchGeolocationService::Factory::GetForBrowserContext(profile());
1267 geo_service->SetSearchEngineDelegateForTest( 1271 geo_service->SetSearchEngineDelegateForTest(
1268 base::MakeUnique<TestSearchEngineDelegate>()); 1272 base::MakeUnique<TestSearchEngineDelegate>());
1269 1273
1270 Profile* otr_profile = profile()->GetOffTheRecordProfile(); 1274 Profile* otr_profile = profile()->GetOffTheRecordProfile();
1271 1275
1272 // A DSE setting of ALLOW should not flow through to incognito. 1276 // A DSE setting of ALLOW should not flow through to incognito.
1273 geo_service->SetDSEGeolocationSetting(true); 1277 geo_service->SetDSEGeolocationSetting(true);
1274 ASSERT_EQ(CONTENT_SETTING_ASK, 1278 ASSERT_EQ(CONTENT_SETTING_ASK,
1275 PermissionManager::Get(otr_profile) 1279 PermissionManager::Get(otr_profile)
1276 ->GetPermissionStatus(CONTENT_SETTINGS_TYPE_GEOLOCATION, 1280 ->GetPermissionStatusForFrame(CONTENT_SETTINGS_TYPE_GEOLOCATION,
1277 requesting_frame, requesting_frame) 1281 main_rfh(), requesting_frame)
1278 .content_setting); 1282 .content_setting);
1279 1283
1280 // Changing the setting to BLOCK should flow through to incognito. 1284 // Changing the setting to BLOCK should flow through to incognito.
1281 geo_service->SetDSEGeolocationSetting(false); 1285 geo_service->SetDSEGeolocationSetting(false);
1282 ASSERT_EQ(CONTENT_SETTING_BLOCK, 1286 ASSERT_EQ(CONTENT_SETTING_BLOCK,
1283 PermissionManager::Get(otr_profile) 1287 PermissionManager::Get(otr_profile)
1284 ->GetPermissionStatus(CONTENT_SETTINGS_TYPE_GEOLOCATION, 1288 ->GetPermissionStatusForFrame(CONTENT_SETTINGS_TYPE_GEOLOCATION,
1285 requesting_frame, requesting_frame) 1289 main_rfh(), requesting_frame)
1286 .content_setting); 1290 .content_setting);
1287 } 1291 }
1288 1292
1289 TEST_P(GeolocationPermissionContextTests, 1293 TEST_P(GeolocationPermissionContextTests,
1290 GeolocationStatusAndroidDisabledLegacy) { 1294 GeolocationStatusAndroidDisabledLegacy) {
1291 GURL requesting_frame("https://www.example.com/geolocation"); 1295 GURL requesting_frame("https://www.example.com/geolocation");
1296 NavigateAndCommit(requesting_frame);
1292 1297
1293 // In these tests the Android permission status should not be taken into 1298 // In these tests the Android permission status should not be taken into
1294 // account, only the content setting. 1299 // account, only the content setting.
1295 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1300 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1296 CONTENT_SETTING_ALLOW); 1301 CONTENT_SETTING_ALLOW);
1297 MockLocationSettings::SetLocationStatus(false /* android */, 1302 MockLocationSettings::SetLocationStatus(false /* android */,
1298 true /* system */); 1303 true /* system */);
1299 ASSERT_EQ(blink::mojom::PermissionStatus::GRANTED, 1304 ASSERT_EQ(
1300 PermissionManager::Get(profile())->GetPermissionStatus( 1305 blink::mojom::PermissionStatus::GRANTED,
1301 content::PermissionType::GEOLOCATION, requesting_frame, 1306 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1302 requesting_frame)); 1307 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1303 1308
1304 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1309 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1305 CONTENT_SETTING_ASK); 1310 CONTENT_SETTING_ASK);
1306 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 1311 ASSERT_EQ(
1307 PermissionManager::Get(profile())->GetPermissionStatus( 1312 blink::mojom::PermissionStatus::ASK,
1308 content::PermissionType::GEOLOCATION, requesting_frame, 1313 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1309 requesting_frame)); 1314 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1310 1315
1311 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1316 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1312 CONTENT_SETTING_BLOCK); 1317 CONTENT_SETTING_BLOCK);
1313 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 1318 ASSERT_EQ(
1314 PermissionManager::Get(profile())->GetPermissionStatus( 1319 blink::mojom::PermissionStatus::DENIED,
1315 content::PermissionType::GEOLOCATION, requesting_frame, 1320 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1316 requesting_frame)); 1321 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1317 } 1322 }
1318 1323
1319 TEST_P(GeolocationPermissionContextTests, GeolocationStatusAndroidDisabled) { 1324 TEST_P(GeolocationPermissionContextTests, GeolocationStatusAndroidDisabled) {
1320 base::test::ScopedFeatureList scoped_feature_list; 1325 base::test::ScopedFeatureList scoped_feature_list;
1321 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt); 1326 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt);
1322 1327
1323 GURL requesting_frame("https://www.example.com/geolocation"); 1328 GURL requesting_frame("https://www.example.com/geolocation");
1329 NavigateAndCommit(requesting_frame);
1324 1330
1325 // With the Android permission off, but location allowed for a domain, the 1331 // With the Android permission off, but location allowed for a domain, the
1326 // permission status should be ASK. 1332 // permission status should be ASK.
1327 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1333 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1328 CONTENT_SETTING_ALLOW); 1334 CONTENT_SETTING_ALLOW);
1329 MockLocationSettings::SetLocationStatus(false /* android */, 1335 MockLocationSettings::SetLocationStatus(false /* android */,
1330 true /* system */); 1336 true /* system */);
1331 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 1337 ASSERT_EQ(
1332 PermissionManager::Get(profile())->GetPermissionStatus( 1338 blink::mojom::PermissionStatus::ASK,
1333 content::PermissionType::GEOLOCATION, requesting_frame, 1339 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1334 requesting_frame)); 1340 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1335 1341
1336 // With the Android permission off, and location blocked for a domain, the 1342 // With the Android permission off, and location blocked for a domain, the
1337 // permission status should still be BLOCK. 1343 // permission status should still be BLOCK.
1338 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1344 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1339 CONTENT_SETTING_BLOCK); 1345 CONTENT_SETTING_BLOCK);
1340 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 1346 ASSERT_EQ(
1341 PermissionManager::Get(profile())->GetPermissionStatus( 1347 blink::mojom::PermissionStatus::DENIED,
1342 content::PermissionType::GEOLOCATION, requesting_frame, 1348 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1343 requesting_frame)); 1349 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1344 1350
1345 // With the Android permission off, and location prompt for a domain, the 1351 // With the Android permission off, and location prompt for a domain, the
1346 // permission status should still be ASK. 1352 // permission status should still be ASK.
1347 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1353 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1348 CONTENT_SETTING_ASK); 1354 CONTENT_SETTING_ASK);
1349 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 1355 ASSERT_EQ(
1350 PermissionManager::Get(profile())->GetPermissionStatus( 1356 blink::mojom::PermissionStatus::ASK,
1351 content::PermissionType::GEOLOCATION, requesting_frame, 1357 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1352 requesting_frame)); 1358 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1353 } 1359 }
1354 1360
1355 TEST_P(GeolocationPermissionContextTests, 1361 TEST_P(GeolocationPermissionContextTests,
1356 GeolocationStatusSystemDisabledLegacy) { 1362 GeolocationStatusSystemDisabledLegacy) {
1357 GURL requesting_frame("https://www.example.com/geolocation"); 1363 GURL requesting_frame("https://www.example.com/geolocation");
1364 NavigateAndCommit(requesting_frame);
1358 1365
1359 // In these tests the system permission status should not be taken into 1366 // In these tests the system permission status should not be taken into
1360 // account, only the content setting. 1367 // account, only the content setting.
1361 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1368 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1362 CONTENT_SETTING_ALLOW); 1369 CONTENT_SETTING_ALLOW);
1363 MockLocationSettings::SetLocationStatus(true /* android */, 1370 MockLocationSettings::SetLocationStatus(true /* android */,
1364 false /* system */); 1371 false /* system */);
1365 ASSERT_EQ(blink::mojom::PermissionStatus::GRANTED, 1372 ASSERT_EQ(
1366 PermissionManager::Get(profile())->GetPermissionStatus( 1373 blink::mojom::PermissionStatus::GRANTED,
1367 content::PermissionType::GEOLOCATION, requesting_frame, 1374 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1368 requesting_frame)); 1375 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1369 1376
1370 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1377 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1371 CONTENT_SETTING_ASK); 1378 CONTENT_SETTING_ASK);
1372 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 1379 ASSERT_EQ(
1373 PermissionManager::Get(profile())->GetPermissionStatus( 1380 blink::mojom::PermissionStatus::ASK,
1374 content::PermissionType::GEOLOCATION, requesting_frame, 1381 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1375 requesting_frame)); 1382 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1376 1383
1377 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1384 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1378 CONTENT_SETTING_BLOCK); 1385 CONTENT_SETTING_BLOCK);
1379 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 1386 ASSERT_EQ(
1380 PermissionManager::Get(profile())->GetPermissionStatus( 1387 blink::mojom::PermissionStatus::DENIED,
1381 content::PermissionType::GEOLOCATION, requesting_frame, 1388 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1382 requesting_frame)); 1389 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1383 } 1390 }
1384 1391
1385 TEST_P(GeolocationPermissionContextTests, GeolocationStatusSystemDisabled) { 1392 TEST_P(GeolocationPermissionContextTests, GeolocationStatusSystemDisabled) {
1386 base::test::ScopedFeatureList scoped_feature_list; 1393 base::test::ScopedFeatureList scoped_feature_list;
1387 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt); 1394 EnableFeature(&scoped_feature_list, features::kLsdPermissionPrompt);
1388 1395
1389 GURL requesting_frame("https://www.example.com/geolocation"); 1396 GURL requesting_frame("https://www.example.com/geolocation");
1397 NavigateAndCommit(requesting_frame);
1390 1398
1391 // With the system permission off, but location allowed for a domain, the 1399 // With the system permission off, but location allowed for a domain, the
1392 // permission status should be reflect whether the LSD can be shown. 1400 // permission status should be reflect whether the LSD can be shown.
1393 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1401 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1394 CONTENT_SETTING_ALLOW); 1402 CONTENT_SETTING_ALLOW);
1395 MockLocationSettings::SetLocationStatus(true /* android */, 1403 MockLocationSettings::SetLocationStatus(true /* android */,
1396 false /* system */); 1404 false /* system */);
1397 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */, 1405 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
1398 DENIED); 1406 DENIED);
1399 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 1407 ASSERT_EQ(
1400 PermissionManager::Get(profile())->GetPermissionStatus( 1408 blink::mojom::PermissionStatus::ASK,
1401 content::PermissionType::GEOLOCATION, requesting_frame, 1409 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1402 requesting_frame)); 1410 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1403 1411
1404 MockLocationSettings::SetLocationSettingsDialogStatus(false /* enabled */, 1412 MockLocationSettings::SetLocationSettingsDialogStatus(false /* enabled */,
1405 GRANTED); 1413 GRANTED);
1406 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 1414 ASSERT_EQ(
1407 PermissionManager::Get(profile())->GetPermissionStatus( 1415 blink::mojom::PermissionStatus::DENIED,
1408 content::PermissionType::GEOLOCATION, requesting_frame, 1416 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1409 requesting_frame)); 1417 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1410 1418
1411 // The result should be the same if the location permission is ASK. 1419 // The result should be the same if the location permission is ASK.
1412 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1420 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1413 CONTENT_SETTING_ASK); 1421 CONTENT_SETTING_ASK);
1414 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */, 1422 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
1415 GRANTED); 1423 GRANTED);
1416 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 1424 ASSERT_EQ(
1417 PermissionManager::Get(profile())->GetPermissionStatus( 1425 blink::mojom::PermissionStatus::ASK,
1418 content::PermissionType::GEOLOCATION, requesting_frame, 1426 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1419 requesting_frame)); 1427 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1420 1428
1421 MockLocationSettings::SetLocationSettingsDialogStatus(false /* enabled */, 1429 MockLocationSettings::SetLocationSettingsDialogStatus(false /* enabled */,
1422 GRANTED); 1430 GRANTED);
1423 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 1431 ASSERT_EQ(
1424 PermissionManager::Get(profile())->GetPermissionStatus( 1432 blink::mojom::PermissionStatus::DENIED,
1425 content::PermissionType::GEOLOCATION, requesting_frame, 1433 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1426 requesting_frame)); 1434 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1427 1435
1428 // With the Android permission off, and location blocked for a domain, the 1436 // With the Android permission off, and location blocked for a domain, the
1429 // permission status should still be BLOCK. 1437 // permission status should still be BLOCK.
1430 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1438 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1431 CONTENT_SETTING_BLOCK); 1439 CONTENT_SETTING_BLOCK);
1432 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */, 1440 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
1433 GRANTED); 1441 GRANTED);
1434 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 1442 ASSERT_EQ(
1435 PermissionManager::Get(profile())->GetPermissionStatus( 1443 blink::mojom::PermissionStatus::DENIED,
1436 content::PermissionType::GEOLOCATION, requesting_frame, 1444 PermissionManager::Get(profile())->GetPermissionStatusForFrame(
1437 requesting_frame)); 1445 content::PermissionType::GEOLOCATION, main_rfh(), requesting_frame));
1438 } 1446 }
1439 #endif // defined(OS_ANDROID) 1447 #endif // defined(OS_ANDROID)
1440 1448
1441 #if defined(OS_ANDROID) 1449 #if defined(OS_ANDROID)
1442 INSTANTIATE_TEST_CASE_P( 1450 INSTANTIATE_TEST_CASE_P(
1443 GeolocationPermissionContextTestsInstance, 1451 GeolocationPermissionContextTestsInstance,
1444 GeolocationPermissionContextTests, 1452 GeolocationPermissionContextTests,
1445 ::testing::Values(TestType::PERMISSION_REQUEST_MANAGER, 1453 ::testing::Values(TestType::PERMISSION_REQUEST_MANAGER,
1446 TestType::PERMISSION_QUEUE_CONTROLLER)); 1454 TestType::PERMISSION_QUEUE_CONTROLLER));
1447 #else 1455 #else
1448 INSTANTIATE_TEST_CASE_P( 1456 INSTANTIATE_TEST_CASE_P(
1449 GeolocationPermissionContextTestsInstance, 1457 GeolocationPermissionContextTestsInstance,
1450 GeolocationPermissionContextTests, 1458 GeolocationPermissionContextTests,
1451 ::testing::Values(TestType::PERMISSION_REQUEST_MANAGER)); 1459 ::testing::Values(TestType::PERMISSION_REQUEST_MANAGER));
1452 #endif 1460 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698