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

Unified 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, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_navigation_observer_browsertest.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_navigation_observer_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_navigation_observer_browsertest.cc
index 85dbd76322c642d3fec1b50698dadcc1d7017186..3600ad687592f65e5973a12cfb2ffd7f82a9b2ee 100644
--- a/chrome/browser/safe_browsing/safe_browsing_navigation_observer_browsertest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_navigation_observer_browsertest.cc
@@ -356,14 +356,14 @@ class SBNavigationObserverBrowserTest : public InProcessBrowserTest {
ReferrerChain* referrer_chain) {
int download_tab_id =
SessionTabHelper::IdForTab(download->GetWebContents());
- auto result = observer_manager_->IdentifyReferrerChainForDownload(
+ auto result = observer_manager_->IdentifyReferrerChainByEventURL(
download->GetURL(), download_tab_id,
2, // kDownloadAttributionUserGestureLimit
referrer_chain);
if (result ==
SafeBrowsingNavigationObserverManager::NAVIGATION_EVENT_NOT_FOUND) {
DCHECK_EQ(0, referrer_chain->size());
- observer_manager_->IdentifyReferrerChainByDownloadWebContent(
+ observer_manager_->IdentifyReferrerChainByWebContent(
download->GetWebContents(),
2, // kDownloadAttributionUserGestureLimit
referrer_chain);
@@ -378,7 +378,7 @@ class SBNavigationObserverBrowserTest : public InProcessBrowserTest {
int tab_id = SessionTabHelper::IdForTab(web_contents);
bool has_user_gesture = observer_manager_->HasUserGesture(web_contents);
observer_manager_->OnUserGestureConsumed(web_contents, base::Time::Now());
- EXPECT_LE(observer_manager_->IdentifyReferrerChainForDownloadHostingPage(
+ EXPECT_LE(observer_manager_->IdentifyReferrerChainByHostingPage(
initiating_frame_url, web_contents->GetLastCommittedURL(),
tab_id, has_user_gesture,
2, // kDownloadAttributionUserGestureLimit
@@ -452,11 +452,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, TypeInURLDownload) {
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(1, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- GURL(), // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ GURL(), // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -492,11 +492,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, DirectDownload) {
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(2, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- initial_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ initial_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -544,11 +544,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(2, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- initial_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ initial_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -606,11 +606,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(2, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- initial_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ initial_url, // referrer_url
GURL(), // referrer_main_frame_url
true, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -669,11 +669,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(3, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- redirect_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ redirect_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -747,11 +747,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(3, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- redirect_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ redirect_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -828,11 +828,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(4, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- second_redirect_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ second_redirect_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -897,11 +897,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(2, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- initial_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ initial_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -958,11 +958,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, MixRedirects) {
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(3, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- redirect_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ redirect_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -1038,11 +1038,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, NewTabDownload) {
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(3, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- blank_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ blank_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -1122,11 +1122,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(3, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- "", // ip_address
- blank_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ "", // ip_address
+ blank_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -1214,11 +1214,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(4, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- iframe_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ iframe_url, // referrer_url
multi_frame_test_url, // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -1332,11 +1332,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
EXPECT_EQ(5, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- blank_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ blank_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -1429,11 +1429,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, CompleteReferrerChain) {
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
EXPECT_EQ(4, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- landing_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ landing_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -1532,11 +1532,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
EXPECT_EQ(3, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- landing_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ landing_url, // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
std::vector<GURL>(), // server redirects
@@ -1744,11 +1744,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, ServerRedirect) {
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(1, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- GURL(), // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ GURL(), // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
{request_url, download_url}, // server redirects
@@ -1792,11 +1792,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, TwoServerRedirects) {
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(1, referrer_chain.size());
- VerifyReferrerChainEntry(destination_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- GURL(), // referrer_url
+ VerifyReferrerChainEntry(destination_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ GURL(), // referrer_url
GURL(), // referrer_main_frame_url
false, // is_retargeting
{request_url, redirect_url, destination_url},
@@ -1843,11 +1843,11 @@ IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest,
ReferrerChain referrer_chain;
IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain);
ASSERT_EQ(2, referrer_chain.size());
- VerifyReferrerChainEntry(download_url, // url
- GURL(), // main_frame_url
- ReferrerChainEntry::DOWNLOAD_URL, // type
- test_server_ip, // ip_address
- initial_url, // referrer_url
+ VerifyReferrerChainEntry(download_url, // url
+ GURL(), // main_frame_url
+ ReferrerChainEntry::EVENT_URL, // type
+ test_server_ip, // ip_address
+ initial_url, // referrer_url
GURL(), // referrer_main_frame_url
true, // is_retargeting
{request_url, download_url}, // server redirects

Powered by Google App Engine
This is Rietveld 408576698