Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: remoting/host/security_key/security_key_ipc_client.h

Issue 2575963002: Handle Security Key requests from outside the remoted session correctly (Closed)
Patch Set: Addressing CR Feedback Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_CLIENT_H_ 5 #ifndef REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_CLIENT_H_
6 #define REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_CLIENT_H_ 6 #define REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_CLIENT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 16 matching lines...) Expand all
27 // The public methods are virtual to allow for using fake objects for testing. 27 // The public methods are virtual to allow for using fake objects for testing.
28 class SecurityKeyIpcClient : public IPC::Listener { 28 class SecurityKeyIpcClient : public IPC::Listener {
29 public: 29 public:
30 SecurityKeyIpcClient(); 30 SecurityKeyIpcClient();
31 ~SecurityKeyIpcClient() override; 31 ~SecurityKeyIpcClient() override;
32 32
33 // Used to send security key extension messages to the client. 33 // Used to send security key extension messages to the client.
34 typedef base::Callback<void(const std::string& response_data)> 34 typedef base::Callback<void(const std::string& response_data)>
35 ResponseCallback; 35 ResponseCallback;
36 36
37 // Used to indicate whether the channel can be used for request forwarding.
38 typedef base::Callback<void(bool connection_usable)> ConnectedCallback;
dcheng 2016/12/16 02:33:07 Nit: it's preferred to use 'using A = B' over 'typ
joedow 2016/12/16 03:36:22 Acknowledged. I'll switch to that style in future
39
37 // Returns true if there is an active remoting session which supports 40 // Returns true if there is an active remoting session which supports
38 // security key request forwarding. 41 // security key request forwarding.
39 virtual bool CheckForSecurityKeyIpcServerChannel(); 42 virtual bool CheckForSecurityKeyIpcServerChannel();
40 43
41 // Begins the process of connecting to the IPC channel which will be used for 44 // Begins the process of connecting to the IPC channel which will be used for
42 // exchanging security key messages. 45 // exchanging security key messages.
43 // |connection_ready_callback| is called when a channel has been established 46 // |connected_callback| is called when a channel has been established and
44 // and security key requests can be sent. 47 // indicates whether security key requests can be sent using it.
45 // |connection_error_callback| is stored and will be called back for any 48 // |connection_error_callback| is stored and will be called back for any
46 // unexpected errors that occur while establishing, or during, the session. 49 // unexpected errors that occur while establishing, or during, the session.
47 virtual void EstablishIpcConnection( 50 virtual void EstablishIpcConnection(
48 const base::Closure& connection_ready_callback, 51 const ConnectedCallback& connected_callback,
49 const base::Closure& connection_error_callback); 52 const base::Closure& connection_error_callback);
50 53
51 // Sends a security key request message to the network process to be forwarded 54 // Sends a security key request message to the network process to be forwarded
52 // to the remote client. 55 // to the remote client.
53 virtual bool SendSecurityKeyRequest( 56 virtual bool SendSecurityKeyRequest(
54 const std::string& request_payload, 57 const std::string& request_payload,
55 const ResponseCallback& response_callback); 58 const ResponseCallback& response_callback);
56 59
57 // Closes the IPC channel if connected. 60 // Closes the IPC channel if connected.
58 virtual void CloseIpcConnection(); 61 virtual void CloseIpcConnection();
59 62
60 // Allows tests to override the IPC channel. 63 // Allows tests to override the IPC channel.
61 void SetIpcChannelHandleForTest( 64 void SetIpcChannelHandleForTest(
62 const mojo::edk::NamedPlatformHandle& channel_handle); 65 const mojo::edk::NamedPlatformHandle& channel_handle);
63 66
64 // Allows tests to override the expected session ID. 67 // Allows tests to override the expected session ID.
65 void SetExpectedIpcServerSessionIdForTest(uint32_t expected_session_id); 68 void SetExpectedIpcServerSessionIdForTest(uint32_t expected_session_id);
66 69
67 private: 70 private:
68 // IPC::Listener implementation. 71 // IPC::Listener implementation.
69 bool OnMessageReceived(const IPC::Message& message) override; 72 bool OnMessageReceived(const IPC::Message& message) override;
70 void OnChannelConnected(int32_t peer_pid) override; 73 void OnChannelConnected(int32_t peer_pid) override;
71 void OnChannelError() override; 74 void OnChannelError() override;
72 75
73 // Handles the ConnectionDetails IPC message. 76 // Handles the ConnectionReady IPC message.
74 void OnConnectionDetails(const std::string& request_data); 77 void OnConnectionReady();
78
79 // Handles the InvalidSession IPC message.
80 void OnInvalidSession();
75 81
76 // Handles security key response IPC messages. 82 // Handles security key response IPC messages.
77 void OnSecurityKeyResponse(const std::string& request_data); 83 void OnSecurityKeyResponse(const std::string& request_data);
78 84
79 // Establishes a connection to the specified IPC Server channel. 85 // Establishes a connection to the specified IPC Server channel.
80 void ConnectToIpcChannel(); 86 void ConnectToIpcChannel();
81 87
82 // Used to validate the IPC Server process is running in the correct session. 88 // Used to validate the IPC Server process is running in the correct session.
83 // '0' (default) corresponds to the session the network process runs in. 89 // '0' (default) corresponds to the session the network process runs in.
84 uint32_t expected_ipc_server_session_id_ = 0; 90 uint32_t expected_ipc_server_session_id_ = 0;
85 91
86
87 // Name of the initial IPC channel used to retrieve connection info. 92 // Name of the initial IPC channel used to retrieve connection info.
88 mojo::edk::NamedPlatformHandle named_channel_handle_; 93 mojo::edk::NamedPlatformHandle named_channel_handle_;
89 94
90 // A handle for the IPC channel used for exchanging security key messages. 95 // A handle for the IPC channel used for exchanging security key messages.
91 mojo::edk::ScopedPlatformHandle channel_handle_; 96 mojo::edk::ScopedPlatformHandle channel_handle_;
92 97
93 // Signaled when the IPC connection is ready for security key requests. 98 // Signaled when the IPC connection is ready for security key requests.
94 base::Closure connection_ready_callback_; 99 ConnectedCallback connected_callback_;
95 100
96 // Signaled when an error occurs in either the IPC channel or communication. 101 // Signaled when an error occurs in either the IPC channel or communication.
97 base::Closure connection_error_callback_; 102 base::Closure connection_error_callback_;
98 103
99 // Signaled when a security key response has been received. 104 // Signaled when a security key response has been received.
100 ResponseCallback response_callback_; 105 ResponseCallback response_callback_;
101 106
102 // Used for sending/receiving security key messages between processes. 107 // Used for sending/receiving security key messages between processes.
103 std::unique_ptr<IPC::Channel> ipc_channel_; 108 std::unique_ptr<IPC::Channel> ipc_channel_;
104 109
105 base::ThreadChecker thread_checker_; 110 base::ThreadChecker thread_checker_;
106 111
107 base::WeakPtrFactory<SecurityKeyIpcClient> weak_factory_; 112 base::WeakPtrFactory<SecurityKeyIpcClient> weak_factory_;
108 113
109 DISALLOW_COPY_AND_ASSIGN(SecurityKeyIpcClient); 114 DISALLOW_COPY_AND_ASSIGN(SecurityKeyIpcClient);
110 }; 115 };
111 116
112 } // namespace remoting 117 } // namespace remoting
113 118
114 #endif // REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_CLIENT_H_ 119 #endif // REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698