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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 if (!registry->OpenProcess(command_, &pid, | 107 if (!registry->OpenProcess(command_, &pid, |
108 base::Bind(&NotifyProcessOutput, profile_, extension_id()))) { | 108 base::Bind(&NotifyProcessOutput, profile_, extension_id()))) { |
109 // If new process could not be opened, we return -1. | 109 // If new process could not be opened, we return -1. |
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() {} |
| 118 |
117 void OpenTerminalProcessFunction::RespondOnUIThread(pid_t pid) { | 119 void OpenTerminalProcessFunction::RespondOnUIThread(pid_t pid) { |
118 result_.reset(new base::FundamentalValue(pid)); | 120 result_.reset(new base::FundamentalValue(pid)); |
119 SendResponse(true); | 121 SendResponse(true); |
120 } | 122 } |
121 | 123 |
122 bool SendInputToTerminalProcessFunction::RunTerminalFunction() { | 124 bool SendInputToTerminalProcessFunction::RunTerminalFunction() { |
123 if (args_->GetSize() != 2) | 125 if (args_->GetSize() != 2) |
124 return false; | 126 return false; |
125 | 127 |
126 pid_t pid; | 128 pid_t pid; |
(...skipping 15 matching lines...) Expand all Loading... |
142 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 144 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
143 base::Bind(&SendInputToTerminalProcessFunction::RespondOnUIThread, this, | 145 base::Bind(&SendInputToTerminalProcessFunction::RespondOnUIThread, this, |
144 success)); | 146 success)); |
145 } | 147 } |
146 | 148 |
147 void SendInputToTerminalProcessFunction::RespondOnUIThread(bool success) { | 149 void SendInputToTerminalProcessFunction::RespondOnUIThread(bool success) { |
148 result_.reset(new base::FundamentalValue(success)); | 150 result_.reset(new base::FundamentalValue(success)); |
149 SendResponse(true); | 151 SendResponse(true); |
150 } | 152 } |
151 | 153 |
| 154 CloseTerminalProcessFunction::~CloseTerminalProcessFunction() {} |
| 155 |
152 bool CloseTerminalProcessFunction::RunTerminalFunction() { | 156 bool CloseTerminalProcessFunction::RunTerminalFunction() { |
153 if (args_->GetSize() != 1) | 157 if (args_->GetSize() != 1) |
154 return false; | 158 return false; |
155 pid_t pid; | 159 pid_t pid; |
156 if (!args_->GetInteger(0, &pid)) | 160 if (!args_->GetInteger(0, &pid)) |
157 return false; | 161 return false; |
158 | 162 |
159 // Registry lives on the FILE thread. | 163 // Registry lives on the FILE thread. |
160 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 164 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
161 base::Bind(&CloseTerminalProcessFunction::CloseOnFileThread, this, pid)); | 165 base::Bind(&CloseTerminalProcessFunction::CloseOnFileThread, this, pid)); |
162 | 166 |
163 return true; | 167 return true; |
164 } | 168 } |
165 | 169 |
166 void CloseTerminalProcessFunction::CloseOnFileThread(pid_t pid) { | 170 void CloseTerminalProcessFunction::CloseOnFileThread(pid_t pid) { |
167 bool success = ProcessProxyRegistry::Get()->CloseProcess(pid); | 171 bool success = ProcessProxyRegistry::Get()->CloseProcess(pid); |
168 | 172 |
169 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 173 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
170 base::Bind(&CloseTerminalProcessFunction::RespondOnUIThread, this, | 174 base::Bind(&CloseTerminalProcessFunction::RespondOnUIThread, this, |
171 success)); | 175 success)); |
172 } | 176 } |
173 | 177 |
174 void CloseTerminalProcessFunction::RespondOnUIThread(bool success) { | 178 void CloseTerminalProcessFunction::RespondOnUIThread(bool success) { |
175 result_.reset(new base::FundamentalValue(success)); | 179 result_.reset(new base::FundamentalValue(success)); |
176 SendResponse(true); | 180 SendResponse(true); |
177 } | 181 } |
178 | 182 |
| 183 OnTerminalResizeFunction::~OnTerminalResizeFunction() {} |
| 184 |
179 bool OnTerminalResizeFunction::RunTerminalFunction() { | 185 bool OnTerminalResizeFunction::RunTerminalFunction() { |
180 if (args_->GetSize() != 3) | 186 if (args_->GetSize() != 3) |
181 return false; | 187 return false; |
182 | 188 |
183 pid_t pid; | 189 pid_t pid; |
184 if (!args_->GetInteger(0, &pid)) | 190 if (!args_->GetInteger(0, &pid)) |
185 return false; | 191 return false; |
186 | 192 |
187 int width; | 193 int width; |
188 if (!args_->GetInteger(1, &width)) | 194 if (!args_->GetInteger(1, &width)) |
(...skipping 18 matching lines...) Expand all Loading... |
207 | 213 |
208 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 214 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
209 base::Bind(&OnTerminalResizeFunction::RespondOnUIThread, this, | 215 base::Bind(&OnTerminalResizeFunction::RespondOnUIThread, this, |
210 success)); | 216 success)); |
211 } | 217 } |
212 | 218 |
213 void OnTerminalResizeFunction::RespondOnUIThread(bool success) { | 219 void OnTerminalResizeFunction::RespondOnUIThread(bool success) { |
214 result_.reset(new base::FundamentalValue(success)); | 220 result_.reset(new base::FundamentalValue(success)); |
215 SendResponse(true); | 221 SendResponse(true); |
216 } | 222 } |
OLD | NEW |