| OLD | NEW |
| 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 378 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
| 379 ConfirmInfoBarDelegate* infobar_delegate = | 379 ConfirmInfoBarDelegate* infobar_delegate = |
| 380 infobar->delegate()->AsConfirmInfoBarDelegate(); | 380 infobar->delegate()->AsConfirmInfoBarDelegate(); |
| 381 return infobar_delegate->GetMessageText(); | 381 return infobar_delegate->GetMessageText(); |
| 382 #endif | 382 #endif |
| 383 } | 383 } |
| 384 | 384 |
| 385 // Tests ---------------------------------------------------------------------- | 385 // Tests ---------------------------------------------------------------------- |
| 386 | 386 |
| 387 TEST_F(GeolocationPermissionContextTests, SinglePermissionBubble) { | 387 TEST_F(GeolocationPermissionContextTests, SinglePermissionBubble) { |
| 388 GURL requesting_frame("http://www.example.com/geolocation"); | 388 GURL requesting_frame("https://www.example.com/geolocation"); |
| 389 NavigateAndCommit(requesting_frame); | 389 NavigateAndCommit(requesting_frame); |
| 390 BubbleManagerDocumentLoadCompleted(); | 390 BubbleManagerDocumentLoadCompleted(); |
| 391 | 391 |
| 392 EXPECT_EQ(0U, GetNumberOfPrompts()); | 392 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 393 RequestGeolocationPermission( | 393 RequestGeolocationPermission( |
| 394 web_contents(), RequestID(0), requesting_frame, true); | 394 web_contents(), RequestID(0), requesting_frame, true); |
| 395 ASSERT_EQ(1U, GetNumberOfPrompts()); | 395 ASSERT_EQ(1U, GetNumberOfPrompts()); |
| 396 } | 396 } |
| 397 | 397 |
| 398 TEST_F(GeolocationPermissionContextTests, |
| 399 SinglePermissionBubbleFailsOnInsecureOrigin) { |
| 400 GURL requesting_frame("http://www.example.com/geolocation"); |
| 401 NavigateAndCommit(requesting_frame); |
| 402 BubbleManagerDocumentLoadCompleted(); |
| 403 |
| 404 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 405 RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame, |
| 406 true); |
| 407 ASSERT_EQ(0U, GetNumberOfPrompts()); |
| 408 } |
| 409 |
| 398 #if BUILDFLAG(ANDROID_JAVA_UI) | 410 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 399 TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) { | 411 TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) { |
| 400 GURL requesting_frame("http://www.example.com/geolocation"); | 412 GURL requesting_frame("https://www.example.com/geolocation"); |
| 401 NavigateAndCommit(requesting_frame); | 413 NavigateAndCommit(requesting_frame); |
| 402 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 414 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 403 RequestGeolocationPermission( | 415 RequestGeolocationPermission( |
| 404 web_contents(), RequestID(0), requesting_frame, true); | 416 web_contents(), RequestID(0), requesting_frame, true); |
| 405 ASSERT_EQ(1U, infobar_service()->infobar_count()); | 417 ASSERT_EQ(1U, infobar_service()->infobar_count()); |
| 406 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); | 418 infobars::InfoBar* infobar = infobar_service()->infobar_at(0); |
| 407 ConfirmInfoBarDelegate* infobar_delegate = | 419 ConfirmInfoBarDelegate* infobar_delegate = |
| 408 infobar->delegate()->AsConfirmInfoBarDelegate(); | 420 infobar->delegate()->AsConfirmInfoBarDelegate(); |
| 409 ASSERT_TRUE(infobar_delegate); | 421 ASSERT_TRUE(infobar_delegate); |
| 410 infobar_delegate->Cancel(); | 422 infobar_delegate->Cancel(); |
| 411 infobar_service()->RemoveInfoBar(infobar); | 423 infobar_service()->RemoveInfoBar(infobar); |
| 412 EXPECT_EQ(1U, closed_infobar_tracker_.size()); | 424 EXPECT_EQ(1U, closed_infobar_tracker_.size()); |
| 413 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar)); | 425 EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar)); |
| 414 } | 426 } |
| 415 | 427 |
| 416 // Infobar-only tests; Android doesn't support permission bubbles. | 428 // Infobar-only tests; Android doesn't support permission bubbles. |
| 417 TEST_F(GeolocationPermissionContextTests, GeolocationEnabledDisabled) { | 429 TEST_F(GeolocationPermissionContextTests, GeolocationEnabledDisabled) { |
| 418 GURL requesting_frame("http://www.example.com/geolocation"); | 430 GURL requesting_frame("https://www.example.com/geolocation"); |
| 419 NavigateAndCommit(requesting_frame); | 431 NavigateAndCommit(requesting_frame); |
| 420 MockLocationSettings::SetLocationStatus(true, true); | 432 MockLocationSettings::SetLocationStatus(true, true); |
| 421 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 433 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 422 RequestGeolocationPermission( | 434 RequestGeolocationPermission( |
| 423 web_contents(), RequestID(0), requesting_frame, true); | 435 web_contents(), RequestID(0), requesting_frame, true); |
| 424 EXPECT_EQ(1U, infobar_service()->infobar_count()); | 436 EXPECT_EQ(1U, infobar_service()->infobar_count()); |
| 425 ConfirmInfoBarDelegate* infobar_delegate_0 = | 437 ConfirmInfoBarDelegate* infobar_delegate_0 = |
| 426 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); | 438 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); |
| 427 ASSERT_TRUE(infobar_delegate_0); | 439 ASSERT_TRUE(infobar_delegate_0); |
| 428 base::string16 text_0 = infobar_delegate_0->GetButtonLabel( | 440 base::string16 text_0 = infobar_delegate_0->GetButtonLabel( |
| 429 ConfirmInfoBarDelegate::BUTTON_OK); | 441 ConfirmInfoBarDelegate::BUTTON_OK); |
| 430 | 442 |
| 431 Reload(); | 443 Reload(); |
| 432 MockLocationSettings::SetLocationStatus(true, false); | 444 MockLocationSettings::SetLocationStatus(true, false); |
| 433 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 445 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 434 RequestGeolocationPermission( | 446 RequestGeolocationPermission( |
| 435 web_contents(), RequestID(0), requesting_frame, true); | 447 web_contents(), RequestID(0), requesting_frame, true); |
| 436 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 448 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 437 } | 449 } |
| 438 | 450 |
| 439 TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsEnabled) { | 451 TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsEnabled) { |
| 440 GURL requesting_frame("http://www.example.com/geolocation"); | 452 GURL requesting_frame("https://www.example.com/geolocation"); |
| 441 NavigateAndCommit(requesting_frame); | 453 NavigateAndCommit(requesting_frame); |
| 442 MockLocationSettings::SetLocationStatus(true, true); | 454 MockLocationSettings::SetLocationStatus(true, true); |
| 443 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 455 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 444 RequestGeolocationPermission( | 456 RequestGeolocationPermission( |
| 445 web_contents(), RequestID(0), requesting_frame, true); | 457 web_contents(), RequestID(0), requesting_frame, true); |
| 446 EXPECT_EQ(1U, infobar_service()->infobar_count()); | 458 EXPECT_EQ(1U, infobar_service()->infobar_count()); |
| 447 ConfirmInfoBarDelegate* infobar_delegate = | 459 ConfirmInfoBarDelegate* infobar_delegate = |
| 448 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); | 460 infobar_service()->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); |
| 449 ASSERT_TRUE(infobar_delegate); | 461 ASSERT_TRUE(infobar_delegate); |
| 450 infobar_delegate->Accept(); | 462 infobar_delegate->Accept(); |
| 451 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); | 463 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); |
| 452 CheckPermissionMessageSent(0, true); | 464 CheckPermissionMessageSent(0, true); |
| 453 } | 465 } |
| 454 | 466 |
| 455 TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsDisabled) { | 467 TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsDisabled) { |
| 456 GURL requesting_frame("http://www.example.com/geolocation"); | 468 GURL requesting_frame("https://www.example.com/geolocation"); |
| 457 NavigateAndCommit(requesting_frame); | 469 NavigateAndCommit(requesting_frame); |
| 458 MockLocationSettings::SetLocationStatus(true, false); | 470 MockLocationSettings::SetLocationStatus(true, false); |
| 459 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 471 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 460 RequestGeolocationPermission( | 472 RequestGeolocationPermission( |
| 461 web_contents(), RequestID(0), requesting_frame, true); | 473 web_contents(), RequestID(0), requesting_frame, true); |
| 462 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 474 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 463 } | 475 } |
| 464 #endif | 476 #endif |
| 465 | 477 |
| 466 TEST_F(GeolocationPermissionContextTests, QueuedPermission) { | 478 TEST_F(GeolocationPermissionContextTests, QueuedPermission) { |
| 467 GURL requesting_frame_0("http://www.example.com/geolocation"); | 479 GURL requesting_frame_0("https://www.example.com/geolocation"); |
| 468 GURL requesting_frame_1("http://www.example-2.com/geolocation"); | 480 GURL requesting_frame_1("https://www.example-2.com/geolocation"); |
| 469 EXPECT_EQ( | 481 EXPECT_EQ( |
| 470 CONTENT_SETTING_ASK, | 482 CONTENT_SETTING_ASK, |
| 471 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_1)); | 483 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_1)); |
| 472 EXPECT_EQ( | 484 EXPECT_EQ( |
| 473 CONTENT_SETTING_ASK, | 485 CONTENT_SETTING_ASK, |
| 474 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_1)); | 486 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_1)); |
| 475 | 487 |
| 476 NavigateAndCommit(requesting_frame_0); | 488 NavigateAndCommit(requesting_frame_0); |
| 477 BubbleManagerDocumentLoadCompleted(); | 489 BubbleManagerDocumentLoadCompleted(); |
| 478 | 490 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 // Ensure the persisted permissions are ok. | 535 // Ensure the persisted permissions are ok. |
| 524 EXPECT_EQ( | 536 EXPECT_EQ( |
| 525 CONTENT_SETTING_ALLOW, | 537 CONTENT_SETTING_ALLOW, |
| 526 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); | 538 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); |
| 527 EXPECT_EQ( | 539 EXPECT_EQ( |
| 528 CONTENT_SETTING_BLOCK, | 540 CONTENT_SETTING_BLOCK, |
| 529 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); | 541 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); |
| 530 } | 542 } |
| 531 | 543 |
| 532 TEST_F(GeolocationPermissionContextTests, HashIsIgnored) { | 544 TEST_F(GeolocationPermissionContextTests, HashIsIgnored) { |
| 533 GURL url_a("http://www.example.com/geolocation#a"); | 545 GURL url_a("https://www.example.com/geolocation#a"); |
| 534 GURL url_b("http://www.example.com/geolocation#b"); | 546 GURL url_b("https://www.example.com/geolocation#b"); |
| 535 | 547 |
| 536 // Navigate to the first url. | 548 // Navigate to the first url. |
| 537 NavigateAndCommit(url_a); | 549 NavigateAndCommit(url_a); |
| 538 BubbleManagerDocumentLoadCompleted(); | 550 BubbleManagerDocumentLoadCompleted(); |
| 539 | 551 |
| 540 // Check permission is requested. | 552 // Check permission is requested. |
| 541 ASSERT_EQ(0U, GetNumberOfPrompts()); | 553 ASSERT_EQ(0U, GetNumberOfPrompts()); |
| 542 #if BUILDFLAG(ANDROID_JAVA_UI) | 554 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 543 const bool user_gesture = false; | 555 const bool user_gesture = false; |
| 544 #else | 556 #else |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); | 602 CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); |
| 591 CheckPermissionMessageSent(0, true); | 603 CheckPermissionMessageSent(0, true); |
| 592 | 604 |
| 593 // Make sure the setting is not stored. | 605 // Make sure the setting is not stored. |
| 594 EXPECT_EQ( | 606 EXPECT_EQ( |
| 595 CONTENT_SETTING_ASK, | 607 CONTENT_SETTING_ASK, |
| 596 GetGeolocationContentSetting(requesting_frame, requesting_frame)); | 608 GetGeolocationContentSetting(requesting_frame, requesting_frame)); |
| 597 } | 609 } |
| 598 | 610 |
| 599 TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { | 611 TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { |
| 600 GURL frame_0("http://www.example.com/geolocation"); | 612 GURL frame_0("https://www.example.com/geolocation"); |
| 601 GURL frame_1("http://www.example-2.com/geolocation"); | 613 GURL frame_1("https://www.example-2.com/geolocation"); |
| 602 EXPECT_EQ( | 614 EXPECT_EQ( |
| 603 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_0, frame_0)); | 615 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_0, frame_0)); |
| 604 EXPECT_EQ( | 616 EXPECT_EQ( |
| 605 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_1, frame_0)); | 617 CONTENT_SETTING_ASK, GetGeolocationContentSetting(frame_1, frame_0)); |
| 606 | 618 |
| 607 NavigateAndCommit(frame_0); | 619 NavigateAndCommit(frame_0); |
| 608 BubbleManagerDocumentLoadCompleted(); | 620 BubbleManagerDocumentLoadCompleted(); |
| 609 | 621 |
| 610 ASSERT_EQ(0U, GetNumberOfPrompts()); | 622 ASSERT_EQ(0U, GetNumberOfPrompts()); |
| 611 | 623 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 | 667 |
| 656 // Nothing should be displayed. | 668 // Nothing should be displayed. |
| 657 EXPECT_EQ(0U, GetNumberOfPrompts()); | 669 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 658 RequestGeolocationPermission( | 670 RequestGeolocationPermission( |
| 659 web_contents(), RequestID(0), requesting_frame, true); | 671 web_contents(), RequestID(0), requesting_frame, true); |
| 660 EXPECT_EQ(0U, GetNumberOfPrompts()); | 672 EXPECT_EQ(0U, GetNumberOfPrompts()); |
| 661 CheckPermissionMessageSent(0, false); | 673 CheckPermissionMessageSent(0, false); |
| 662 } | 674 } |
| 663 | 675 |
| 664 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { | 676 TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { |
| 665 GURL url_a("http://www.example.com/geolocation"); | 677 GURL url_a("https://www.example.com/geolocation"); |
| 666 GURL url_b("http://www.example-2.com/geolocation"); | 678 GURL url_b("https://www.example-2.com/geolocation"); |
| 667 NavigateAndCommit(url_a); // Tab A0 | 679 NavigateAndCommit(url_a); // Tab A0 |
| 668 AddNewTab(url_b); // Tab B (extra_tabs_[0]) | 680 AddNewTab(url_b); // Tab B (extra_tabs_[0]) |
| 669 AddNewTab(url_a); // Tab A1 (extra_tabs_[1]) | 681 AddNewTab(url_a); // Tab A1 (extra_tabs_[1]) |
| 670 BubbleManagerDocumentLoadCompleted(); | 682 BubbleManagerDocumentLoadCompleted(); |
| 671 BubbleManagerDocumentLoadCompleted(extra_tabs_[0]); | 683 BubbleManagerDocumentLoadCompleted(extra_tabs_[0]); |
| 672 BubbleManagerDocumentLoadCompleted(extra_tabs_[1]); | 684 BubbleManagerDocumentLoadCompleted(extra_tabs_[1]); |
| 673 #if !BUILDFLAG(ANDROID_JAVA_UI) | 685 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 674 PermissionBubbleManager* manager_a0 = | 686 PermissionBubbleManager* manager_a0 = |
| 675 PermissionBubbleManager::FromWebContents(web_contents()); | 687 PermissionBubbleManager::FromWebContents(web_contents()); |
| 676 PermissionBubbleManager* manager_b = | 688 PermissionBubbleManager* manager_b = |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 #if !BUILDFLAG(ANDROID_JAVA_UI) | 728 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 717 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); | 729 ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); |
| 718 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b)); | 730 ASSERT_EQ(1U, GetBubblesQueueSize(manager_b)); |
| 719 #else | 731 #else |
| 720 CheckPermissionMessageSentForTab(1, 0, true); | 732 CheckPermissionMessageSentForTab(1, 0, true); |
| 721 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); | 733 ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); |
| 722 #endif | 734 #endif |
| 723 } | 735 } |
| 724 | 736 |
| 725 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { | 737 TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { |
| 726 GURL url_a("http://www.example.com/geolocation"); | 738 GURL url_a("https://www.example.com/geolocation"); |
| 727 GURL url_b("http://www.example-2.com/geolocation"); | 739 GURL url_b("https://www.example-2.com/geolocation"); |
| 728 NavigateAndCommit(url_a); // Tab A0. | 740 NavigateAndCommit(url_a); // Tab A0. |
| 729 AddNewTab(url_a); // Tab A1. | 741 AddNewTab(url_a); // Tab A1. |
| 730 #if !BUILDFLAG(ANDROID_JAVA_UI) | 742 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 731 BubbleManagerDocumentLoadCompleted(); | 743 BubbleManagerDocumentLoadCompleted(); |
| 732 BubbleManagerDocumentLoadCompleted(extra_tabs_[0]); | 744 BubbleManagerDocumentLoadCompleted(extra_tabs_[0]); |
| 733 PermissionBubbleManager* manager_a0 = | 745 PermissionBubbleManager* manager_a0 = |
| 734 PermissionBubbleManager::FromWebContents(web_contents()); | 746 PermissionBubbleManager::FromWebContents(web_contents()); |
| 735 PermissionBubbleManager* manager_a1 = | 747 PermissionBubbleManager* manager_a1 = |
| 736 PermissionBubbleManager::FromWebContents(extra_tabs_[0]); | 748 PermissionBubbleManager::FromWebContents(extra_tabs_[0]); |
| 737 #endif | 749 #endif |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 #else | 803 #else |
| 792 infobars::InfoBar* infobar_1 = infobar_service_for_tab(0)->infobar_at(0); | 804 infobars::InfoBar* infobar_1 = infobar_service_for_tab(0)->infobar_at(0); |
| 793 ConfirmInfoBarDelegate* infobar_delegate_1 = | 805 ConfirmInfoBarDelegate* infobar_delegate_1 = |
| 794 infobar_1->delegate()->AsConfirmInfoBarDelegate(); | 806 infobar_1->delegate()->AsConfirmInfoBarDelegate(); |
| 795 ASSERT_TRUE(infobar_delegate_1); | 807 ASSERT_TRUE(infobar_delegate_1); |
| 796 infobar_delegate_1->Accept(); | 808 infobar_delegate_1->Accept(); |
| 797 #endif | 809 #endif |
| 798 } | 810 } |
| 799 | 811 |
| 800 TEST_F(GeolocationPermissionContextTests, TabDestroyed) { | 812 TEST_F(GeolocationPermissionContextTests, TabDestroyed) { |
| 801 GURL requesting_frame_0("http://www.example.com/geolocation"); | 813 GURL requesting_frame_0("https://www.example.com/geolocation"); |
| 802 GURL requesting_frame_1("http://www.example-2.com/geolocation"); | 814 GURL requesting_frame_1("https://www.example-2.com/geolocation"); |
| 803 EXPECT_EQ( | 815 EXPECT_EQ( |
| 804 CONTENT_SETTING_ASK, | 816 CONTENT_SETTING_ASK, |
| 805 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); | 817 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); |
| 806 EXPECT_EQ( | 818 EXPECT_EQ( |
| 807 CONTENT_SETTING_ASK, | 819 CONTENT_SETTING_ASK, |
| 808 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); | 820 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); |
| 809 | 821 |
| 810 NavigateAndCommit(requesting_frame_0); | 822 NavigateAndCommit(requesting_frame_0); |
| 811 BubbleManagerDocumentLoadCompleted(); | 823 BubbleManagerDocumentLoadCompleted(); |
| 812 | 824 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 830 // The content settings should not have changed. | 842 // The content settings should not have changed. |
| 831 EXPECT_EQ( | 843 EXPECT_EQ( |
| 832 CONTENT_SETTING_ASK, | 844 CONTENT_SETTING_ASK, |
| 833 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); | 845 GetGeolocationContentSetting(requesting_frame_0, requesting_frame_0)); |
| 834 EXPECT_EQ( | 846 EXPECT_EQ( |
| 835 CONTENT_SETTING_ASK, | 847 CONTENT_SETTING_ASK, |
| 836 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); | 848 GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0)); |
| 837 } | 849 } |
| 838 | 850 |
| 839 TEST_F(GeolocationPermissionContextTests, LastUsageAudited) { | 851 TEST_F(GeolocationPermissionContextTests, LastUsageAudited) { |
| 840 GURL requesting_frame("http://www.example.com/geolocation"); | 852 GURL requesting_frame("https://www.example.com/geolocation"); |
| 841 NavigateAndCommit(requesting_frame); | 853 NavigateAndCommit(requesting_frame); |
| 842 BubbleManagerDocumentLoadCompleted(); | 854 BubbleManagerDocumentLoadCompleted(); |
| 843 | 855 |
| 844 base::SimpleTestClock* test_clock = new base::SimpleTestClock; | 856 base::SimpleTestClock* test_clock = new base::SimpleTestClock; |
| 845 test_clock->SetNow(base::Time::UnixEpoch() + | 857 test_clock->SetNow(base::Time::UnixEpoch() + |
| 846 base::TimeDelta::FromSeconds(10)); | 858 base::TimeDelta::FromSeconds(10)); |
| 847 | 859 |
| 848 HostContentSettingsMap* map = | 860 HostContentSettingsMap* map = |
| 849 HostContentSettingsMapFactory::GetForProfile(profile()); | 861 HostContentSettingsMapFactory::GetForProfile(profile()); |
| 850 map->SetPrefClockForTesting(scoped_ptr<base::Clock>(test_clock)); | 862 map->SetPrefClockForTesting(scoped_ptr<base::Clock>(test_clock)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 | 894 |
| 883 TEST_F(GeolocationPermissionContextTests, LastUsageAuditedMultipleFrames) { | 895 TEST_F(GeolocationPermissionContextTests, LastUsageAuditedMultipleFrames) { |
| 884 base::SimpleTestClock* test_clock = new base::SimpleTestClock; | 896 base::SimpleTestClock* test_clock = new base::SimpleTestClock; |
| 885 test_clock->SetNow(base::Time::UnixEpoch() + | 897 test_clock->SetNow(base::Time::UnixEpoch() + |
| 886 base::TimeDelta::FromSeconds(10)); | 898 base::TimeDelta::FromSeconds(10)); |
| 887 | 899 |
| 888 HostContentSettingsMap* map = | 900 HostContentSettingsMap* map = |
| 889 HostContentSettingsMapFactory::GetForProfile(profile()); | 901 HostContentSettingsMapFactory::GetForProfile(profile()); |
| 890 map->SetPrefClockForTesting(scoped_ptr<base::Clock>(test_clock)); | 902 map->SetPrefClockForTesting(scoped_ptr<base::Clock>(test_clock)); |
| 891 | 903 |
| 892 GURL requesting_frame_0("http://www.example.com/geolocation"); | 904 GURL requesting_frame_0("https://www.example.com/geolocation"); |
| 893 GURL requesting_frame_1("http://www.example-2.com/geolocation"); | 905 GURL requesting_frame_1("https://www.example-2.com/geolocation"); |
| 894 | 906 |
| 895 // The permission shouldn't have been used yet. | 907 // The permission shouldn't have been used yet. |
| 896 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 908 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
| 897 requesting_frame_0.GetOrigin(), | 909 requesting_frame_0.GetOrigin(), |
| 898 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 910 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 899 0); | 911 0); |
| 900 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 912 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
| 901 requesting_frame_0.GetOrigin(), | 913 requesting_frame_0.GetOrigin(), |
| 902 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 914 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 903 0); | 915 0); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 // it is the embedder. | 977 // it is the embedder. |
| 966 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 978 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
| 967 requesting_frame_0.GetOrigin(), | 979 requesting_frame_0.GetOrigin(), |
| 968 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 980 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 969 13); | 981 13); |
| 970 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 982 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
| 971 requesting_frame_0.GetOrigin(), | 983 requesting_frame_0.GetOrigin(), |
| 972 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 984 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 973 11); | 985 11); |
| 974 } | 986 } |
| OLD | NEW |