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