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/safe_browsing/download_protection_service.h" | 5 #include "chrome/browser/safe_browsing/download_protection_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 | 549 |
550 void DownloadProtectionServiceTest::CheckClientDownloadReportCorruptArchive( | 550 void DownloadProtectionServiceTest::CheckClientDownloadReportCorruptArchive( |
551 ArchiveType type, | 551 ArchiveType type, |
552 bool is_extended_reporting, | 552 bool is_extended_reporting, |
553 bool is_incognito) { | 553 bool is_incognito) { |
554 net::FakeURLFetcherFactory factory(NULL); | 554 net::FakeURLFetcherFactory factory(NULL); |
555 PrepareResponse( | 555 PrepareResponse( |
556 &factory, ClientDownloadResponse::SAFE, net::HTTP_OK, | 556 &factory, ClientDownloadResponse::SAFE, net::HTTP_OK, |
557 net::URLRequestStatus::SUCCESS); | 557 net::URLRequestStatus::SUCCESS); |
558 | 558 |
559 profile_->GetPrefs()->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, | 559 SetExtendedReportingPreference(is_extended_reporting); |
560 is_extended_reporting); | |
561 content::MockDownloadItem item; | 560 content::MockDownloadItem item; |
562 if (type == ZIP) { | 561 if (type == ZIP) { |
563 PrepareBasicDownloadItem(&item, {"http://www.evil.com/a.zip"}, // url_chain | 562 PrepareBasicDownloadItem(&item, {"http://www.evil.com/a.zip"}, // url_chain |
564 "http://www.google.com/", // referrer | 563 "http://www.google.com/", // referrer |
565 FILE_PATH_LITERAL("a.tmp"), // tmp_path | 564 FILE_PATH_LITERAL("a.tmp"), // tmp_path |
566 FILE_PATH_LITERAL("a.zip")); // final_path | 565 FILE_PATH_LITERAL("a.zip")); // final_path |
567 } else if (type == DMG) { | 566 } else if (type == DMG) { |
568 PrepareBasicDownloadItem(&item, {"http://www.evil.com/a.dmg"}, // url_chain | 567 PrepareBasicDownloadItem(&item, {"http://www.evil.com/a.dmg"}, // url_chain |
569 "http://www.google.com/", // referrer | 568 "http://www.google.com/", // referrer |
570 FILE_PATH_LITERAL("a.tmp"), // tmp_path | 569 FILE_PATH_LITERAL("a.tmp"), // tmp_path |
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1980 EXPECT_EQ(token, DownloadProtectionService::GetDownloadPingToken(&item)); | 1979 EXPECT_EQ(token, DownloadProtectionService::GetDownloadPingToken(&item)); |
1981 | 1980 |
1982 DownloadProtectionService::SetDownloadPingToken(&item, std::string()); | 1981 DownloadProtectionService::SetDownloadPingToken(&item, std::string()); |
1983 EXPECT_TRUE(DownloadProtectionService::GetDownloadPingToken(&item).empty()); | 1982 EXPECT_TRUE(DownloadProtectionService::GetDownloadPingToken(&item).empty()); |
1984 } | 1983 } |
1985 | 1984 |
1986 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Unsupported) { | 1985 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Unsupported) { |
1987 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt")); | 1986 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt")); |
1988 std::vector<base::FilePath::StringType> alternate_extensions{ | 1987 std::vector<base::FilePath::StringType> alternate_extensions{ |
1989 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".asdfasdf")}; | 1988 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".asdfasdf")}; |
1989 SetExtendedReportingPreference(false); | |
1990 download_service_->CheckPPAPIDownloadRequest( | 1990 download_service_->CheckPPAPIDownloadRequest( |
1991 GURL("http://example.com/foo"), default_file_path, alternate_extensions, | 1991 GURL("http://example.com/foo"), default_file_path, alternate_extensions, |
1992 profile_.get(), | |
1992 base::Bind(&DownloadProtectionServiceTest::SyncCheckDoneCallback, | 1993 base::Bind(&DownloadProtectionServiceTest::SyncCheckDoneCallback, |
1993 base::Unretained(this))); | 1994 base::Unretained(this))); |
1994 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 1995 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
1995 } | 1996 } |
1996 | 1997 |
1997 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedDefault) { | 1998 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedDefault) { |
1998 net::FakeURLFetcherFactory factory(nullptr); | 1999 net::FakeURLFetcherFactory factory(nullptr); |
1999 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); | 2000 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); |
2000 std::vector<base::FilePath::StringType> alternate_extensions; | 2001 std::vector<base::FilePath::StringType> alternate_extensions; |
2001 EXPECT_CALL(*sb_service_->mock_database_manager(), | 2002 EXPECT_CALL(*sb_service_->mock_database_manager(), |
(...skipping 10 matching lines...) Expand all Loading... | |
2012 DownloadProtectionService::DANGEROUS_HOST}, | 2013 DownloadProtectionService::DANGEROUS_HOST}, |
2013 {ClientDownloadResponse::POTENTIALLY_UNWANTED, | 2014 {ClientDownloadResponse::POTENTIALLY_UNWANTED, |
2014 DownloadProtectionService::POTENTIALLY_UNWANTED}, | 2015 DownloadProtectionService::POTENTIALLY_UNWANTED}, |
2015 {ClientDownloadResponse::UNKNOWN, DownloadProtectionService::UNKNOWN}, | 2016 {ClientDownloadResponse::UNKNOWN, DownloadProtectionService::UNKNOWN}, |
2016 }; | 2017 }; |
2017 | 2018 |
2018 for (const auto& test_case : kExpectedResults) { | 2019 for (const auto& test_case : kExpectedResults) { |
2019 factory.ClearFakeResponses(); | 2020 factory.ClearFakeResponses(); |
2020 PrepareResponse(&factory, test_case.verdict, net::HTTP_OK, | 2021 PrepareResponse(&factory, test_case.verdict, net::HTTP_OK, |
2021 net::URLRequestStatus::SUCCESS); | 2022 net::URLRequestStatus::SUCCESS); |
2023 SetExtendedReportingPreference(false); | |
2022 download_service_->CheckPPAPIDownloadRequest( | 2024 download_service_->CheckPPAPIDownloadRequest( |
2023 GURL("http://example.com/foo"), default_file_path, alternate_extensions, | 2025 GURL("http://example.com/foo"), default_file_path, alternate_extensions, |
2026 profile_.get(), | |
2024 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 2027 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
2025 base::Unretained(this))); | 2028 base::Unretained(this))); |
2026 base::RunLoop().Run(); | 2029 base::RunLoop().Run(); |
2027 ASSERT_TRUE(IsResult(test_case.expected_result)); | 2030 ASSERT_TRUE(IsResult(test_case.expected_result)); |
2028 } | 2031 } |
2029 } | 2032 } |
2030 | 2033 |
2031 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedAlternate) { | 2034 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedAlternate) { |
2032 net::FakeURLFetcherFactory factory(nullptr); | 2035 net::FakeURLFetcherFactory factory(nullptr); |
2033 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt")); | 2036 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt")); |
2034 std::vector<base::FilePath::StringType> alternate_extensions{ | 2037 std::vector<base::FilePath::StringType> alternate_extensions{ |
2035 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".crx")}; | 2038 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".crx")}; |
2036 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, | 2039 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, |
2037 net::URLRequestStatus::SUCCESS); | 2040 net::URLRequestStatus::SUCCESS); |
2038 EXPECT_CALL(*sb_service_->mock_database_manager(), | 2041 EXPECT_CALL(*sb_service_->mock_database_manager(), |
2039 MatchDownloadWhitelistUrl(_)) | 2042 MatchDownloadWhitelistUrl(_)) |
2040 .WillRepeatedly(Return(false)); | 2043 .WillRepeatedly(Return(false)); |
2044 SetExtendedReportingPreference(false); | |
2041 download_service_->CheckPPAPIDownloadRequest( | 2045 download_service_->CheckPPAPIDownloadRequest( |
2042 GURL("http://example.com/foo"), default_file_path, alternate_extensions, | 2046 GURL("http://example.com/foo"), default_file_path, alternate_extensions, |
2047 profile_.get(), | |
2043 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 2048 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
2044 base::Unretained(this))); | 2049 base::Unretained(this))); |
2045 base::RunLoop().Run(); | 2050 base::RunLoop().Run(); |
2046 | 2051 |
2047 ASSERT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | 2052 ASSERT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
2048 } | 2053 } |
2049 | 2054 |
2050 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_WhitelistedURL) { | 2055 TEST_F(DownloadProtectionServiceTest, |
2056 PPAPIDownloadRequest_WhitelistedURLNotExtendedReporting) { | |
2051 net::FakeURLFetcherFactory factory(nullptr); | 2057 net::FakeURLFetcherFactory factory(nullptr); |
2052 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); | 2058 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); |
2053 std::vector<base::FilePath::StringType> alternate_extensions; | 2059 std::vector<base::FilePath::StringType> alternate_extensions; |
2060 // Configs "server" side response to DANGEROUS, in case a request is send out. | |
2061 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, | |
2062 net::URLRequestStatus::SUCCESS); | |
2054 EXPECT_CALL(*sb_service_->mock_database_manager(), | 2063 EXPECT_CALL(*sb_service_->mock_database_manager(), |
2055 MatchDownloadWhitelistUrl(_)) | 2064 MatchDownloadWhitelistUrl(_)) |
2056 .WillRepeatedly(Return(true)); | 2065 .WillRepeatedly(Return(true)); |
2066 SetExtendedReportingPreference(false); | |
2067 // Sets the sample rate to 1.00. | |
2068 SetWhitelistedDownloadSampleRate(1.00); | |
2057 download_service_->CheckPPAPIDownloadRequest( | 2069 download_service_->CheckPPAPIDownloadRequest( |
2058 GURL("http://example.com/foo"), default_file_path, alternate_extensions, | 2070 GURL("http://example.com/foo"), default_file_path, alternate_extensions, |
2071 profile_.get(), | |
2059 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 2072 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
2060 base::Unretained(this))); | 2073 base::Unretained(this))); |
2061 base::RunLoop().Run(); | 2074 base::RunLoop().Run(); |
asanka
2016/07/15 14:59:52
Perhaps not for this CL since it's going to involv
Jialiu Lin
2016/07/15 22:10:56
Thanks for your detailed explanation on RunLoop. I
| |
2062 | 2075 |
2076 // Result should be SAFE, since download matches whitelist but user is not in | |
2077 // extended reporting group (a.k.a no request sents out). | |
2063 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 2078 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
2064 } | 2079 } |
2065 | 2080 |
2081 TEST_F(DownloadProtectionServiceTest, | |
2082 PPAPIDownloadRequest_WhitelistedURLIncognito) { | |
2083 net::FakeURLFetcherFactory factory(nullptr); | |
2084 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); | |
2085 std::vector<base::FilePath::StringType> alternate_extensions; | |
2086 // Configs "server" side response to DANGEROUS, in case a request is send out. | |
2087 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, | |
2088 net::URLRequestStatus::SUCCESS); | |
2089 EXPECT_CALL(*sb_service_->mock_database_manager(), | |
2090 MatchDownloadWhitelistUrl(_)) | |
2091 .WillRepeatedly(Return(true)); | |
2092 SetExtendedReportingPreference(true); | |
2093 download_service_->CheckPPAPIDownloadRequest( | |
2094 GURL("http://example.com/foo"), default_file_path, alternate_extensions, | |
2095 profile_->GetOffTheRecordProfile(), | |
2096 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | |
2097 base::Unretained(this))); | |
2098 base::RunLoop().Run(); | |
2099 | |
2100 // Result should still be SAFE, since download matches whitelist and user is | |
2101 // in incognito mode. | |
2102 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); | |
2103 } | |
2104 | |
2105 TEST_F(DownloadProtectionServiceTest, | |
2106 PPAPIDownloadRequest_SampleWhitelistedURL) { | |
2107 net::FakeURLFetcherFactory factory(nullptr); | |
2108 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); | |
2109 std::vector<base::FilePath::StringType> alternate_extensions; | |
2110 // Configs "server" side response to DANGEROUS. | |
2111 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, | |
2112 net::URLRequestStatus::SUCCESS); | |
2113 EXPECT_CALL(*sb_service_->mock_database_manager(), | |
2114 MatchDownloadWhitelistUrl(_)) | |
2115 .WillRepeatedly(Return(true)); | |
2116 // Sets the sample rate to 1.00 to trigger ClientDownloadRequest. | |
2117 SetWhitelistedDownloadSampleRate(1.00); | |
2118 SetExtendedReportingPreference(true); | |
2119 download_service_->CheckPPAPIDownloadRequest( | |
2120 GURL("http://example.com/foo"), default_file_path, alternate_extensions, | |
2121 profile_.get(), | |
2122 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | |
2123 base::Unretained(this))); | |
2124 base::RunLoop().Run(); | |
2125 | |
2126 // Result should be Dangerous, since we will sample this download and ping SB | |
2127 // Server (server returns DANGEROUS verdict). | |
2128 ASSERT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | |
2129 } | |
2130 | |
2066 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_FetchFailed) { | 2131 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_FetchFailed) { |
2067 net::FakeURLFetcherFactory factory(nullptr); | 2132 net::FakeURLFetcherFactory factory(nullptr); |
2068 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); | 2133 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); |
2069 std::vector<base::FilePath::StringType> alternate_extensions; | 2134 std::vector<base::FilePath::StringType> alternate_extensions; |
2070 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, | 2135 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, |
2071 net::URLRequestStatus::FAILED); | 2136 net::URLRequestStatus::FAILED); |
2072 EXPECT_CALL(*sb_service_->mock_database_manager(), | 2137 EXPECT_CALL(*sb_service_->mock_database_manager(), |
2073 MatchDownloadWhitelistUrl(_)) | 2138 MatchDownloadWhitelistUrl(_)) |
2074 .WillRepeatedly(Return(false)); | 2139 .WillRepeatedly(Return(false)); |
2140 SetExtendedReportingPreference(false); | |
2075 download_service_->CheckPPAPIDownloadRequest( | 2141 download_service_->CheckPPAPIDownloadRequest( |
2076 GURL("http://example.com/foo"), default_file_path, alternate_extensions, | 2142 GURL("http://example.com/foo"), default_file_path, alternate_extensions, |
2143 profile_.get(), | |
2077 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 2144 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
2078 base::Unretained(this))); | 2145 base::Unretained(this))); |
2079 base::RunLoop().Run(); | 2146 base::RunLoop().Run(); |
2080 | 2147 |
2081 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); | 2148 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); |
2082 } | 2149 } |
2083 | 2150 |
2084 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_InvalidResponse) { | 2151 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_InvalidResponse) { |
2085 net::FakeURLFetcherFactory factory(nullptr); | 2152 net::FakeURLFetcherFactory factory(nullptr); |
2086 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); | 2153 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); |
2087 std::vector<base::FilePath::StringType> alternate_extensions; | 2154 std::vector<base::FilePath::StringType> alternate_extensions; |
2088 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(), | 2155 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(), |
2089 "Hello world!", net::HTTP_OK, | 2156 "Hello world!", net::HTTP_OK, |
2090 net::URLRequestStatus::SUCCESS); | 2157 net::URLRequestStatus::SUCCESS); |
2091 EXPECT_CALL(*sb_service_->mock_database_manager(), | 2158 EXPECT_CALL(*sb_service_->mock_database_manager(), |
2092 MatchDownloadWhitelistUrl(_)) | 2159 MatchDownloadWhitelistUrl(_)) |
2093 .WillRepeatedly(Return(false)); | 2160 .WillRepeatedly(Return(false)); |
2161 SetExtendedReportingPreference(false); | |
2094 download_service_->CheckPPAPIDownloadRequest( | 2162 download_service_->CheckPPAPIDownloadRequest( |
2095 GURL("http://example.com/foo"), default_file_path, alternate_extensions, | 2163 GURL("http://example.com/foo"), default_file_path, alternate_extensions, |
2164 profile_.get(), | |
2096 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 2165 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
2097 base::Unretained(this))); | 2166 base::Unretained(this))); |
2098 base::RunLoop().Run(); | 2167 base::RunLoop().Run(); |
2099 | 2168 |
2100 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); | 2169 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); |
2101 } | 2170 } |
2102 | 2171 |
2103 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Timeout) { | 2172 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Timeout) { |
2104 net::FakeURLFetcherFactory factory(nullptr); | 2173 net::FakeURLFetcherFactory factory(nullptr); |
2105 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); | 2174 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); |
2106 std::vector<base::FilePath::StringType> alternate_extensions; | 2175 std::vector<base::FilePath::StringType> alternate_extensions; |
2107 EXPECT_CALL(*sb_service_->mock_database_manager(), | 2176 EXPECT_CALL(*sb_service_->mock_database_manager(), |
2108 MatchDownloadWhitelistUrl(_)) | 2177 MatchDownloadWhitelistUrl(_)) |
2109 .WillRepeatedly(Return(false)); | 2178 .WillRepeatedly(Return(false)); |
2110 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK, | 2179 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK, |
2111 net::URLRequestStatus::SUCCESS); | 2180 net::URLRequestStatus::SUCCESS); |
2112 download_service_->download_request_timeout_ms_ = 0; | 2181 download_service_->download_request_timeout_ms_ = 0; |
2182 SetExtendedReportingPreference(false); | |
2113 download_service_->CheckPPAPIDownloadRequest( | 2183 download_service_->CheckPPAPIDownloadRequest( |
2114 GURL("http://example.com/foo"), default_file_path, alternate_extensions, | 2184 GURL("http://example.com/foo"), default_file_path, alternate_extensions, |
2185 profile_.get(), | |
2115 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 2186 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
2116 base::Unretained(this))); | 2187 base::Unretained(this))); |
2117 base::RunLoop().Run(); | 2188 base::RunLoop().Run(); |
2118 | 2189 |
2119 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); | 2190 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); |
2120 } | 2191 } |
2121 | 2192 |
2122 namespace { | 2193 namespace { |
2123 | 2194 |
2124 std::unique_ptr<net::FakeURLFetcher> FakeURLFetcherCreatorFunc( | 2195 std::unique_ptr<net::FakeURLFetcher> FakeURLFetcherCreatorFunc( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2163 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); | 2234 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); |
2164 std::vector<base::FilePath::StringType> alternate_extensions{ | 2235 std::vector<base::FilePath::StringType> alternate_extensions{ |
2165 FILE_PATH_LITERAL(".txt"), FILE_PATH_LITERAL(".abc"), | 2236 FILE_PATH_LITERAL(".txt"), FILE_PATH_LITERAL(".abc"), |
2166 FILE_PATH_LITERAL(""), FILE_PATH_LITERAL(".sdF")}; | 2237 FILE_PATH_LITERAL(""), FILE_PATH_LITERAL(".sdF")}; |
2167 EXPECT_CALL(*sb_service_->mock_database_manager(), | 2238 EXPECT_CALL(*sb_service_->mock_database_manager(), |
2168 MatchDownloadWhitelistUrl(_)) | 2239 MatchDownloadWhitelistUrl(_)) |
2169 .WillRepeatedly(Return(false)); | 2240 .WillRepeatedly(Return(false)); |
2170 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK, | 2241 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK, |
2171 net::URLRequestStatus::SUCCESS); | 2242 net::URLRequestStatus::SUCCESS); |
2172 const GURL kRequestorUrl("http://example.com/foo"); | 2243 const GURL kRequestorUrl("http://example.com/foo"); |
2244 SetExtendedReportingPreference(false); | |
2173 download_service_->CheckPPAPIDownloadRequest( | 2245 download_service_->CheckPPAPIDownloadRequest( |
2174 kRequestorUrl, default_file_path, alternate_extensions, | 2246 kRequestorUrl, default_file_path, alternate_extensions, profile_.get(), |
2175 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 2247 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
2176 base::Unretained(this))); | 2248 base::Unretained(this))); |
2177 base::RunLoop().Run(); | 2249 base::RunLoop().Run(); |
2178 | 2250 |
2179 ASSERT_FALSE(upload_data.empty()); | 2251 ASSERT_FALSE(upload_data.empty()); |
2180 | 2252 |
2181 ClientDownloadRequest request; | 2253 ClientDownloadRequest request; |
2182 ASSERT_TRUE(request.ParseFromString(upload_data)); | 2254 ASSERT_TRUE(request.ParseFromString(upload_data)); |
2183 | 2255 |
2184 EXPECT_EQ(ClientDownloadRequest::PPAPI_SAVE_REQUEST, request.download_type()); | 2256 EXPECT_EQ(ClientDownloadRequest::PPAPI_SAVE_REQUEST, request.download_type()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2265 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 2337 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
2266 base::Unretained(this))); | 2338 base::Unretained(this))); |
2267 base::RunLoop().Run(); | 2339 base::RunLoop().Run(); |
2268 | 2340 |
2269 EXPECT_FALSE(HasClientDownloadRequest()); | 2341 EXPECT_FALSE(HasClientDownloadRequest()); |
2270 // Overriden by flag: | 2342 // Overriden by flag: |
2271 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | 2343 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
2272 } | 2344 } |
2273 | 2345 |
2274 } // namespace safe_browsing | 2346 } // namespace safe_browsing |
OLD | NEW |