Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
|
jdoerrie
2017/04/06 14:25:50
#include <utility>
vabr (Chromium)
2017/04/07 20:40:40
Done.
| |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 30 bool user_level) { | 30 bool user_level) { |
| 31 std::unique_ptr<base::DictionaryValue> manifest(new base::DictionaryValue()); | 31 std::unique_ptr<base::DictionaryValue> manifest(new base::DictionaryValue()); |
| 32 manifest->SetString("name", host_name); | 32 manifest->SetString("name", host_name); |
| 33 manifest->SetString("description", "Native Messaging Echo Test"); | 33 manifest->SetString("description", "Native Messaging Echo Test"); |
| 34 manifest->SetString("type", "stdio"); | 34 manifest->SetString("type", "stdio"); |
| 35 manifest->SetString("path", host_path.AsUTF8Unsafe()); | 35 manifest->SetString("path", host_path.AsUTF8Unsafe()); |
| 36 | 36 |
| 37 std::unique_ptr<base::ListValue> origins(new base::ListValue()); | 37 std::unique_ptr<base::ListValue> origins(new base::ListValue()); |
| 38 origins->AppendString(base::StringPrintf( | 38 origins->AppendString(base::StringPrintf( |
| 39 "chrome-extension://%s/", ScopedTestNativeMessagingHost::kExtensionId)); | 39 "chrome-extension://%s/", ScopedTestNativeMessagingHost::kExtensionId)); |
| 40 manifest->Set("allowed_origins", origins.release()); | 40 manifest->Set("allowed_origins", std::move(origins)); |
| 41 | 41 |
| 42 base::FilePath manifest_path = target_dir.AppendASCII(host_name + ".json"); | 42 base::FilePath manifest_path = target_dir.AppendASCII(host_name + ".json"); |
| 43 JSONFileValueSerializer serializer(manifest_path); | 43 JSONFileValueSerializer serializer(manifest_path); |
| 44 ASSERT_TRUE(serializer.Serialize(*manifest)); | 44 ASSERT_TRUE(serializer.Serialize(*manifest)); |
| 45 | 45 |
| 46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 47 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; | 47 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
| 48 base::string16 key = L"SOFTWARE\\Google\\Chrome\\NativeMessagingHosts\\" + | 48 base::string16 key = L"SOFTWARE\\Google\\Chrome\\NativeMessagingHosts\\" + |
| 49 base::UTF8ToUTF16(host_name); | 49 base::UTF8ToUTF16(host_name); |
| 50 base::win::RegKey manifest_key( | 50 base::win::RegKey manifest_key( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 temp_dir_.GetPath(), kHostName, host_path, user_level)); | 94 temp_dir_.GetPath(), kHostName, host_path, user_level)); |
| 95 | 95 |
| 96 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( | 96 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( |
| 97 temp_dir_.GetPath(), kBinaryMissingHostName, | 97 temp_dir_.GetPath(), kBinaryMissingHostName, |
| 98 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level)); | 98 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level)); |
| 99 } | 99 } |
| 100 | 100 |
| 101 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {} | 101 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {} |
| 102 | 102 |
| 103 } // namespace extensions | 103 } // namespace extensions |
| OLD | NEW |