Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "remoting/host/desktop_session_agent.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/single_thread_task_runner.h" | |
| 9 #include "base/stringprintf.h" | |
| 10 #include "base/utf_string_conversions.h" | |
| 11 #include "base/win/scoped_handle.h" | |
| 12 #include "base/win/win_util.h" | |
| 13 #include "ipc/ipc_channel.h" | |
| 14 #include "ipc/ipc_channel_proxy.h" | |
| 15 #include "remoting/host/win/launch_process_with_token.h" | |
| 16 | |
| 17 using base::win::ScopedHandle; | |
| 18 | |
| 19 const char kSelfSecurityDescriptorFormat[] = "O:%1$sG:%1$sD:(A;;GA;;;%1$s)"; | |
|
Sergey Ulanov
2012/10/24 20:12:01
static or anonymous namespace. Or maybe move it in
alexeypa (please no reviews)
2012/10/24 21:41:51
It is a constant. It is limited to the file scope
| |
| 20 | |
| 21 namespace remoting { | |
| 22 | |
| 23 // Provides screen/audio capturing and input injection services for | |
| 24 // the network process. | |
| 25 class DesktopSessionAgentWin : public DesktopSessionAgent { | |
| 26 public: | |
| 27 DesktopSessionAgentWin( | |
| 28 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | |
| 29 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); | |
| 30 virtual ~DesktopSessionAgentWin(); | |
| 31 | |
| 32 protected: | |
| 33 virtual bool DoCreateNetworkChannel( | |
| 34 IPC::PlatformFileForTransit* client_out, | |
| 35 scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE; | |
| 36 | |
| 37 private: | |
| 38 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentWin); | |
| 39 }; | |
| 40 | |
| 41 DesktopSessionAgentWin::DesktopSessionAgentWin( | |
| 42 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | |
| 43 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) | |
| 44 : DesktopSessionAgent(caller_task_runner, io_task_runner) { | |
| 45 } | |
| 46 | |
| 47 DesktopSessionAgentWin::~DesktopSessionAgentWin() { | |
| 48 } | |
| 49 | |
| 50 bool DesktopSessionAgentWin::DoCreateNetworkChannel( | |
| 51 IPC::PlatformFileForTransit* client_out, | |
| 52 scoped_ptr<IPC::ChannelProxy>* server_out) { | |
| 53 // Generate a unique name for the channel. | |
| 54 std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID(); | |
| 55 | |
| 56 // presubmit: allow wstring | |
|
Sergey Ulanov
2012/10/24 20:12:01
remove this comment?
alexeypa (please no reviews)
2012/10/24 21:41:51
It is necessary to suppress the presubmit warning.
| |
| 57 std::wstring user_sid; | |
| 58 if (!base::win::GetUserSidString(&user_sid)) { | |
| 59 LOG(ERROR) << "Failed to query the current user SID."; | |
| 60 return false; | |
| 61 } | |
| 62 | |
| 63 // Create a security descriptor that will be used to protect the named pipe in | |
| 64 // between CreateNamedPipe() and CreateFile() calls before it will be passed | |
| 65 // to the network process. It gives full access to the account that | |
| 66 // the calling code is running under and denies access by anyone else. | |
| 67 std::string security_descriptor = base::StringPrintf( | |
| 68 kSelfSecurityDescriptorFormat, WideToUTF8(user_sid).c_str()); | |
| 69 | |
| 70 // Create a connected IPC channel. | |
| 71 ScopedHandle client; | |
| 72 scoped_ptr<IPC::ChannelProxy> server; | |
| 73 if (!CreateConnectedIpcChannel(channel_name, security_descriptor, | |
| 74 io_task_runner(), this, &client, &server)) { | |
| 75 return false; | |
| 76 } | |
| 77 | |
| 78 *client_out = client.Take(); | |
| 79 *server_out = server.Pass(); | |
| 80 return true; | |
| 81 } | |
| 82 | |
| 83 // static | |
| 84 scoped_ptr<DesktopSessionAgent> DesktopSessionAgent::Create( | |
| 85 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | |
| 86 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { | |
| 87 return scoped_ptr<DesktopSessionAgent>(new DesktopSessionAgentWin( | |
| 88 caller_task_runner, io_task_runner)); | |
| 89 } | |
| 90 | |
| 91 } // namespace remoting | |
| OLD | NEW |