Chromium Code Reviews| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/ppapi/ppapi_test.h" | 13 #include "chrome/test/ppapi/ppapi_test.h" |
| 14 #include "ppapi/shared_impl/test_utils.h" | 14 #include "ppapi/shared_impl/test_utils.h" |
| 15 #include "ui/shell_dialogs/select_file_dialog.h" | 15 #include "ui/shell_dialogs/select_file_dialog.h" |
| 16 #include "ui/shell_dialogs/select_file_dialog_factory.h" | 16 #include "ui/shell_dialogs/select_file_dialog_factory.h" |
| 17 #include "ui/shell_dialogs/selected_file_info.h" | 17 #include "ui/shell_dialogs/selected_file_info.h" |
| 18 | 18 |
| 19 #if defined(OS_WIN) | |
| 20 #include "base/win/scoped_handle.h" | |
| 21 #endif | |
| 22 | |
| 19 #if defined(FULL_SAFE_BROWSING) | 23 #if defined(FULL_SAFE_BROWSING) |
| 20 #include "chrome/browser/safe_browsing/download_protection_service.h" | 24 #include "chrome/browser/safe_browsing/download_protection_service.h" |
| 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 22 #include "components/safe_browsing_db/test_database_manager.h" | 26 #include "components/safe_browsing_db/test_database_manager.h" |
| 23 #include "content/public/test/test_download_request_handler.h" | 27 #include "content/public/test/test_download_request_handler.h" |
| 24 | 28 |
| 25 using safe_browsing::DownloadProtectionService; | 29 using safe_browsing::DownloadProtectionService; |
| 26 using safe_browsing::SafeBrowsingService; | 30 using safe_browsing::SafeBrowsingService; |
| 27 #endif | 31 #endif |
| 28 | 32 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 EXPECT_EQ("Hello from PPAPI", file_contents); | 346 EXPECT_EQ("Hello from PPAPI", file_contents); |
| 343 } | 347 } |
| 344 | 348 |
| 345 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTest, FileChooser_SaveAs_Cancel) { | 349 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTest, FileChooser_SaveAs_Cancel) { |
| 346 TestSelectFileDialogFactory test_dialog_factory( | 350 TestSelectFileDialogFactory test_dialog_factory( |
| 347 TestSelectFileDialogFactory::CANCEL, | 351 TestSelectFileDialogFactory::CANCEL, |
| 348 TestSelectFileDialogFactory::SelectedFileInfoList()); | 352 TestSelectFileDialogFactory::SelectedFileInfoList()); |
| 349 RunTestViaHTTP("FileChooser_SaveAsCancel"); | 353 RunTestViaHTTP("FileChooser_SaveAsCancel"); |
| 350 } | 354 } |
| 351 | 355 |
| 356 #if defined(OS_WIN) | |
|
bbudge
2016/07/11 20:08:22
Could you add a comment explaining what this tests
asanka
2016/09/12 16:07:04
Done.
| |
| 357 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTest, | |
| 358 FileChooser_WindowsMOTW_DependsOnLocalConfig) { | |
| 359 base::ScopedTempDir temp_dir; | |
| 360 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | |
| 361 base::FilePath suggested_filename = temp_dir.path().AppendASCII("foo"); | |
| 362 | |
| 363 TestSelectFileDialogFactory::SelectedFileInfoList file_info_list; | |
| 364 file_info_list.push_back( | |
| 365 ui::SelectedFileInfo(suggested_filename, suggested_filename)); | |
| 366 TestSelectFileDialogFactory test_dialog_factory( | |
| 367 TestSelectFileDialogFactory::REPLACE_BASENAME, file_info_list); | |
| 368 | |
| 369 RunTestViaHTTP("FileChooser_SaveAsDangerousExecutableAllowed"); | |
| 370 base::FilePath actual_filename = temp_dir.path().AppendASCII("dangerous.exe"); | |
| 371 | |
| 372 ASSERT_TRUE(base::PathExists(actual_filename)); | |
| 373 const DWORD kShare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; | |
| 374 base::FilePath::StringType zone_identifier_path = | |
| 375 actual_filename.value() + L":Zone.Identifier"; | |
| 376 base::win::ScopedHandle zone_identifier( | |
| 377 CreateFile(zone_identifier_path.c_str(), GENERIC_READ, kShare, nullptr, | |
| 378 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr)); | |
| 379 EXPECT_TRUE(zone_identifier.IsValid()); | |
| 380 } | |
| 381 #endif | |
| 382 | |
| 352 #if defined(FULL_SAFE_BROWSING) | 383 #if defined(FULL_SAFE_BROWSING) |
| 353 // These tests only make sense when SafeBrowsing is enabled. They verify | 384 // These tests only make sense when SafeBrowsing is enabled. They verify |
| 354 // that files written via the FileChooser_Trusted API are properly passed | 385 // that files written via the FileChooser_Trusted API are properly passed |
| 355 // through Safe Browsing. | 386 // through Safe Browsing. |
| 356 | 387 |
| 357 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTestWithSBService, | 388 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTestWithSBService, |
| 358 FileChooser_SaveAs_DangerousExecutable_Allowed) { | 389 FileChooser_SaveAs_DangerousExecutable_Allowed) { |
| 359 safe_browsing_test_configuration_.default_result = | 390 safe_browsing_test_configuration_.default_result = |
| 360 DownloadProtectionService::DANGEROUS; | 391 DownloadProtectionService::DANGEROUS; |
| 361 safe_browsing_test_configuration_.result_map.insert( | 392 safe_browsing_test_configuration_.result_map.insert( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 std::make_pair(base::FilePath::StringType(FILE_PATH_LITERAL(".exe")), | 434 std::make_pair(base::FilePath::StringType(FILE_PATH_LITERAL(".exe")), |
| 404 DownloadProtectionService::DANGEROUS)); | 435 DownloadProtectionService::DANGEROUS)); |
| 405 | 436 |
| 406 TestSelectFileDialogFactory test_dialog_factory( | 437 TestSelectFileDialogFactory test_dialog_factory( |
| 407 TestSelectFileDialogFactory::NOT_REACHED, | 438 TestSelectFileDialogFactory::NOT_REACHED, |
| 408 TestSelectFileDialogFactory::SelectedFileInfoList()); | 439 TestSelectFileDialogFactory::SelectedFileInfoList()); |
| 409 RunTestViaHTTP("FileChooser_SaveAsDangerousExtensionListDisallowed"); | 440 RunTestViaHTTP("FileChooser_SaveAsDangerousExtensionListDisallowed"); |
| 410 } | 441 } |
| 411 | 442 |
| 412 #endif // FULL_SAFE_BROWSING | 443 #endif // FULL_SAFE_BROWSING |
| OLD | NEW |