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 11 matching lines...) Expand all Loading... |
22 void CreateTestNativeHostManifest(base::FilePath manifest_path) { | 22 void CreateTestNativeHostManifest(base::FilePath manifest_path) { |
23 scoped_ptr<base::DictionaryValue> manifest(new base::DictionaryValue()); | 23 scoped_ptr<base::DictionaryValue> manifest(new base::DictionaryValue()); |
24 manifest->SetString("name", kTestNativeMessagingHostName); | 24 manifest->SetString("name", kTestNativeMessagingHostName); |
25 manifest->SetString("description", "Native Messaging Echo Test"); | 25 manifest->SetString("description", "Native Messaging Echo Test"); |
26 manifest->SetString("type", "stdio"); | 26 manifest->SetString("type", "stdio"); |
27 | 27 |
28 base::FilePath test_user_data_dir; | 28 base::FilePath test_user_data_dir; |
29 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir)); | 29 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir)); |
30 test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging"); | 30 test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging"); |
31 test_user_data_dir = test_user_data_dir.AppendASCII("native_hosts"); | 31 test_user_data_dir = test_user_data_dir.AppendASCII("native_hosts"); |
32 #ifdef OS_POSIX | 32 #if defined(OS_POSIX) |
33 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.py"); | 33 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.py"); |
34 #else | 34 #else |
35 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.bat"); | 35 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.bat"); |
36 #endif | 36 #endif |
37 manifest->SetString("path", host_path.AsUTF8Unsafe()); | 37 manifest->SetString("path", host_path.AsUTF8Unsafe()); |
38 | 38 |
39 scoped_ptr<base::ListValue> origins(new base::ListValue()); | 39 scoped_ptr<base::ListValue> origins(new base::ListValue()); |
40 origins->AppendString(base::StringPrintf("chrome-extension://%s/", | 40 origins->AppendString(base::StringPrintf("chrome-extension://%s/", |
41 kTestNativeMessagingExtensionId)); | 41 kTestNativeMessagingExtensionId)); |
42 manifest->Set("allowed_origins", origins.release()); | 42 manifest->Set("allowed_origins", origins.release()); |
43 | 43 |
44 JSONFileValueSerializer serializer(manifest_path); | 44 JSONFileValueSerializer serializer(manifest_path); |
45 ASSERT_TRUE(serializer.Serialize(*manifest)); | 45 ASSERT_TRUE(serializer.Serialize(*manifest)); |
46 } | 46 } |
47 | 47 |
48 } // namespace extensions | 48 } // namespace extensions |
OLD | NEW |