 Chromium Code Reviews
 Chromium Code Reviews Issue 224883008:
  Sniff MIME type for files which have unknown extensions.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 224883008:
  Sniff MIME type for files which have unknown extensions.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/app_window.h" | 5 #include "apps/app_window.h" | 
| 6 #include "apps/app_window_registry.h" | 6 #include "apps/app_window_registry.h" | 
| 7 #include "apps/common/api/app_runtime.h" | 7 #include "apps/common/api/app_runtime.h" | 
| 8 #include "apps/launcher.h" | 8 #include "apps/launcher.h" | 
| 9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" | 
| 10 #include "base/bind.h" | 10 #include "base/bind.h" | 
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 } | 645 } | 
| 646 | 646 | 
| 647 // Tests that no launch data is sent through if the platform app does not | 647 // Tests that no launch data is sent through if the platform app does not | 
| 648 // provide an intent. | 648 // provide an intent. | 
| 649 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNoIntent) { | 649 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNoIntent) { | 
| 650 SetCommandLineArg(kTestFilePath); | 650 SetCommandLineArg(kTestFilePath); | 
| 651 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_no_intent")) | 651 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_no_intent")) | 
| 652 << message_; | 652 << message_; | 
| 653 } | 653 } | 
| 654 | 654 | 
| 655 // Tests that launch data is sent through when the file has unknown extension | |
| 656 // but the MIME type can be sniffed and the sniffed type matches. | |
| 657 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithSniffableType) { | |
| 658 SetCommandLineArg("platform_apps/launch_files/test.unknownextension"); | |
| 659 ASSERT_TRUE(RunPlatformAppTest( | |
| 660 "platform_apps/launch_file_by_extension_and_type")) << message_; | |
| 661 } | |
| 662 | |
| 655 // Tests that launch data is sent through with the MIME type set to | 663 // Tests that launch data is sent through with the MIME type set to | 
| 656 // application/octet-stream if the file MIME type cannot be read. | 664 // application/octet-stream if the file MIME type cannot be read. | 
| 657 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNoType) { | 665 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNoType) { | 
| 658 SetCommandLineArg("platform_apps/launch_files/test.unknownextension"); | 666 SetCommandLineArg("platform_apps/launch_files/test_binary.unknownextension"); | 
| 
fukino
2014/04/15 07:29:00
To force the MIME type to fall back to application
 | |
| 659 ASSERT_TRUE(RunPlatformAppTest( | 667 ASSERT_TRUE(RunPlatformAppTest( | 
| 660 "platform_apps/launch_application_octet_stream")) << message_; | 668 "platform_apps/launch_application_octet_stream")) << message_; | 
| 661 } | 669 } | 
| 662 | 670 | 
| 663 // Tests that no launch data is sent through if the file does not exist. | 671 // Tests that no launch data is sent through if the file does not exist. | 
| 664 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNoFile) { | 672 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNoFile) { | 
| 665 SetCommandLineArg("platform_apps/launch_files/doesnotexist.txt"); | 673 SetCommandLineArg("platform_apps/launch_files/doesnotexist.txt"); | 
| 666 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_invalid")) | 674 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_invalid")) | 
| 667 << message_; | 675 << message_; | 
| 668 } | 676 } | 
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1324 | 1332 | 
| 1325 ExtensionApiTest::ResultCatcher result_catcher; | 1333 ExtensionApiTest::ResultCatcher result_catcher; | 
| 1326 | 1334 | 
| 1327 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 1335 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 
| 1328 | 1336 | 
| 1329 EXPECT_TRUE(result_catcher.GetNextResult()); | 1337 EXPECT_TRUE(result_catcher.GetNextResult()); | 
| 1330 } | 1338 } | 
| 1331 } | 1339 } | 
| 1332 | 1340 | 
| 1333 } // namespace extensions | 1341 } // namespace extensions | 
| OLD | NEW |