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

Side by Side Diff: chrome/test/ppapi/ppapi_filechooser_browsertest.cc

Issue 2124373002: [PPAPI] Quarantine files that are writeable by a Pepper plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@consolidate-file-metadata
Patch Set: Address comments. Created 4 years 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
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 5 #include <map>
6 #include <vector>
6 7
7 #include "base/bind.h" 8 #include "base/bind.h"
8 #include "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/strings/string_piece.h"
11 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
12 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
13 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/ppapi/ppapi_test.h" 16 #include "chrome/test/ppapi/ppapi_test.h"
17 #include "content/public/common/quarantine.h"
15 #include "ppapi/shared_impl/test_utils.h" 18 #include "ppapi/shared_impl/test_utils.h"
16 #include "ui/shell_dialogs/select_file_dialog.h" 19 #include "ui/shell_dialogs/select_file_dialog.h"
17 #include "ui/shell_dialogs/select_file_dialog_factory.h" 20 #include "ui/shell_dialogs/select_file_dialog_factory.h"
18 #include "ui/shell_dialogs/selected_file_info.h" 21 #include "ui/shell_dialogs/selected_file_info.h"
19 22
20 #if defined(FULL_SAFE_BROWSING) 23 #if defined(FULL_SAFE_BROWSING)
21 #include "chrome/browser/safe_browsing/download_protection_service.h" 24 #include "chrome/browser/safe_browsing/download_protection_service.h"
22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
23 #include "components/safe_browsing_db/test_database_manager.h" 26 #include "components/safe_browsing_db/test_database_manager.h"
24 #include "content/public/test/test_download_request_handler.h" 27 #include "content/public/test/test_download_request_handler.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 EXPECT_EQ("Hello from PPAPI", file_contents); 350 EXPECT_EQ("Hello from PPAPI", file_contents);
348 } 351 }
349 352
350 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTest, FileChooser_SaveAs_Cancel) { 353 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTest, FileChooser_SaveAs_Cancel) {
351 TestSelectFileDialogFactory test_dialog_factory( 354 TestSelectFileDialogFactory test_dialog_factory(
352 TestSelectFileDialogFactory::CANCEL, 355 TestSelectFileDialogFactory::CANCEL,
353 TestSelectFileDialogFactory::SelectedFileInfoList()); 356 TestSelectFileDialogFactory::SelectedFileInfoList());
354 RunTestViaHTTP("FileChooser_SaveAsCancel"); 357 RunTestViaHTTP("FileChooser_SaveAsCancel");
355 } 358 }
356 359
360 #if defined(OS_WIN) || defined(OS_LINUX)
361 // On Windows, tests that a file downloaded via PPAPI FileChooser API has the
362 // mark-of-the-web. The PPAPI FileChooser implementation invokes QuarantineFile
363 // in order to mark the file as being downloaded from the web as soon as the
364 // file is created. This MOTW prevents the file being opened without due
365 // security warnings if the file is executable.
366 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTest, FileChooser_Quarantine) {
367 base::ScopedTempDir temp_dir;
368 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
369 base::FilePath suggested_filename = temp_dir.GetPath().AppendASCII("foo");
370
371 TestSelectFileDialogFactory::SelectedFileInfoList file_info_list;
372 file_info_list.push_back(
373 ui::SelectedFileInfo(suggested_filename, suggested_filename));
374 TestSelectFileDialogFactory test_dialog_factory(
375 TestSelectFileDialogFactory::REPLACE_BASENAME, file_info_list);
376
377 RunTestViaHTTP("FileChooser_SaveAsDangerousExecutableAllowed");
378 base::FilePath actual_filename =
379 temp_dir.GetPath().AppendASCII("dangerous.exe");
380
381 ASSERT_TRUE(base::PathExists(actual_filename));
382 EXPECT_TRUE(content::IsFileQuarantined(actual_filename, GURL(), GURL()));
383 }
384 #endif // defined(OS_WIN) || defined(OS_LINUX)
385
357 #if defined(FULL_SAFE_BROWSING) 386 #if defined(FULL_SAFE_BROWSING)
358 // These tests only make sense when SafeBrowsing is enabled. They verify 387 // These tests only make sense when SafeBrowsing is enabled. They verify
359 // that files written via the FileChooser_Trusted API are properly passed 388 // that files written via the FileChooser_Trusted API are properly passed
360 // through Safe Browsing. 389 // through Safe Browsing.
361 390
362 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTestWithSBService, 391 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTestWithSBService,
363 FileChooser_SaveAs_DangerousExecutable_Allowed) { 392 FileChooser_SaveAs_DangerousExecutable_Allowed) {
364 safe_browsing_test_configuration_.default_result = 393 safe_browsing_test_configuration_.default_result =
365 DownloadProtectionService::DANGEROUS; 394 DownloadProtectionService::DANGEROUS;
366 safe_browsing_test_configuration_.result_map.insert( 395 safe_browsing_test_configuration_.result_map.insert(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 std::make_pair(base::FilePath::StringType(FILE_PATH_LITERAL(".exe")), 438 std::make_pair(base::FilePath::StringType(FILE_PATH_LITERAL(".exe")),
410 DownloadProtectionService::DANGEROUS)); 439 DownloadProtectionService::DANGEROUS));
411 440
412 TestSelectFileDialogFactory test_dialog_factory( 441 TestSelectFileDialogFactory test_dialog_factory(
413 TestSelectFileDialogFactory::NOT_REACHED, 442 TestSelectFileDialogFactory::NOT_REACHED,
414 TestSelectFileDialogFactory::SelectedFileInfoList()); 443 TestSelectFileDialogFactory::SelectedFileInfoList());
415 RunTestViaHTTP("FileChooser_SaveAsDangerousExtensionListDisallowed"); 444 RunTestViaHTTP("FileChooser_SaveAsDangerousExtensionListDisallowed");
416 } 445 }
417 446
418 #endif // FULL_SAFE_BROWSING 447 #endif // FULL_SAFE_BROWSING
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698