OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/terminal/terminal_private_api.h" | 5 #include "chrome/browser/extensions/api/terminal/terminal_private_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 pid = -1; | 110 pid = -1; |
111 } | 111 } |
112 | 112 |
113 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 113 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
114 base::Bind(&OpenTerminalProcessFunction::RespondOnUIThread, this, pid)); | 114 base::Bind(&OpenTerminalProcessFunction::RespondOnUIThread, this, pid)); |
115 } | 115 } |
116 | 116 |
117 SendInputToTerminalProcessFunction::~SendInputToTerminalProcessFunction() {} | 117 SendInputToTerminalProcessFunction::~SendInputToTerminalProcessFunction() {} |
118 | 118 |
119 void OpenTerminalProcessFunction::RespondOnUIThread(pid_t pid) { | 119 void OpenTerminalProcessFunction::RespondOnUIThread(pid_t pid) { |
120 result_.reset(new base::FundamentalValue(pid)); | 120 SetResult(new base::FundamentalValue(pid)); |
121 SendResponse(true); | 121 SendResponse(true); |
122 } | 122 } |
123 | 123 |
124 bool SendInputToTerminalProcessFunction::RunTerminalFunction() { | 124 bool SendInputToTerminalProcessFunction::RunTerminalFunction() { |
125 if (args_->GetSize() != 2) | 125 if (args_->GetSize() != 2) |
126 return false; | 126 return false; |
127 | 127 |
128 pid_t pid; | 128 pid_t pid; |
129 std::string text; | 129 std::string text; |
130 if (!args_->GetInteger(0, &pid) || !args_->GetString(1, &text)) | 130 if (!args_->GetInteger(0, &pid) || !args_->GetString(1, &text)) |
131 return false; | 131 return false; |
132 | 132 |
133 // Registry lives on the FILE thread. | 133 // Registry lives on the FILE thread. |
134 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 134 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
135 base::Bind(&SendInputToTerminalProcessFunction::SendInputOnFileThread, | 135 base::Bind(&SendInputToTerminalProcessFunction::SendInputOnFileThread, |
136 this, pid, text)); | 136 this, pid, text)); |
137 return true; | 137 return true; |
138 } | 138 } |
139 | 139 |
140 void SendInputToTerminalProcessFunction::SendInputOnFileThread(pid_t pid, | 140 void SendInputToTerminalProcessFunction::SendInputOnFileThread(pid_t pid, |
141 const std::string& text) { | 141 const std::string& text) { |
142 bool success = ProcessProxyRegistry::Get()->SendInput(pid, text); | 142 bool success = ProcessProxyRegistry::Get()->SendInput(pid, text); |
143 | 143 |
144 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 144 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
145 base::Bind(&SendInputToTerminalProcessFunction::RespondOnUIThread, this, | 145 base::Bind(&SendInputToTerminalProcessFunction::RespondOnUIThread, this, |
146 success)); | 146 success)); |
147 } | 147 } |
148 | 148 |
149 void SendInputToTerminalProcessFunction::RespondOnUIThread(bool success) { | 149 void SendInputToTerminalProcessFunction::RespondOnUIThread(bool success) { |
150 result_.reset(new base::FundamentalValue(success)); | 150 SetResult(new base::FundamentalValue(success)); |
151 SendResponse(true); | 151 SendResponse(true); |
152 } | 152 } |
153 | 153 |
154 CloseTerminalProcessFunction::~CloseTerminalProcessFunction() {} | 154 CloseTerminalProcessFunction::~CloseTerminalProcessFunction() {} |
155 | 155 |
156 bool CloseTerminalProcessFunction::RunTerminalFunction() { | 156 bool CloseTerminalProcessFunction::RunTerminalFunction() { |
157 if (args_->GetSize() != 1) | 157 if (args_->GetSize() != 1) |
158 return false; | 158 return false; |
159 pid_t pid; | 159 pid_t pid; |
160 if (!args_->GetInteger(0, &pid)) | 160 if (!args_->GetInteger(0, &pid)) |
161 return false; | 161 return false; |
162 | 162 |
163 // Registry lives on the FILE thread. | 163 // Registry lives on the FILE thread. |
164 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 164 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
165 base::Bind(&CloseTerminalProcessFunction::CloseOnFileThread, this, pid)); | 165 base::Bind(&CloseTerminalProcessFunction::CloseOnFileThread, this, pid)); |
166 | 166 |
167 return true; | 167 return true; |
168 } | 168 } |
169 | 169 |
170 void CloseTerminalProcessFunction::CloseOnFileThread(pid_t pid) { | 170 void CloseTerminalProcessFunction::CloseOnFileThread(pid_t pid) { |
171 bool success = ProcessProxyRegistry::Get()->CloseProcess(pid); | 171 bool success = ProcessProxyRegistry::Get()->CloseProcess(pid); |
172 | 172 |
173 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 173 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
174 base::Bind(&CloseTerminalProcessFunction::RespondOnUIThread, this, | 174 base::Bind(&CloseTerminalProcessFunction::RespondOnUIThread, this, |
175 success)); | 175 success)); |
176 } | 176 } |
177 | 177 |
178 void CloseTerminalProcessFunction::RespondOnUIThread(bool success) { | 178 void CloseTerminalProcessFunction::RespondOnUIThread(bool success) { |
179 result_.reset(new base::FundamentalValue(success)); | 179 SetResult(new base::FundamentalValue(success)); |
180 SendResponse(true); | 180 SendResponse(true); |
181 } | 181 } |
182 | 182 |
183 OnTerminalResizeFunction::~OnTerminalResizeFunction() {} | 183 OnTerminalResizeFunction::~OnTerminalResizeFunction() {} |
184 | 184 |
185 bool OnTerminalResizeFunction::RunTerminalFunction() { | 185 bool OnTerminalResizeFunction::RunTerminalFunction() { |
186 if (args_->GetSize() != 3) | 186 if (args_->GetSize() != 3) |
187 return false; | 187 return false; |
188 | 188 |
189 pid_t pid; | 189 pid_t pid; |
(...skipping 20 matching lines...) Expand all Loading... |
210 int width, int height) { | 210 int width, int height) { |
211 bool success = ProcessProxyRegistry::Get()->OnTerminalResize(pid, | 211 bool success = ProcessProxyRegistry::Get()->OnTerminalResize(pid, |
212 width, height); | 212 width, height); |
213 | 213 |
214 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 214 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
215 base::Bind(&OnTerminalResizeFunction::RespondOnUIThread, this, | 215 base::Bind(&OnTerminalResizeFunction::RespondOnUIThread, this, |
216 success)); | 216 success)); |
217 } | 217 } |
218 | 218 |
219 void OnTerminalResizeFunction::RespondOnUIThread(bool success) { | 219 void OnTerminalResizeFunction::RespondOnUIThread(bool success) { |
220 result_.reset(new base::FundamentalValue(success)); | 220 SetResult(new base::FundamentalValue(success)); |
221 SendResponse(true); | 221 SendResponse(true); |
222 } | 222 } |
OLD | NEW |