OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/host/security_key/remote_security_key_ipc_constants.h" | 5 #include "remoting/host/security_key/security_key_ipc_constants.h" |
6 | 6 |
7 #include "base/environment.h" | 7 #include "base/environment.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 base::LazyInstance<std::string> g_remote_security_key_ipc_channel_name = | 11 base::LazyInstance<std::string> g_security_key_ipc_channel_name = |
12 LAZY_INSTANCE_INITIALIZER; | 12 LAZY_INSTANCE_INITIALIZER; |
13 | 13 |
14 const char kRemoteSecurityKeyIpcChannelName[] = | 14 const char kSecurityKeyIpcChannelName[] = "security_key_ipc_channel"; |
15 "remote_security_key_ipc_channel"; | |
16 | 15 |
17 } // namespace | 16 } // namespace |
18 | 17 |
19 namespace remoting { | 18 namespace remoting { |
20 | 19 |
21 extern const char kRemoteSecurityKeyConnectionError[] = | 20 extern const char kSecurityKeyConnectionError[] = "ssh_connection_error"; |
22 "remote_ssh_connection_error"; | |
23 | 21 |
24 const std::string& GetRemoteSecurityKeyIpcChannelName() { | 22 const std::string& GetSecurityKeyIpcChannelName() { |
25 if (g_remote_security_key_ipc_channel_name.Get().empty()) { | 23 if (g_security_key_ipc_channel_name.Get().empty()) { |
26 g_remote_security_key_ipc_channel_name.Get() = | 24 g_security_key_ipc_channel_name.Get() = kSecurityKeyIpcChannelName; |
27 kRemoteSecurityKeyIpcChannelName; | |
28 } | 25 } |
29 | 26 |
30 return g_remote_security_key_ipc_channel_name.Get(); | 27 return g_security_key_ipc_channel_name.Get(); |
31 } | 28 } |
32 | 29 |
33 void SetRemoteSecurityKeyIpcChannelNameForTest( | 30 void SetSecurityKeyIpcChannelNameForTest(const std::string& channel_name) { |
34 const std::string& channel_name) { | 31 g_security_key_ipc_channel_name.Get() = channel_name; |
35 g_remote_security_key_ipc_channel_name.Get() = channel_name; | |
36 } | 32 } |
37 | 33 |
38 std::string GetChannelNamePathPrefixForTest() { | 34 std::string GetChannelNamePathPrefixForTest() { |
39 std::string path_prefix; | 35 std::string path_prefix; |
40 #if defined(OS_LINUX) | 36 #if defined(OS_LINUX) |
41 path_prefix = "/dev/socket/"; | 37 path_prefix = "/dev/socket/"; |
42 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 38 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
43 if (env->GetVar(base::env_vars::kHome, &path_prefix)) | 39 if (env->GetVar(base::env_vars::kHome, &path_prefix)) |
44 path_prefix += "/"; | 40 path_prefix += "/"; |
45 #endif | 41 #endif |
46 return path_prefix; | 42 return path_prefix; |
47 } | 43 } |
48 | 44 |
49 } // namespace remoting | 45 } // namespace remoting |
OLD | NEW |