| 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 "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" | 5 #include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 68 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 69 ScopedTestNativeMessagingHost test_host; | 69 ScopedTestNativeMessagingHost test_host; |
| 70 | 70 |
| 71 base::FilePath test_user_data_dir; | 71 base::FilePath test_user_data_dir; |
| 72 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir)); | 72 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir)); |
| 73 test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging") | 73 test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging") |
| 74 .AppendASCII("native_hosts"); | 74 .AppendASCII("native_hosts"); |
| 75 | 75 |
| 76 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
| 77 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; | 77 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
| 78 registry_override_.OverrideRegistry(root_key, L"native_messaging"); | 78 registry_override_.OverrideRegistry(root_key); |
| 79 #else | 79 #else |
| 80 path_override_.reset(new base::ScopedPathOverride( | 80 path_override_.reset(new base::ScopedPathOverride( |
| 81 user_level ? chrome::DIR_USER_NATIVE_MESSAGING | 81 user_level ? chrome::DIR_USER_NATIVE_MESSAGING |
| 82 : chrome::DIR_NATIVE_MESSAGING, | 82 : chrome::DIR_NATIVE_MESSAGING, |
| 83 temp_dir_.path())); | 83 temp_dir_.path())); |
| 84 #endif | 84 #endif |
| 85 | 85 |
| 86 #if defined(OS_POSIX) | 86 #if defined(OS_POSIX) |
| 87 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.py"); | 87 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.py"); |
| 88 #else | 88 #else |
| 89 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.bat"); | 89 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.bat"); |
| 90 #endif | 90 #endif |
| 91 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( | 91 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( |
| 92 temp_dir_.path(), kHostName, host_path, user_level)); | 92 temp_dir_.path(), kHostName, host_path, user_level)); |
| 93 | 93 |
| 94 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( | 94 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( |
| 95 temp_dir_.path(), kBinaryMissingHostName, | 95 temp_dir_.path(), kBinaryMissingHostName, |
| 96 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level)); | 96 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {} | 99 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {} |
| 100 | 100 |
| 101 } // namespace extensions | 101 } // namespace extensions |
| OLD | NEW |