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

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

Issue 2742373003: Limit the amount the Location Settings Dialog will be shown to users. (Closed)
Patch Set: Woops, missed one Created 3 years, 9 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 void AddNewTab(const GURL& url); 173 void AddNewTab(const GURL& url);
174 void CheckTabContentsState(const GURL& requesting_frame, 174 void CheckTabContentsState(const GURL& requesting_frame,
175 ContentSetting expected_content_setting); 175 ContentSetting expected_content_setting);
176 #if !defined(OS_ANDROID) 176 #if !defined(OS_ANDROID)
177 void SetupRequestManager(content::WebContents* web_contents); 177 void SetupRequestManager(content::WebContents* web_contents);
178 size_t GetBubblesQueueSize(PermissionRequestManager* manager); 178 size_t GetBubblesQueueSize(PermissionRequestManager* manager);
179 void AcceptBubble(PermissionRequestManager* manager); 179 void AcceptBubble(PermissionRequestManager* manager);
180 void DenyBubble(PermissionRequestManager* manager); 180 void DenyBubble(PermissionRequestManager* manager);
181 void CloseBubble(PermissionRequestManager* manager); 181 void CloseBubble(PermissionRequestManager* manager);
182 #endif 182 #endif
183 #if defined(OS_ANDROID)
184 bool RequestPermissionIsLSDShown(const GURL& origin);
185 bool RequestPermissionIsLSDShownWithPermissionPrompt(const GURL& origin);
186 void AddDayOffsetForTesting(int days);
187 void SetDSEOriginForTesting(const char* dse_origin);
188 #endif
183 void RequestManagerDocumentLoadCompleted(); 189 void RequestManagerDocumentLoadCompleted();
184 void RequestManagerDocumentLoadCompleted(content::WebContents* web_contents); 190 void RequestManagerDocumentLoadCompleted(content::WebContents* web_contents);
185 ContentSetting GetGeolocationContentSetting(GURL frame_0, GURL frame_1); 191 ContentSetting GetGeolocationContentSetting(GURL frame_0, GURL frame_1);
186 void SetGeolocationContentSetting(GURL frame_0, 192 void SetGeolocationContentSetting(GURL frame_0,
187 GURL frame_1, 193 GURL frame_1,
188 ContentSetting content_setting); 194 ContentSetting content_setting);
189 size_t GetNumberOfPrompts(); 195 size_t GetNumberOfPrompts();
190 void AcceptPrompt(); 196 void AcceptPrompt();
191 base::string16 GetPromptText(); 197 base::string16 GetPromptText();
192 198
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 PermissionRequestManager* manager) { 372 PermissionRequestManager* manager) {
367 manager->Deny(); 373 manager->Deny();
368 } 374 }
369 375
370 void GeolocationPermissionContextTests::CloseBubble( 376 void GeolocationPermissionContextTests::CloseBubble(
371 PermissionRequestManager* manager) { 377 PermissionRequestManager* manager) {
372 manager->Closing(); 378 manager->Closing();
373 } 379 }
374 #endif 380 #endif
375 381
382 #if defined(OS_ANDROID)
383 bool GeolocationPermissionContextTests::RequestPermissionIsLSDShown(
384 const GURL& origin) {
385 NavigateAndCommit(origin);
386 MockLocationSettings::ClearHasShownLocationSettingsDialog();
387 RequestGeolocationPermission(web_contents(), RequestID(0), origin, true);
388
389 return MockLocationSettings::HasShownLocationSettingsDialog();
390 }
391
392 bool GeolocationPermissionContextTests::
393 RequestPermissionIsLSDShownWithPermissionPrompt(const GURL& origin) {
394 NavigateAndCommit(origin);
395 MockLocationSettings::ClearHasShownLocationSettingsDialog();
396 RequestGeolocationPermission(web_contents(), RequestID(0), origin, true);
397
398 EXPECT_EQ(1U, infobar_service()->infobar_count());
399 ConfirmInfoBarDelegate* infobar_delegate =
400 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate();
401 EXPECT_TRUE(infobar_delegate);
402 infobar_delegate->Accept();
403
404 return MockLocationSettings::HasShownLocationSettingsDialog();
405 }
406
407 void GeolocationPermissionContextTests::AddDayOffsetForTesting(int days) {
408 GeolocationPermissionContextAndroid::AddDayOffsetForTesting(days);
409 }
410
411 void GeolocationPermissionContextTests::SetDSEOriginForTesting(
412 const char* dse_origin) {
413 GeolocationPermissionContextAndroid::SetDSEOriginForTesting(dse_origin);
414 }
415 #endif
416
376 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted() { 417 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted() {
377 GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted( 418 GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted(
378 web_contents()); 419 web_contents());
379 } 420 }
380 421
381 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted( 422 void GeolocationPermissionContextTests::RequestManagerDocumentLoadCompleted(
382 content::WebContents* web_contents) { 423 content::WebContents* web_contents) {
383 #if !defined(OS_ANDROID) 424 #if !defined(OS_ANDROID)
384 PermissionRequestManager::FromWebContents(web_contents)-> 425 PermissionRequestManager::FromWebContents(web_contents)->
385 DocumentOnLoadCompletedInMainFrame(); 426 DocumentOnLoadCompletedInMainFrame();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 } 617 }
577 618
578 TEST_F(GeolocationPermissionContextTests, SystemLocationOffLSDAccept) { 619 TEST_F(GeolocationPermissionContextTests, SystemLocationOffLSDAccept) {
579 base::test::ScopedFeatureList scoped_feature_list; 620 base::test::ScopedFeatureList scoped_feature_list;
580 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt); 621 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt);
581 622
582 GURL requesting_frame("https://www.example.com/geolocation"); 623 GURL requesting_frame("https://www.example.com/geolocation");
583 NavigateAndCommit(requesting_frame); 624 NavigateAndCommit(requesting_frame);
584 MockLocationSettings::SetLocationStatus(true /* android */, 625 MockLocationSettings::SetLocationStatus(true /* android */,
585 false /* system */); 626 false /* system */);
586 MockLocationSettings::SetLocationSettingsDialogStatus(true, GRANTED); 627 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
628 GRANTED);
587 EXPECT_EQ(0U, infobar_service()->infobar_count()); 629 EXPECT_EQ(0U, infobar_service()->infobar_count());
588 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame, 630 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame,
589 true); 631 true);
590 EXPECT_EQ(1U, infobar_service()->infobar_count()); 632 EXPECT_EQ(1U, infobar_service()->infobar_count());
591 ConfirmInfoBarDelegate* infobar_delegate = 633 ConfirmInfoBarDelegate* infobar_delegate =
592 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); 634 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate();
593 ASSERT_TRUE(infobar_delegate); 635 ASSERT_TRUE(infobar_delegate);
594 infobar_delegate->Accept(); 636 infobar_delegate->Accept();
595 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); 637 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW);
596 CheckPermissionMessageSent(0, true); 638 CheckPermissionMessageSent(0, true);
597 EXPECT_TRUE(MockLocationSettings::HasShownLocationSettingsDialog()); 639 EXPECT_TRUE(MockLocationSettings::HasShownLocationSettingsDialog());
598 } 640 }
599 641
600 TEST_F(GeolocationPermissionContextTests, SystemLocationOffLSDReject) { 642 TEST_F(GeolocationPermissionContextTests, SystemLocationOffLSDReject) {
601 base::test::ScopedFeatureList scoped_feature_list; 643 base::test::ScopedFeatureList scoped_feature_list;
602 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt); 644 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt);
603 645
604 GURL requesting_frame("https://www.example.com/geolocation"); 646 GURL requesting_frame("https://www.example.com/geolocation");
605 NavigateAndCommit(requesting_frame); 647 NavigateAndCommit(requesting_frame);
606 MockLocationSettings::SetLocationStatus(true /* android */, 648 MockLocationSettings::SetLocationStatus(true /* android */,
607 false /* system */); 649 false /* system */);
608 MockLocationSettings::SetLocationSettingsDialogStatus(true, DENIED); 650 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
651 DENIED);
609 EXPECT_EQ(0U, infobar_service()->infobar_count()); 652 EXPECT_EQ(0U, infobar_service()->infobar_count());
610 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame, 653 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame,
611 true); 654 true);
612 EXPECT_EQ(1U, infobar_service()->infobar_count()); 655 EXPECT_EQ(1U, infobar_service()->infobar_count());
613 ConfirmInfoBarDelegate* infobar_delegate = 656 ConfirmInfoBarDelegate* infobar_delegate =
614 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); 657 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate();
615 ASSERT_TRUE(infobar_delegate); 658 ASSERT_TRUE(infobar_delegate);
616 infobar_delegate->Accept(); 659 infobar_delegate->Accept();
617 CheckTabContentsState(requesting_frame, CONTENT_SETTING_BLOCK); 660 CheckTabContentsState(requesting_frame, CONTENT_SETTING_BLOCK);
618 CheckPermissionMessageSent(0, false); 661 CheckPermissionMessageSent(0, false);
619 EXPECT_TRUE(MockLocationSettings::HasShownLocationSettingsDialog()); 662 EXPECT_TRUE(MockLocationSettings::HasShownLocationSettingsDialog());
620 } 663 }
664
665 TEST_F(GeolocationPermissionContextTests, LSDBackOffDifferentSites) {
666 base::test::ScopedFeatureList scoped_feature_list;
667 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt);
668
669 GURL requesting_frame_1("https://www.example.com/geolocation");
670 GURL requesting_frame_2("https://www.example-2.com/geolocation");
671 const char* requesting_frame_dse_ptr = "https://www.dse.com/geolocation";
672 GURL requesting_frame_dse(requesting_frame_dse_ptr);
673
674 SetDSEOriginForTesting(requesting_frame_dse_ptr);
675
676 // Set all origin geolocation permissions to ALLOW.
677 SetGeolocationContentSetting(requesting_frame_1, requesting_frame_1,
678 CONTENT_SETTING_ALLOW);
679 SetGeolocationContentSetting(requesting_frame_2, requesting_frame_2,
680 CONTENT_SETTING_ALLOW);
681 SetGeolocationContentSetting(requesting_frame_dse, requesting_frame_dse,
682 CONTENT_SETTING_ALLOW);
683
684 // Turn off system location but allow the LSD to be shown, and denied.
685 MockLocationSettings::SetLocationStatus(true /* android */,
686 false /* system */);
687 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
688 DENIED);
689
690 // Now permission requests should trigger the LSD, but the LSD will be denied,
691 // putting the requesting origins into backoff. Check that the two non-DSE
692 // origins share the same backoff, which is distinct to the DSE origin.
693 // First, cancel a LSD prompt on the first non-DSE origin to go into backoff.
694 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame_1));
695
696 // Now check that the LSD is prevented on this origin.
697 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame_1));
698
699 // Now ask on the other non-DSE origin and check backoff prevented the prompt.
700 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame_2));
701
702 // Now request on the DSE and check that the LSD is shown, as the non-DSE
703 // backoff should not apply.
704 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame_dse));
705
706 // Now check that the DSE is in backoff.
707 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame_dse));
708 }
709
710 TEST_F(GeolocationPermissionContextTests, LSDBackOffTiming) {
711 base::test::ScopedFeatureList scoped_feature_list;
712 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt);
713
714 GURL requesting_frame("https://www.example.com/geolocation");
715 SetGeolocationContentSetting(requesting_frame, requesting_frame,
716 CONTENT_SETTING_ALLOW);
717
718 // Turn off system location but allow the LSD to be shown, and denied.
719 MockLocationSettings::SetLocationStatus(true /* android */,
720 false /* system */);
721 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
722 DENIED);
723
724 // First, cancel a LSD prompt on the first non-DSE origin to go into backoff.
725 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
726 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
727
728 // Check the LSD is prevented in 6 days time.
729 AddDayOffsetForTesting(6);
730 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
731
732 // Check it is shown in one more days time, but then not straight after..
733 AddDayOffsetForTesting(1);
734 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
735 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
736
737 // Check that it isn't shown 29 days after that.
738 AddDayOffsetForTesting(29);
739 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
740
741 // Check it is shown in one more days time, but then not straight after..
742 AddDayOffsetForTesting(1);
743 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
744 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
745
746 // Check that it isn't shown 89 days after that.
747 AddDayOffsetForTesting(89);
748 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
749
750 // Check it is shown in one more days time, but then not straight after..
751 AddDayOffsetForTesting(1);
752 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
753 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
754
755 // Check that it isn't shown 89 days after that.
756 AddDayOffsetForTesting(89);
757 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
758
759 // Check it is shown in one more days time, but then not straight after..
760 AddDayOffsetForTesting(1);
761 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
762 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
763 }
764
765 TEST_F(GeolocationPermissionContextTests, LSDBackOffPermissionStatus) {
766 base::test::ScopedFeatureList scoped_feature_list;
767 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt);
768
769 GURL requesting_frame("https://www.example.com/geolocation");
770 SetGeolocationContentSetting(requesting_frame, requesting_frame,
771 CONTENT_SETTING_ALLOW);
772
773 // Turn off system location but allow the LSD to be shown, and denied.
774 MockLocationSettings::SetLocationStatus(true /* android */,
775 false /* system */);
776 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
777 DENIED);
778
779 // The permission status should reflect that the LSD will be shown.
780 ASSERT_EQ(blink::mojom::PermissionStatus::ASK,
781 PermissionManager::Get(profile())->GetPermissionStatus(
782 content::PermissionType::GEOLOCATION, requesting_frame,
783 requesting_frame));
784 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
785
786 // Now that the LSD is in backoff, the permission status should reflect it.
787 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
788 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED,
789 PermissionManager::Get(profile())->GetPermissionStatus(
790 content::PermissionType::GEOLOCATION, requesting_frame,
791 requesting_frame));
792 }
793
794 TEST_F(GeolocationPermissionContextTests, LSDBackOffAskPromptsDespiteBackOff) {
795 base::test::ScopedFeatureList scoped_feature_list;
796 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt);
797
798 GURL requesting_frame("https://www.example.com/geolocation");
799 SetGeolocationContentSetting(requesting_frame, requesting_frame,
800 CONTENT_SETTING_ALLOW);
801
802 // Turn off system location but allow the LSD to be shown, and denied.
803 MockLocationSettings::SetLocationStatus(true /* android */,
804 false /* system */);
805 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
806 DENIED);
807
808 // First, cancel a LSD prompt on the first non-DSE origin to go into backoff.
809 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
810 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
811
812 // Set the content setting back to ASK. The permission status should be
813 // prompt, and the LSD prompt should now be shown.
814 SetGeolocationContentSetting(requesting_frame, requesting_frame,
815 CONTENT_SETTING_ASK);
816 ASSERT_EQ(blink::mojom::PermissionStatus::ASK,
817 PermissionManager::Get(profile())->GetPermissionStatus(
818 content::PermissionType::GEOLOCATION, requesting_frame,
819 requesting_frame));
820 EXPECT_TRUE(
821 RequestPermissionIsLSDShownWithPermissionPrompt(requesting_frame));
822 }
823
824 TEST_F(GeolocationPermissionContextTests,
825 LSDBackOffAcceptPermissionResetsBackOff) {
826 base::test::ScopedFeatureList scoped_feature_list;
827 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt);
828
829 GURL requesting_frame("https://www.example.com/geolocation");
830 SetGeolocationContentSetting(requesting_frame, requesting_frame,
831 CONTENT_SETTING_ALLOW);
832
833 // Turn off system location but allow the LSD to be shown, and denied.
834 MockLocationSettings::SetLocationStatus(true /* android */,
835 false /* system */);
836 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
837 DENIED);
838
839 // First, get into the highest backoff state.
840 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
841 AddDayOffsetForTesting(7);
842 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
843 AddDayOffsetForTesting(30);
844 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
845 AddDayOffsetForTesting(90);
846 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
847
848 // Now accept a permissions prompt.
849 SetGeolocationContentSetting(requesting_frame, requesting_frame,
850 CONTENT_SETTING_ASK);
851 EXPECT_TRUE(
852 RequestPermissionIsLSDShownWithPermissionPrompt(requesting_frame));
853
854 // And check that back in the lowest backoff state.
855 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
856 AddDayOffsetForTesting(7);
857 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
858 }
859
860 TEST_F(GeolocationPermissionContextTests, LSDBackOffAcceptLSDResetsBackOff) {
861 base::test::ScopedFeatureList scoped_feature_list;
862 scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt);
863
864 GURL requesting_frame("https://www.example.com/geolocation");
865 SetGeolocationContentSetting(requesting_frame, requesting_frame,
866 CONTENT_SETTING_ALLOW);
867
868 // Turn off system location but allow the LSD to be shown, and denied.
869 MockLocationSettings::SetLocationStatus(true /* android */,
870 false /* system */);
871 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
872 DENIED);
873
874 // First, get into the highest backoff state.
875 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
876 AddDayOffsetForTesting(7);
877 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
878 AddDayOffsetForTesting(30);
879 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
880
881 // Now accept the LSD.
882 AddDayOffsetForTesting(90);
883 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
884 GRANTED);
885 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
886
887 // Check that not in backoff, and that at the lowest backoff state.
888 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
889 DENIED);
890 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
891 EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame));
892 AddDayOffsetForTesting(7);
893 EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame));
894 }
621 #endif 895 #endif
622 896
623 TEST_F(GeolocationPermissionContextTests, QueuedPermission) { 897 TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
624 GURL requesting_frame_0("https://www.example.com/geolocation"); 898 GURL requesting_frame_0("https://www.example.com/geolocation");
625 GURL requesting_frame_1("https://www.example-2.com/geolocation"); 899 GURL requesting_frame_1("https://www.example-2.com/geolocation");
626 EXPECT_EQ( 900 EXPECT_EQ(
627 CONTENT_SETTING_ASK, 901 CONTENT_SETTING_ASK,
628 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_1)); 902 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_1));
629 EXPECT_EQ( 903 EXPECT_EQ(
630 CONTENT_SETTING_ASK, 904 CONTENT_SETTING_ASK,
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 // permission status should be reflect whether the LSD can be shown. 1406 // permission status should be reflect whether the LSD can be shown.
1133 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1407 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1134 CONTENT_SETTING_ALLOW); 1408 CONTENT_SETTING_ALLOW);
1135 MockLocationSettings::SetLocationStatus(true /* android */, 1409 MockLocationSettings::SetLocationStatus(true /* android */,
1136 false /* system */); 1410 false /* system */);
1137 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 1411 ASSERT_EQ(blink::mojom::PermissionStatus::ASK,
1138 PermissionManager::Get(profile())->GetPermissionStatus( 1412 PermissionManager::Get(profile())->GetPermissionStatus(
1139 content::PermissionType::GEOLOCATION, requesting_frame, 1413 content::PermissionType::GEOLOCATION, requesting_frame,
1140 requesting_frame)); 1414 requesting_frame));
1141 1415
1142 MockLocationSettings::SetLocationSettingsDialogStatus(false, GRANTED); 1416 MockLocationSettings::SetLocationSettingsDialogStatus(false /* enabled */,
1417 GRANTED);
1143 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 1418 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED,
1144 PermissionManager::Get(profile())->GetPermissionStatus( 1419 PermissionManager::Get(profile())->GetPermissionStatus(
1145 content::PermissionType::GEOLOCATION, requesting_frame, 1420 content::PermissionType::GEOLOCATION, requesting_frame,
1146 requesting_frame)); 1421 requesting_frame));
1147 1422
1148 // The result should be the same if the location permission is ASK. 1423 // The result should be the same if the location permission is ASK.
1149 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1424 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1150 CONTENT_SETTING_ASK); 1425 CONTENT_SETTING_ASK);
1151 MockLocationSettings::SetLocationSettingsDialogStatus(true, GRANTED); 1426 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
1427 GRANTED);
1152 ASSERT_EQ(blink::mojom::PermissionStatus::ASK, 1428 ASSERT_EQ(blink::mojom::PermissionStatus::ASK,
1153 PermissionManager::Get(profile())->GetPermissionStatus( 1429 PermissionManager::Get(profile())->GetPermissionStatus(
1154 content::PermissionType::GEOLOCATION, requesting_frame, 1430 content::PermissionType::GEOLOCATION, requesting_frame,
1155 requesting_frame)); 1431 requesting_frame));
1156 1432
1157 MockLocationSettings::SetLocationSettingsDialogStatus(false, GRANTED); 1433 MockLocationSettings::SetLocationSettingsDialogStatus(false /* enabled */,
1434 GRANTED);
1158 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 1435 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED,
1159 PermissionManager::Get(profile())->GetPermissionStatus( 1436 PermissionManager::Get(profile())->GetPermissionStatus(
1160 content::PermissionType::GEOLOCATION, requesting_frame, 1437 content::PermissionType::GEOLOCATION, requesting_frame,
1161 requesting_frame)); 1438 requesting_frame));
1162 1439
1163 // With the Android permission off, and location blocked for a domain, the 1440 // With the Android permission off, and location blocked for a domain, the
1164 // permission status should still be BLOCK. 1441 // permission status should still be BLOCK.
1165 SetGeolocationContentSetting(requesting_frame, requesting_frame, 1442 SetGeolocationContentSetting(requesting_frame, requesting_frame,
1166 CONTENT_SETTING_BLOCK); 1443 CONTENT_SETTING_BLOCK);
1167 MockLocationSettings::SetLocationSettingsDialogStatus(true, GRANTED); 1444 MockLocationSettings::SetLocationSettingsDialogStatus(true /* enabled */,
1445 GRANTED);
1168 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED, 1446 ASSERT_EQ(blink::mojom::PermissionStatus::DENIED,
1169 PermissionManager::Get(profile())->GetPermissionStatus( 1447 PermissionManager::Get(profile())->GetPermissionStatus(
1170 content::PermissionType::GEOLOCATION, requesting_frame, 1448 content::PermissionType::GEOLOCATION, requesting_frame,
1171 requesting_frame)); 1449 requesting_frame));
1172 } 1450 }
1173 #endif // defined(OS_ANDROID) 1451 #endif // defined(OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698