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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_navigation_observer_browsertest.cc

Issue 2777853005: Generalize the usage of referrer chain (Closed)
Patch Set: nit Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "chrome/browser/chrome_notification_types.h" 6 #include "chrome/browser/chrome_notification_types.h"
7 #include "chrome/browser/download/download_prefs.h" 7 #include "chrome/browser/download/download_prefs.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/safe_browsing/download_protection_service.h" 9 #include "chrome/browser/safe_browsing/download_protection_service.h"
10 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h" 10 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 } 350 }
351 } 351 }
352 352
353 // Identify referrer chain of a DownloadItem and populate |referrer_chain|. 353 // Identify referrer chain of a DownloadItem and populate |referrer_chain|.
354 void IdentifyReferrerChainForDownload( 354 void IdentifyReferrerChainForDownload(
355 DownloadItem* download, 355 DownloadItem* download,
356 ReferrerChain* referrer_chain) { 356 ReferrerChain* referrer_chain) {
357 int download_tab_id = 357 int download_tab_id =
358 SessionTabHelper::IdForTab(download->GetWebContents()); 358 SessionTabHelper::IdForTab(download->GetWebContents());
359 auto result = observer_manager_->IdentifyReferrerChainForDownload( 359 auto result = observer_manager_->IdentifyReferrerChainByEventURL(
360 download->GetURL(), download_tab_id, 360 download->GetURL(), download_tab_id,
361 2, // kDownloadAttributionUserGestureLimit 361 2, // kDownloadAttributionUserGestureLimit
362 referrer_chain); 362 referrer_chain);
363 if (result == 363 if (result ==
364 SafeBrowsingNavigationObserverManager::NAVIGATION_EVENT_NOT_FOUND) { 364 SafeBrowsingNavigationObserverManager::NAVIGATION_EVENT_NOT_FOUND) {
365 DCHECK_EQ(0, referrer_chain->size()); 365 DCHECK_EQ(0, referrer_chain->size());
366 observer_manager_->IdentifyReferrerChainByDownloadWebContent( 366 observer_manager_->IdentifyReferrerChainByWebContent(
367 download->GetWebContents(), 367 download->GetWebContents(),
368 2, // kDownloadAttributionUserGestureLimit 368 2, // kDownloadAttributionUserGestureLimit
369 referrer_chain); 369 referrer_chain);
370 } 370 }
371 } 371 }
372 372
373 // Identify referrer chain of a PPAPI download and populate |referrer_chain|. 373 // Identify referrer chain of a PPAPI download and populate |referrer_chain|.
374 void IdentifyReferrerChainForPPAPIDownload( 374 void IdentifyReferrerChainForPPAPIDownload(
375 const GURL& initiating_frame_url, 375 const GURL& initiating_frame_url,
376 content::WebContents* web_contents, 376 content::WebContents* web_contents,
377 ReferrerChain* referrer_chain) { 377 ReferrerChain* referrer_chain) {
378 int tab_id = SessionTabHelper::IdForTab(web_contents); 378 int tab_id = SessionTabHelper::IdForTab(web_contents);
379 bool has_user_gesture = observer_manager_->HasUserGesture(web_contents); 379 bool has_user_gesture = observer_manager_->HasUserGesture(web_contents);
380 observer_manager_->OnUserGestureConsumed(web_contents, base::Time::Now()); 380 observer_manager_->OnUserGestureConsumed(web_contents, base::Time::Now());
381 EXPECT_LE(observer_manager_->IdentifyReferrerChainForDownloadHostingPage( 381 EXPECT_LE(observer_manager_->IdentifyReferrerChainByHostingPage(
382 initiating_frame_url, web_contents->GetLastCommittedURL(), 382 initiating_frame_url, web_contents->GetLastCommittedURL(),
383 tab_id, has_user_gesture, 383 tab_id, has_user_gesture,
384 2, // kDownloadAttributionUserGestureLimit 384 2, // kDownloadAttributionUserGestureLimit
385 referrer_chain), 385 referrer_chain),
386 SafeBrowsingNavigationObserverManager::SUCCESS_LANDING_REFERRER); 386 SafeBrowsingNavigationObserverManager::SUCCESS_LANDING_REFERRER);
387 } 387 }
388 388
389 void VerifyHostToIpMap() { 389 void VerifyHostToIpMap() {
390 // Since all testing pages have the same host, there is only one entry in 390 // Since all testing pages have the same host, there is only one entry in
391 // host_to_ip_map_. 391 // host_to_ip_map_.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 download_url, // destination_url 445 download_url, // destination_url
446 true, // is_user_initiated, 446 true, // is_user_initiated,
447 false, // has_committed 447 false, // has_committed
448 false, // has_server_redirect 448 false, // has_server_redirect
449 nav_list->Get(1)); 449 nav_list->Get(1));
450 VerifyHostToIpMap(); 450 VerifyHostToIpMap();
451 451
452 ReferrerChain referrer_chain; 452 ReferrerChain referrer_chain;
453 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 453 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
454 ASSERT_EQ(1, referrer_chain.size()); 454 ASSERT_EQ(1, referrer_chain.size());
455 VerifyReferrerChainEntry(download_url, // url 455 VerifyReferrerChainEntry(download_url, // url
456 GURL(), // main_frame_url 456 GURL(), // main_frame_url
457 ReferrerChainEntry::DOWNLOAD_URL, // type 457 ReferrerChainEntry::EVENT_URL, // type
458 test_server_ip, // ip_address 458 test_server_ip, // ip_address
459 GURL(), // referrer_url 459 GURL(), // referrer_url
460 GURL(), // referrer_main_frame_url 460 GURL(), // referrer_main_frame_url
461 false, // is_retargeting 461 false, // is_retargeting
462 std::vector<GURL>(), // server redirects 462 std::vector<GURL>(), // server redirects
463 referrer_chain.Get(0)); 463 referrer_chain.Get(0));
464 } 464 }
465 // Click on a link and start download on the same page. 465 // Click on a link and start download on the same page.
466 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, DirectDownload) { 466 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, DirectDownload) {
467 GURL initial_url = embedded_test_server()->GetURL(kSingleFrameTestURL); 467 GURL initial_url = embedded_test_server()->GetURL(kSingleFrameTestURL);
468 ClickTestLink("direct_download", 1, initial_url); 468 ClickTestLink("direct_download", 1, initial_url);
469 GURL download_url = embedded_test_server()->GetURL(kDownloadItemURL); 469 GURL download_url = embedded_test_server()->GetURL(kDownloadItemURL);
(...skipping 15 matching lines...) Expand all
485 download_url, // destination_url 485 download_url, // destination_url
486 true, // is_user_initiated, 486 true, // is_user_initiated,
487 false, // has_committed 487 false, // has_committed
488 false, // has_server_redirect 488 false, // has_server_redirect
489 nav_list->Get(1)); 489 nav_list->Get(1));
490 VerifyHostToIpMap(); 490 VerifyHostToIpMap();
491 491
492 ReferrerChain referrer_chain; 492 ReferrerChain referrer_chain;
493 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 493 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
494 ASSERT_EQ(2, referrer_chain.size()); 494 ASSERT_EQ(2, referrer_chain.size());
495 VerifyReferrerChainEntry(download_url, // url 495 VerifyReferrerChainEntry(download_url, // url
496 GURL(), // main_frame_url 496 GURL(), // main_frame_url
497 ReferrerChainEntry::DOWNLOAD_URL, // type 497 ReferrerChainEntry::EVENT_URL, // type
498 test_server_ip, // ip_address 498 test_server_ip, // ip_address
499 initial_url, // referrer_url 499 initial_url, // referrer_url
500 GURL(), // referrer_main_frame_url 500 GURL(), // referrer_main_frame_url
501 false, // is_retargeting 501 false, // is_retargeting
502 std::vector<GURL>(), // server redirects 502 std::vector<GURL>(), // server redirects
503 referrer_chain.Get(0)); 503 referrer_chain.Get(0));
504 VerifyReferrerChainEntry(initial_url, // url 504 VerifyReferrerChainEntry(initial_url, // url
505 GURL(), // main_frame_url 505 GURL(), // main_frame_url
506 ReferrerChainEntry::LANDING_PAGE, // type 506 ReferrerChainEntry::LANDING_PAGE, // type
507 test_server_ip, // ip_address 507 test_server_ip, // ip_address
508 GURL(), // referrer_url 508 GURL(), // referrer_url
509 GURL(), // referrer_main_frame_url 509 GURL(), // referrer_main_frame_url
(...skipping 27 matching lines...) Expand all
537 download_url, // destination_url 537 download_url, // destination_url
538 true, // is_user_initiated, 538 true, // is_user_initiated,
539 false, // has_committed 539 false, // has_committed
540 false, // has_server_redirect 540 false, // has_server_redirect
541 nav_list->Get(1)); 541 nav_list->Get(1));
542 VerifyHostToIpMap(); 542 VerifyHostToIpMap();
543 543
544 ReferrerChain referrer_chain; 544 ReferrerChain referrer_chain;
545 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 545 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
546 ASSERT_EQ(2, referrer_chain.size()); 546 ASSERT_EQ(2, referrer_chain.size());
547 VerifyReferrerChainEntry(download_url, // url 547 VerifyReferrerChainEntry(download_url, // url
548 GURL(), // main_frame_url 548 GURL(), // main_frame_url
549 ReferrerChainEntry::DOWNLOAD_URL, // type 549 ReferrerChainEntry::EVENT_URL, // type
550 test_server_ip, // ip_address 550 test_server_ip, // ip_address
551 initial_url, // referrer_url 551 initial_url, // referrer_url
552 GURL(), // referrer_main_frame_url 552 GURL(), // referrer_main_frame_url
553 false, // is_retargeting 553 false, // is_retargeting
554 std::vector<GURL>(), // server redirects 554 std::vector<GURL>(), // server redirects
555 referrer_chain.Get(0)); 555 referrer_chain.Get(0));
556 VerifyReferrerChainEntry(initial_url, // url 556 VerifyReferrerChainEntry(initial_url, // url
557 GURL(), // main_frame_url 557 GURL(), // main_frame_url
558 ReferrerChainEntry::LANDING_PAGE, // type 558 ReferrerChainEntry::LANDING_PAGE, // type
559 test_server_ip, // ip_address 559 test_server_ip, // ip_address
560 GURL(), // referrer_url 560 GURL(), // referrer_url
561 GURL(), // referrer_main_frame_url 561 GURL(), // referrer_main_frame_url
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 download_url, // destination_url 599 download_url, // destination_url
600 false, // is_user_initiated, 600 false, // is_user_initiated,
601 false, // has_committed 601 false, // has_committed
602 false, // has_server_redirect 602 false, // has_server_redirect
603 nav_list->Get(2)); 603 nav_list->Get(2));
604 VerifyHostToIpMap(); 604 VerifyHostToIpMap();
605 605
606 ReferrerChain referrer_chain; 606 ReferrerChain referrer_chain;
607 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 607 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
608 ASSERT_EQ(2, referrer_chain.size()); 608 ASSERT_EQ(2, referrer_chain.size());
609 VerifyReferrerChainEntry(download_url, // url 609 VerifyReferrerChainEntry(download_url, // url
610 GURL(), // main_frame_url 610 GURL(), // main_frame_url
611 ReferrerChainEntry::DOWNLOAD_URL, // type 611 ReferrerChainEntry::EVENT_URL, // type
612 test_server_ip, // ip_address 612 test_server_ip, // ip_address
613 initial_url, // referrer_url 613 initial_url, // referrer_url
614 GURL(), // referrer_main_frame_url 614 GURL(), // referrer_main_frame_url
615 true, // is_retargeting 615 true, // is_retargeting
616 std::vector<GURL>(), // server redirects 616 std::vector<GURL>(), // server redirects
617 referrer_chain.Get(0)); 617 referrer_chain.Get(0));
618 VerifyReferrerChainEntry(initial_url, // url 618 VerifyReferrerChainEntry(initial_url, // url
619 GURL(), // main_frame_url 619 GURL(), // main_frame_url
620 ReferrerChainEntry::LANDING_PAGE, // type 620 ReferrerChainEntry::LANDING_PAGE, // type
621 test_server_ip, // ip_address 621 test_server_ip, // ip_address
622 GURL(), // referrer_url 622 GURL(), // referrer_url
623 GURL(), // referrer_main_frame_url 623 GURL(), // referrer_main_frame_url
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 download_url, // destination_url 662 download_url, // destination_url
663 false, // is_user_initiated, 663 false, // is_user_initiated,
664 false, // has_committed 664 false, // has_committed
665 false, // has_server_redirect 665 false, // has_server_redirect
666 nav_list->Get(2)); 666 nav_list->Get(2));
667 VerifyHostToIpMap(); 667 VerifyHostToIpMap();
668 668
669 ReferrerChain referrer_chain; 669 ReferrerChain referrer_chain;
670 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 670 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
671 ASSERT_EQ(3, referrer_chain.size()); 671 ASSERT_EQ(3, referrer_chain.size());
672 VerifyReferrerChainEntry(download_url, // url 672 VerifyReferrerChainEntry(download_url, // url
673 GURL(), // main_frame_url 673 GURL(), // main_frame_url
674 ReferrerChainEntry::DOWNLOAD_URL, // type 674 ReferrerChainEntry::EVENT_URL, // type
675 test_server_ip, // ip_address 675 test_server_ip, // ip_address
676 redirect_url, // referrer_url 676 redirect_url, // referrer_url
677 GURL(), // referrer_main_frame_url 677 GURL(), // referrer_main_frame_url
678 false, // is_retargeting 678 false, // is_retargeting
679 std::vector<GURL>(), // server redirects 679 std::vector<GURL>(), // server redirects
680 referrer_chain.Get(0)); 680 referrer_chain.Get(0));
681 VerifyReferrerChainEntry(redirect_url, // url 681 VerifyReferrerChainEntry(redirect_url, // url
682 GURL(), // main_frame_url 682 GURL(), // main_frame_url
683 ReferrerChainEntry::CLIENT_REDIRECT, // type 683 ReferrerChainEntry::CLIENT_REDIRECT, // type
684 test_server_ip, // ip_address 684 test_server_ip, // ip_address
685 initial_url, // referrer_url 685 initial_url, // referrer_url
686 GURL(), // referrer_main_frame_url 686 GURL(), // referrer_main_frame_url
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 download_url, // destination_url 740 download_url, // destination_url
741 false, // is_user_initiated, 741 false, // is_user_initiated,
742 false, // has_committed 742 false, // has_committed
743 false, // has_server_redirect 743 false, // has_server_redirect
744 nav_list->Get(3)); 744 nav_list->Get(3));
745 VerifyHostToIpMap(); 745 VerifyHostToIpMap();
746 746
747 ReferrerChain referrer_chain; 747 ReferrerChain referrer_chain;
748 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 748 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
749 ASSERT_EQ(3, referrer_chain.size()); 749 ASSERT_EQ(3, referrer_chain.size());
750 VerifyReferrerChainEntry(download_url, // url 750 VerifyReferrerChainEntry(download_url, // url
751 GURL(), // main_frame_url 751 GURL(), // main_frame_url
752 ReferrerChainEntry::DOWNLOAD_URL, // type 752 ReferrerChainEntry::EVENT_URL, // type
753 test_server_ip, // ip_address 753 test_server_ip, // ip_address
754 redirect_url, // referrer_url 754 redirect_url, // referrer_url
755 GURL(), // referrer_main_frame_url 755 GURL(), // referrer_main_frame_url
756 false, // is_retargeting 756 false, // is_retargeting
757 std::vector<GURL>(), // server redirects 757 std::vector<GURL>(), // server redirects
758 referrer_chain.Get(0)); 758 referrer_chain.Get(0));
759 VerifyReferrerChainEntry(redirect_url, // url 759 VerifyReferrerChainEntry(redirect_url, // url
760 GURL(), // main_frame_url 760 GURL(), // main_frame_url
761 ReferrerChainEntry::CLIENT_REDIRECT, // type 761 ReferrerChainEntry::CLIENT_REDIRECT, // type
762 test_server_ip, // ip_address 762 test_server_ip, // ip_address
763 initial_url, // referrer_url 763 initial_url, // referrer_url
764 GURL(), // referrer_main_frame_url 764 GURL(), // referrer_main_frame_url
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 download_url, // destination_url 821 download_url, // destination_url
822 false, // is_user_initiated, 822 false, // is_user_initiated,
823 false, // has_committed 823 false, // has_committed
824 false, // has_server_redirect 824 false, // has_server_redirect
825 nav_list->Get(3)); 825 nav_list->Get(3));
826 VerifyHostToIpMap(); 826 VerifyHostToIpMap();
827 827
828 ReferrerChain referrer_chain; 828 ReferrerChain referrer_chain;
829 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 829 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
830 ASSERT_EQ(4, referrer_chain.size()); 830 ASSERT_EQ(4, referrer_chain.size());
831 VerifyReferrerChainEntry(download_url, // url 831 VerifyReferrerChainEntry(download_url, // url
832 GURL(), // main_frame_url 832 GURL(), // main_frame_url
833 ReferrerChainEntry::DOWNLOAD_URL, // type 833 ReferrerChainEntry::EVENT_URL, // type
834 test_server_ip, // ip_address 834 test_server_ip, // ip_address
835 second_redirect_url, // referrer_url 835 second_redirect_url, // referrer_url
836 GURL(), // referrer_main_frame_url 836 GURL(), // referrer_main_frame_url
837 false, // is_retargeting 837 false, // is_retargeting
838 std::vector<GURL>(), // server redirects 838 std::vector<GURL>(), // server redirects
839 referrer_chain.Get(0)); 839 referrer_chain.Get(0));
840 VerifyReferrerChainEntry(second_redirect_url, // url 840 VerifyReferrerChainEntry(second_redirect_url, // url
841 GURL(), // main_frame_url 841 GURL(), // main_frame_url
842 ReferrerChainEntry::CLIENT_REDIRECT, // type 842 ReferrerChainEntry::CLIENT_REDIRECT, // type
843 test_server_ip, // ip_address 843 test_server_ip, // ip_address
844 first_redirect_url, // referrer_url 844 first_redirect_url, // referrer_url
845 GURL(), // referrer_main_frame_url 845 GURL(), // referrer_main_frame_url
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 download_url, // original_request_url 890 download_url, // original_request_url
891 download_url, // destination_url 891 download_url, // destination_url
892 true, // is_user_initiated, 892 true, // is_user_initiated,
893 false, // has_committed 893 false, // has_committed
894 false, // has_server_redirect 894 false, // has_server_redirect
895 nav_list->Get(1)); 895 nav_list->Get(1));
896 896
897 ReferrerChain referrer_chain; 897 ReferrerChain referrer_chain;
898 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 898 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
899 ASSERT_EQ(2, referrer_chain.size()); 899 ASSERT_EQ(2, referrer_chain.size());
900 VerifyReferrerChainEntry(download_url, // url 900 VerifyReferrerChainEntry(download_url, // url
901 GURL(), // main_frame_url 901 GURL(), // main_frame_url
902 ReferrerChainEntry::DOWNLOAD_URL, // type 902 ReferrerChainEntry::EVENT_URL, // type
903 test_server_ip, // ip_address 903 test_server_ip, // ip_address
904 initial_url, // referrer_url 904 initial_url, // referrer_url
905 GURL(), // referrer_main_frame_url 905 GURL(), // referrer_main_frame_url
906 false, // is_retargeting 906 false, // is_retargeting
907 std::vector<GURL>(), // server redirects 907 std::vector<GURL>(), // server redirects
908 referrer_chain.Get(0)); 908 referrer_chain.Get(0));
909 VerifyReferrerChainEntry(initial_url, // url 909 VerifyReferrerChainEntry(initial_url, // url
910 GURL(), // main_frame_url 910 GURL(), // main_frame_url
911 ReferrerChainEntry::LANDING_PAGE, // type 911 ReferrerChainEntry::LANDING_PAGE, // type
912 test_server_ip, // ip_address 912 test_server_ip, // ip_address
913 GURL(), // referrer_url 913 GURL(), // referrer_url
914 GURL(), // referrer_main_frame_url 914 GURL(), // referrer_main_frame_url
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 download_url, // destination_url 951 download_url, // destination_url
952 false, // is_user_initiated, 952 false, // is_user_initiated,
953 false, // has_committed 953 false, // has_committed
954 false, // has_server_redirect 954 false, // has_server_redirect
955 nav_list->Get(2)); 955 nav_list->Get(2));
956 VerifyHostToIpMap(); 956 VerifyHostToIpMap();
957 957
958 ReferrerChain referrer_chain; 958 ReferrerChain referrer_chain;
959 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 959 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
960 ASSERT_EQ(3, referrer_chain.size()); 960 ASSERT_EQ(3, referrer_chain.size());
961 VerifyReferrerChainEntry(download_url, // url 961 VerifyReferrerChainEntry(download_url, // url
962 GURL(), // main_frame_url 962 GURL(), // main_frame_url
963 ReferrerChainEntry::DOWNLOAD_URL, // type 963 ReferrerChainEntry::EVENT_URL, // type
964 test_server_ip, // ip_address 964 test_server_ip, // ip_address
965 redirect_url, // referrer_url 965 redirect_url, // referrer_url
966 GURL(), // referrer_main_frame_url 966 GURL(), // referrer_main_frame_url
967 false, // is_retargeting 967 false, // is_retargeting
968 std::vector<GURL>(), // server redirects 968 std::vector<GURL>(), // server redirects
969 referrer_chain.Get(0)); 969 referrer_chain.Get(0));
970 VerifyReferrerChainEntry(redirect_url, // url 970 VerifyReferrerChainEntry(redirect_url, // url
971 GURL(), // main_frame_url 971 GURL(), // main_frame_url
972 ReferrerChainEntry::CLIENT_REDIRECT, // type 972 ReferrerChainEntry::CLIENT_REDIRECT, // type
973 test_server_ip, // ip_address 973 test_server_ip, // ip_address
974 initial_url, // referrer_url 974 initial_url, // referrer_url
975 GURL(), // referrer_main_frame_url 975 GURL(), // referrer_main_frame_url
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 false, // is_user_initiated, 1031 false, // is_user_initiated,
1032 false, // has_committed 1032 false, // has_committed
1033 false, // has_server_redirect 1033 false, // has_server_redirect
1034 nav_list->Get(3)); 1034 nav_list->Get(3));
1035 EXPECT_EQ(nav_list->Get(3)->source_tab_id, nav_list->Get(3)->target_tab_id); 1035 EXPECT_EQ(nav_list->Get(3)->source_tab_id, nav_list->Get(3)->target_tab_id);
1036 VerifyHostToIpMap(); 1036 VerifyHostToIpMap();
1037 1037
1038 ReferrerChain referrer_chain; 1038 ReferrerChain referrer_chain;
1039 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 1039 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
1040 ASSERT_EQ(3, referrer_chain.size()); 1040 ASSERT_EQ(3, referrer_chain.size());
1041 VerifyReferrerChainEntry(download_url, // url 1041 VerifyReferrerChainEntry(download_url, // url
1042 GURL(), // main_frame_url 1042 GURL(), // main_frame_url
1043 ReferrerChainEntry::DOWNLOAD_URL, // type 1043 ReferrerChainEntry::EVENT_URL, // type
1044 test_server_ip, // ip_address 1044 test_server_ip, // ip_address
1045 blank_url, // referrer_url 1045 blank_url, // referrer_url
1046 GURL(), // referrer_main_frame_url 1046 GURL(), // referrer_main_frame_url
1047 false, // is_retargeting 1047 false, // is_retargeting
1048 std::vector<GURL>(), // server redirects 1048 std::vector<GURL>(), // server redirects
1049 referrer_chain.Get(0)); 1049 referrer_chain.Get(0));
1050 VerifyReferrerChainEntry(blank_url, // url 1050 VerifyReferrerChainEntry(blank_url, // url
1051 GURL(), // main_frame_url 1051 GURL(), // main_frame_url
1052 ReferrerChainEntry::CLIENT_REDIRECT, // type 1052 ReferrerChainEntry::CLIENT_REDIRECT, // type
1053 "", // ip_address 1053 "", // ip_address
1054 initial_url, // referrer_url 1054 initial_url, // referrer_url
1055 GURL(), // referrer_main_frame_url 1055 GURL(), // referrer_main_frame_url
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 false, // has_committed 1115 false, // has_committed
1116 false, // has_server_redirect 1116 false, // has_server_redirect
1117 nav_list->Get(3)); 1117 nav_list->Get(3));
1118 EXPECT_TRUE(nav_list->Get(3)->source_tab_id == 1118 EXPECT_TRUE(nav_list->Get(3)->source_tab_id ==
1119 nav_list->Get(3)->target_tab_id); 1119 nav_list->Get(3)->target_tab_id);
1120 VerifyHostToIpMap(); 1120 VerifyHostToIpMap();
1121 1121
1122 ReferrerChain referrer_chain; 1122 ReferrerChain referrer_chain;
1123 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 1123 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
1124 ASSERT_EQ(3, referrer_chain.size()); 1124 ASSERT_EQ(3, referrer_chain.size());
1125 VerifyReferrerChainEntry(download_url, // url 1125 VerifyReferrerChainEntry(download_url, // url
1126 GURL(), // main_frame_url 1126 GURL(), // main_frame_url
1127 ReferrerChainEntry::DOWNLOAD_URL, // type 1127 ReferrerChainEntry::EVENT_URL, // type
1128 "", // ip_address 1128 "", // ip_address
1129 blank_url, // referrer_url 1129 blank_url, // referrer_url
1130 GURL(), // referrer_main_frame_url 1130 GURL(), // referrer_main_frame_url
1131 false, // is_retargeting 1131 false, // is_retargeting
1132 std::vector<GURL>(), // server redirects 1132 std::vector<GURL>(), // server redirects
1133 referrer_chain.Get(0)); 1133 referrer_chain.Get(0));
1134 VerifyReferrerChainEntry(blank_url, // url 1134 VerifyReferrerChainEntry(blank_url, // url
1135 GURL(), // main_frame_url 1135 GURL(), // main_frame_url
1136 ReferrerChainEntry::CLIENT_REDIRECT, // type 1136 ReferrerChainEntry::CLIENT_REDIRECT, // type
1137 "", // ip_address 1137 "", // ip_address
1138 initial_url, // referrer_url 1138 initial_url, // referrer_url
1139 GURL(), // referrer_main_frame_url 1139 GURL(), // referrer_main_frame_url
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 download_url, // destination_url 1207 download_url, // destination_url
1208 true, // is_user_initiated, 1208 true, // is_user_initiated,
1209 false, // has_committed 1209 false, // has_committed
1210 false, // has_server_redirect 1210 false, // has_server_redirect
1211 nav_list->Get(4)); 1211 nav_list->Get(4));
1212 VerifyHostToIpMap(); 1212 VerifyHostToIpMap();
1213 1213
1214 ReferrerChain referrer_chain; 1214 ReferrerChain referrer_chain;
1215 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 1215 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
1216 ASSERT_EQ(4, referrer_chain.size()); 1216 ASSERT_EQ(4, referrer_chain.size());
1217 VerifyReferrerChainEntry(download_url, // url 1217 VerifyReferrerChainEntry(download_url, // url
1218 GURL(), // main_frame_url 1218 GURL(), // main_frame_url
1219 ReferrerChainEntry::DOWNLOAD_URL, // type 1219 ReferrerChainEntry::EVENT_URL, // type
1220 test_server_ip, // ip_address 1220 test_server_ip, // ip_address
1221 iframe_url, // referrer_url 1221 iframe_url, // referrer_url
1222 multi_frame_test_url, // referrer_main_frame_url 1222 multi_frame_test_url, // referrer_main_frame_url
1223 false, // is_retargeting 1223 false, // is_retargeting
1224 std::vector<GURL>(), // server redirects 1224 std::vector<GURL>(), // server redirects
1225 referrer_chain.Get(0)); 1225 referrer_chain.Get(0));
1226 VerifyReferrerChainEntry(iframe_url, // url 1226 VerifyReferrerChainEntry(iframe_url, // url
1227 multi_frame_test_url, // main_frame_url 1227 multi_frame_test_url, // main_frame_url
1228 ReferrerChainEntry::LANDING_PAGE, // type 1228 ReferrerChainEntry::LANDING_PAGE, // type
1229 test_server_ip, // ip_address 1229 test_server_ip, // ip_address
1230 GURL(), // referrer_url 1230 GURL(), // referrer_url
1231 multi_frame_test_url, // referrer_main_frame_url 1231 multi_frame_test_url, // referrer_main_frame_url
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 download_url, // destination_url 1325 download_url, // destination_url
1326 false, // is_user_initiated, 1326 false, // is_user_initiated,
1327 false, // has_committed 1327 false, // has_committed
1328 false, // has_server_redirect 1328 false, // has_server_redirect
1329 nav_list->Get(6)); 1329 nav_list->Get(6));
1330 VerifyHostToIpMap(); 1330 VerifyHostToIpMap();
1331 1331
1332 ReferrerChain referrer_chain; 1332 ReferrerChain referrer_chain;
1333 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 1333 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
1334 EXPECT_EQ(5, referrer_chain.size()); 1334 EXPECT_EQ(5, referrer_chain.size());
1335 VerifyReferrerChainEntry(download_url, // url 1335 VerifyReferrerChainEntry(download_url, // url
1336 GURL(), // main_frame_url 1336 GURL(), // main_frame_url
1337 ReferrerChainEntry::DOWNLOAD_URL, // type 1337 ReferrerChainEntry::EVENT_URL, // type
1338 test_server_ip, // ip_address 1338 test_server_ip, // ip_address
1339 blank_url, // referrer_url 1339 blank_url, // referrer_url
1340 GURL(), // referrer_main_frame_url 1340 GURL(), // referrer_main_frame_url
1341 false, // is_retargeting 1341 false, // is_retargeting
1342 std::vector<GURL>(), // server redirects 1342 std::vector<GURL>(), // server redirects
1343 referrer_chain.Get(0)); 1343 referrer_chain.Get(0));
1344 VerifyReferrerChainEntry(blank_url, // url 1344 VerifyReferrerChainEntry(blank_url, // url
1345 GURL(), // main_frame_url 1345 GURL(), // main_frame_url
1346 ReferrerChainEntry::CLIENT_REDIRECT, // type 1346 ReferrerChainEntry::CLIENT_REDIRECT, // type
1347 "", // ip_address 1347 "", // ip_address
1348 iframe_retargeting_url, // referrer_url 1348 iframe_retargeting_url, // referrer_url
1349 multi_frame_test_url, // referrer_main_frame_url 1349 multi_frame_test_url, // referrer_main_frame_url
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 download_url, // destination_url 1422 download_url, // destination_url
1423 true, // is_user_initiated, 1423 true, // is_user_initiated,
1424 false, // has_committed 1424 false, // has_committed
1425 false, // has_server_redirect 1425 false, // has_server_redirect
1426 nav_list->Get(3)); 1426 nav_list->Get(3));
1427 VerifyHostToIpMap(); 1427 VerifyHostToIpMap();
1428 1428
1429 ReferrerChain referrer_chain; 1429 ReferrerChain referrer_chain;
1430 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 1430 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
1431 EXPECT_EQ(4, referrer_chain.size()); 1431 EXPECT_EQ(4, referrer_chain.size());
1432 VerifyReferrerChainEntry(download_url, // url 1432 VerifyReferrerChainEntry(download_url, // url
1433 GURL(), // main_frame_url 1433 GURL(), // main_frame_url
1434 ReferrerChainEntry::DOWNLOAD_URL, // type 1434 ReferrerChainEntry::EVENT_URL, // type
1435 test_server_ip, // ip_address 1435 test_server_ip, // ip_address
1436 landing_url, // referrer_url 1436 landing_url, // referrer_url
1437 GURL(), // referrer_main_frame_url 1437 GURL(), // referrer_main_frame_url
1438 false, // is_retargeting 1438 false, // is_retargeting
1439 std::vector<GURL>(), // server redirects 1439 std::vector<GURL>(), // server redirects
1440 referrer_chain.Get(0)); 1440 referrer_chain.Get(0));
1441 VerifyReferrerChainEntry(landing_url, // url 1441 VerifyReferrerChainEntry(landing_url, // url
1442 GURL(), // main_frame_url 1442 GURL(), // main_frame_url
1443 ReferrerChainEntry::LANDING_PAGE, // type 1443 ReferrerChainEntry::LANDING_PAGE, // type
1444 test_server_ip, // ip_address 1444 test_server_ip, // ip_address
1445 redirect_url, // referrer_url 1445 redirect_url, // referrer_url
1446 GURL(), // referrer_main_frame_url 1446 GURL(), // referrer_main_frame_url
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 download_url, // destination_url 1525 download_url, // destination_url
1526 true, // is_user_initiated, 1526 true, // is_user_initiated,
1527 false, // has_committed 1527 false, // has_committed
1528 false, // has_server_redirect 1528 false, // has_server_redirect
1529 nav_list->Get(4)); 1529 nav_list->Get(4));
1530 VerifyHostToIpMap(); 1530 VerifyHostToIpMap();
1531 1531
1532 ReferrerChain referrer_chain; 1532 ReferrerChain referrer_chain;
1533 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 1533 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
1534 EXPECT_EQ(3, referrer_chain.size()); 1534 EXPECT_EQ(3, referrer_chain.size());
1535 VerifyReferrerChainEntry(download_url, // url 1535 VerifyReferrerChainEntry(download_url, // url
1536 GURL(), // main_frame_url 1536 GURL(), // main_frame_url
1537 ReferrerChainEntry::DOWNLOAD_URL, // type 1537 ReferrerChainEntry::EVENT_URL, // type
1538 test_server_ip, // ip_address 1538 test_server_ip, // ip_address
1539 landing_url, // referrer_url 1539 landing_url, // referrer_url
1540 GURL(), // referrer_main_frame_url 1540 GURL(), // referrer_main_frame_url
1541 false, // is_retargeting 1541 false, // is_retargeting
1542 std::vector<GURL>(), // server redirects 1542 std::vector<GURL>(), // server redirects
1543 referrer_chain.Get(0)); 1543 referrer_chain.Get(0));
1544 VerifyReferrerChainEntry(landing_url, // url 1544 VerifyReferrerChainEntry(landing_url, // url
1545 GURL(), // main_frame_url 1545 GURL(), // main_frame_url
1546 ReferrerChainEntry::LANDING_PAGE, // type 1546 ReferrerChainEntry::LANDING_PAGE, // type
1547 test_server_ip, // ip_address 1547 test_server_ip, // ip_address
1548 landing_referrer_url, // referrer_url 1548 landing_referrer_url, // referrer_url
1549 GURL(), // referrer_main_frame_url 1549 GURL(), // referrer_main_frame_url
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 request_url, // original_request_url 1737 request_url, // original_request_url
1738 download_url, // destination_url 1738 download_url, // destination_url
1739 true, // is_user_initiated, 1739 true, // is_user_initiated,
1740 false, // has_committed 1740 false, // has_committed
1741 true, // has_server_redirect 1741 true, // has_server_redirect
1742 nav_list->Get(1)); 1742 nav_list->Get(1));
1743 1743
1744 ReferrerChain referrer_chain; 1744 ReferrerChain referrer_chain;
1745 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 1745 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
1746 ASSERT_EQ(1, referrer_chain.size()); 1746 ASSERT_EQ(1, referrer_chain.size());
1747 VerifyReferrerChainEntry(download_url, // url 1747 VerifyReferrerChainEntry(download_url, // url
1748 GURL(), // main_frame_url 1748 GURL(), // main_frame_url
1749 ReferrerChainEntry::DOWNLOAD_URL, // type 1749 ReferrerChainEntry::EVENT_URL, // type
1750 test_server_ip, // ip_address 1750 test_server_ip, // ip_address
1751 GURL(), // referrer_url 1751 GURL(), // referrer_url
1752 GURL(), // referrer_main_frame_url 1752 GURL(), // referrer_main_frame_url
1753 false, // is_retargeting 1753 false, // is_retargeting
1754 {request_url, download_url}, // server redirects 1754 {request_url, download_url}, // server redirects
1755 referrer_chain.Get(0)); 1755 referrer_chain.Get(0));
1756 } 1756 }
1757 1757
1758 // 2 consecutive server-side redirects. 1758 // 2 consecutive server-side redirects.
1759 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, TwoServerRedirects) { 1759 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, TwoServerRedirects) {
1760 GURL initial_url = embedded_test_server()->GetURL(kSingleFrameTestURL); 1760 GURL initial_url = embedded_test_server()->GetURL(kSingleFrameTestURL);
1761 GURL destination_url = embedded_test_server()->GetURL(kDownloadItemURL); 1761 GURL destination_url = embedded_test_server()->GetURL(kDownloadItemURL);
(...skipping 23 matching lines...) Expand all
1785 true, // has_server_redirect 1785 true, // has_server_redirect
1786 nav_list->Get(1)); 1786 nav_list->Get(1));
1787 const auto redirect_vector = nav_list->Get(1)->server_redirect_urls; 1787 const auto redirect_vector = nav_list->Get(1)->server_redirect_urls;
1788 ASSERT_EQ(2U, redirect_vector.size()); 1788 ASSERT_EQ(2U, redirect_vector.size());
1789 EXPECT_EQ(redirect_url, redirect_vector.at(0)); 1789 EXPECT_EQ(redirect_url, redirect_vector.at(0));
1790 EXPECT_EQ(destination_url, redirect_vector.at(1)); 1790 EXPECT_EQ(destination_url, redirect_vector.at(1));
1791 1791
1792 ReferrerChain referrer_chain; 1792 ReferrerChain referrer_chain;
1793 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 1793 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
1794 ASSERT_EQ(1, referrer_chain.size()); 1794 ASSERT_EQ(1, referrer_chain.size());
1795 VerifyReferrerChainEntry(destination_url, // url 1795 VerifyReferrerChainEntry(destination_url, // url
1796 GURL(), // main_frame_url 1796 GURL(), // main_frame_url
1797 ReferrerChainEntry::DOWNLOAD_URL, // type 1797 ReferrerChainEntry::EVENT_URL, // type
1798 test_server_ip, // ip_address 1798 test_server_ip, // ip_address
1799 GURL(), // referrer_url 1799 GURL(), // referrer_url
1800 GURL(), // referrer_main_frame_url 1800 GURL(), // referrer_main_frame_url
1801 false, // is_retargeting 1801 false, // is_retargeting
1802 {request_url, redirect_url, destination_url}, 1802 {request_url, redirect_url, destination_url},
1803 referrer_chain.Get(0)); 1803 referrer_chain.Get(0));
1804 } 1804 }
1805 1805
1806 // Retargeting immediately followed by server-side redirect. 1806 // Retargeting immediately followed by server-side redirect.
1807 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, 1807 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
1808 RetargetingAndServerRedirect) { 1808 RetargetingAndServerRedirect) {
1809 GURL initial_url = embedded_test_server()->GetURL(kSingleFrameTestURL); 1809 GURL initial_url = embedded_test_server()->GetURL(kSingleFrameTestURL);
(...skipping 26 matching lines...) Expand all
1836 request_url, // original_request_url 1836 request_url, // original_request_url
1837 download_url, // destination_url 1837 download_url, // destination_url
1838 false, // is_user_initiated, 1838 false, // is_user_initiated,
1839 false, // has_committed 1839 false, // has_committed
1840 true, // has_server_redirect 1840 true, // has_server_redirect
1841 nav_list->Get(2)); 1841 nav_list->Get(2));
1842 1842
1843 ReferrerChain referrer_chain; 1843 ReferrerChain referrer_chain;
1844 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); 1844 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
1845 ASSERT_EQ(2, referrer_chain.size()); 1845 ASSERT_EQ(2, referrer_chain.size());
1846 VerifyReferrerChainEntry(download_url, // url 1846 VerifyReferrerChainEntry(download_url, // url
1847 GURL(), // main_frame_url 1847 GURL(), // main_frame_url
1848 ReferrerChainEntry::DOWNLOAD_URL, // type 1848 ReferrerChainEntry::EVENT_URL, // type
1849 test_server_ip, // ip_address 1849 test_server_ip, // ip_address
1850 initial_url, // referrer_url 1850 initial_url, // referrer_url
1851 GURL(), // referrer_main_frame_url 1851 GURL(), // referrer_main_frame_url
1852 true, // is_retargeting 1852 true, // is_retargeting
1853 {request_url, download_url}, // server redirects 1853 {request_url, download_url}, // server redirects
1854 referrer_chain.Get(0)); 1854 referrer_chain.Get(0));
1855 VerifyReferrerChainEntry(initial_url, // url 1855 VerifyReferrerChainEntry(initial_url, // url
1856 GURL(), // main_frame_url 1856 GURL(), // main_frame_url
1857 ReferrerChainEntry::LANDING_PAGE, // type 1857 ReferrerChainEntry::LANDING_PAGE, // type
1858 test_server_ip, // ip_address 1858 test_server_ip, // ip_address
1859 GURL(), // referrer_url 1859 GURL(), // referrer_url
1860 GURL(), // referrer_main_frame_url 1860 GURL(), // referrer_main_frame_url
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 GURL(), // main_frame_url 1959 GURL(), // main_frame_url
1960 ReferrerChainEntry::CLIENT_REDIRECT, // type 1960 ReferrerChainEntry::CLIENT_REDIRECT, // type
1961 test_server_ip, // ip_address 1961 test_server_ip, // ip_address
1962 GURL(), // referrer_url 1962 GURL(), // referrer_url
1963 GURL(), // referrer_main_frame_url 1963 GURL(), // referrer_main_frame_url
1964 false, // is_retargeting 1964 false, // is_retargeting
1965 std::vector<GURL>(), // server redirects 1965 std::vector<GURL>(), // server redirects
1966 referrer_chain.Get(0)); 1966 referrer_chain.Get(0));
1967 } 1967 }
1968 } // namespace safe_browsing 1968 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698