OLD | NEW |
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 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 EXPECT_NE(yesterday, ip_map->at(test_server_host).front().timestamp); | 1904 EXPECT_NE(yesterday, ip_map->at(test_server_host).front().timestamp); |
1905 } | 1905 } |
1906 | 1906 |
1907 // Download via html5 file API with user gesture. | 1907 // Download via html5 file API with user gesture. |
1908 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, | 1908 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, |
1909 DownloadViaHTML5FileApiWithUserGesture) { | 1909 DownloadViaHTML5FileApiWithUserGesture) { |
1910 GURL hosting_url = embedded_test_server()->GetURL(kSingleFrameTestURL); | 1910 GURL hosting_url = embedded_test_server()->GetURL(kSingleFrameTestURL); |
1911 // Trigger download by user gesture. | 1911 // Trigger download by user gesture. |
1912 TriggerDownloadViaHtml5FileApi(true /* has_user_gesture */); | 1912 TriggerDownloadViaHtml5FileApi(true /* has_user_gesture */); |
1913 std::string test_server_ip(embedded_test_server()->host_port_pair().host()); | 1913 std::string test_server_ip(embedded_test_server()->host_port_pair().host()); |
1914 auto* nav_list = navigation_event_list(); | 1914 auto nav_list = navigation_event_list(); |
1915 ASSERT_TRUE(nav_list); | 1915 ASSERT_TRUE(nav_list); |
1916 ASSERT_EQ(1U, nav_list->Size()); | 1916 ASSERT_EQ(1U, nav_list->Size()); |
1917 VerifyNavigationEvent(GURL(), // source_url | 1917 VerifyNavigationEvent(GURL(), // source_url |
1918 GURL(), // source_main_frame_url | 1918 GURL(), // source_main_frame_url |
1919 hosting_url, // original_request_url | 1919 hosting_url, // original_request_url |
1920 hosting_url, // destination_url | 1920 hosting_url, // destination_url |
1921 true, // is_user_initiated, | 1921 true, // is_user_initiated, |
1922 true, // has_committed | 1922 true, // has_committed |
1923 false, // has_server_redirect | 1923 false, // has_server_redirect |
1924 nav_list->Get(0)); | 1924 nav_list->Get(0)); |
(...skipping 13 matching lines...) Expand all Loading... |
1938 referrer_chain.Get(0)); | 1938 referrer_chain.Get(0)); |
1939 } | 1939 } |
1940 | 1940 |
1941 // Download via html5 file API without user gesture. | 1941 // Download via html5 file API without user gesture. |
1942 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, | 1942 IN_PROC_BROWSER_TEST_F(SBNavigationObserverBrowserTest, |
1943 DownloadViaHTML5FileApiWithoutUserGesture) { | 1943 DownloadViaHTML5FileApiWithoutUserGesture) { |
1944 GURL hosting_url = embedded_test_server()->GetURL(kSingleFrameTestURL); | 1944 GURL hosting_url = embedded_test_server()->GetURL(kSingleFrameTestURL); |
1945 // Trigger download without user gesture. | 1945 // Trigger download without user gesture. |
1946 TriggerDownloadViaHtml5FileApi(false /* has_user_gesture */); | 1946 TriggerDownloadViaHtml5FileApi(false /* has_user_gesture */); |
1947 std::string test_server_ip(embedded_test_server()->host_port_pair().host()); | 1947 std::string test_server_ip(embedded_test_server()->host_port_pair().host()); |
1948 auto* nav_list = navigation_event_list(); | 1948 auto nav_list = navigation_event_list(); |
1949 ASSERT_TRUE(nav_list); | 1949 ASSERT_TRUE(nav_list); |
1950 ASSERT_EQ(1U, nav_list->Size()); | 1950 ASSERT_EQ(1U, nav_list->Size()); |
1951 VerifyNavigationEvent(GURL(), // source_url | 1951 VerifyNavigationEvent(GURL(), // source_url |
1952 GURL(), // source_main_frame_url | 1952 GURL(), // source_main_frame_url |
1953 hosting_url, // original_request_url | 1953 hosting_url, // original_request_url |
1954 hosting_url, // destination_url | 1954 hosting_url, // destination_url |
1955 true, // is_user_initiated, | 1955 true, // is_user_initiated, |
1956 true, // has_committed | 1956 true, // has_committed |
1957 false, // has_server_redirect | 1957 false, // has_server_redirect |
1958 nav_list->Get(0)); | 1958 nav_list->Get(0)); |
1959 VerifyHostToIpMap(); | 1959 VerifyHostToIpMap(); |
1960 ReferrerChain referrer_chain; | 1960 ReferrerChain referrer_chain; |
1961 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); | 1961 IdentifyReferrerChainForDownload(GetDownload(), &referrer_chain); |
1962 ASSERT_EQ(1, referrer_chain.size()); | 1962 ASSERT_EQ(1, referrer_chain.size()); |
1963 | 1963 |
1964 VerifyReferrerChainEntry(hosting_url, // url | 1964 VerifyReferrerChainEntry(hosting_url, // url |
1965 GURL(), // main_frame_url | 1965 GURL(), // main_frame_url |
1966 ReferrerChainEntry::CLIENT_REDIRECT, // type | 1966 ReferrerChainEntry::CLIENT_REDIRECT, // type |
1967 test_server_ip, // ip_address | 1967 test_server_ip, // ip_address |
1968 GURL(), // referrer_url | 1968 GURL(), // referrer_url |
1969 GURL(), // referrer_main_frame_url | 1969 GURL(), // referrer_main_frame_url |
1970 false, // is_retargeting | 1970 false, // is_retargeting |
1971 std::vector<GURL>(), // server redirects | 1971 std::vector<GURL>(), // server redirects |
1972 referrer_chain.Get(0)); | 1972 referrer_chain.Get(0)); |
1973 } | 1973 } |
1974 } // namespace safe_browsing | 1974 } // namespace safe_browsing |
OLD | NEW |