OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 Mode mode_; | 124 Mode mode_; |
125 }; | 125 }; |
126 | 126 |
127 class FakeDatabaseManager | 127 class FakeDatabaseManager |
128 : public safe_browsing::TestSafeBrowsingDatabaseManager { | 128 : public safe_browsing::TestSafeBrowsingDatabaseManager { |
129 public: | 129 public: |
130 bool IsSupported() const override { return true; } | 130 bool IsSupported() const override { return true; } |
131 bool MatchDownloadWhitelistUrl(const GURL& url) override { | 131 bool MatchDownloadWhitelistUrl(const GURL& url) override { |
132 // This matches the behavior in RunTestViaHTTP(). | 132 // This matches the behavior in RunTestViaHTTP(). |
133 return url.SchemeIsHTTPOrHTTPS() && url.has_path() && | 133 return url.SchemeIsHTTPOrHTTPS() && url.has_path() && |
134 url.path().find("/files/test_case.html") == 0; | 134 url.path().find("/test_case.html") == 0; |
135 } | 135 } |
136 | 136 |
137 protected: | 137 protected: |
138 ~FakeDatabaseManager() override {} | 138 ~FakeDatabaseManager() override {} |
139 }; | 139 }; |
140 | 140 |
141 class TestSafeBrowsingService : public SafeBrowsingService { | 141 class TestSafeBrowsingService : public SafeBrowsingService { |
142 public: | 142 public: |
143 safe_browsing::SafeBrowsingDatabaseManager* CreateDatabaseManager() override { | 143 safe_browsing::SafeBrowsingDatabaseManager* CreateDatabaseManager() override { |
144 return new FakeDatabaseManager(); | 144 return new FakeDatabaseManager(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 RunTestViaHTTP("FileChooser_SaveAsDangerousExecutableAllowed"); | 331 RunTestViaHTTP("FileChooser_SaveAsDangerousExecutableAllowed"); |
332 base::FilePath actual_filename = temp_dir.path().AppendASCII("dangerous.exe"); | 332 base::FilePath actual_filename = temp_dir.path().AppendASCII("dangerous.exe"); |
333 | 333 |
334 ASSERT_TRUE(base::PathExists(actual_filename)); | 334 ASSERT_TRUE(base::PathExists(actual_filename)); |
335 std::string file_contents; | 335 std::string file_contents; |
336 ASSERT_TRUE(base::ReadFileToString(actual_filename, &file_contents, 100)); | 336 ASSERT_TRUE(base::ReadFileToString(actual_filename, &file_contents, 100)); |
337 EXPECT_EQ("Hello from PPAPI", file_contents); | 337 EXPECT_EQ("Hello from PPAPI", file_contents); |
338 } | 338 } |
339 | 339 |
340 #endif // FULL_SAFE_BROWSING | 340 #endif // FULL_SAFE_BROWSING |
OLD | NEW |