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