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" |
11 #include "chrome/browser/chromeos/process_proxy/process_proxy_registry.h" | 11 #include "chromeos/process_proxy/process_proxy_registry.h" |
12 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" | 12 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" |
13 #include "chrome/browser/extensions/event_names.h" | 13 #include "chrome/browser/extensions/event_names.h" |
14 #include "chrome/browser/extensions/event_router.h" | 14 #include "chrome/browser/extensions/event_router.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/extensions/extension_system.h" | 16 #include "chrome/browser/extensions/extension_system.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Registry lives on FILE thread. | 98 // Registry lives on FILE thread. |
99 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 99 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
100 base::Bind(&TerminalPrivateOpenTerminalProcessFunction::OpenOnFileThread, | 100 base::Bind(&TerminalPrivateOpenTerminalProcessFunction::OpenOnFileThread, |
101 this)); | 101 this)); |
102 return true; | 102 return true; |
103 } | 103 } |
104 | 104 |
105 void TerminalPrivateOpenTerminalProcessFunction::OpenOnFileThread() { | 105 void TerminalPrivateOpenTerminalProcessFunction::OpenOnFileThread() { |
106 DCHECK(command_); | 106 DCHECK(command_); |
107 | 107 |
108 ProcessProxyRegistry* registry = ProcessProxyRegistry::Get(); | 108 chromeos::ProcessProxyRegistry* registry = |
| 109 chromeos::ProcessProxyRegistry::Get(); |
109 pid_t pid; | 110 pid_t pid; |
110 if (!registry->OpenProcess(command_, &pid, | 111 if (!registry->OpenProcess( |
| 112 command_, &pid, |
111 base::Bind(&NotifyProcessOutput, profile_, extension_id()))) { | 113 base::Bind(&NotifyProcessOutput, profile_, extension_id()))) { |
112 // If new process could not be opened, we return -1. | 114 // If new process could not be opened, we return -1. |
113 pid = -1; | 115 pid = -1; |
114 } | 116 } |
115 | 117 |
116 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 118 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
117 base::Bind(&TerminalPrivateOpenTerminalProcessFunction::RespondOnUIThread, | 119 base::Bind(&TerminalPrivateOpenTerminalProcessFunction::RespondOnUIThread, |
118 this, pid)); | 120 this, pid)); |
119 } | 121 } |
120 | 122 |
(...skipping 15 matching lines...) Expand all Loading... |
136 | 138 |
137 // Registry lives on the FILE thread. | 139 // Registry lives on the FILE thread. |
138 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 140 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
139 base::Bind(&TerminalPrivateSendInputFunction::SendInputOnFileThread, | 141 base::Bind(&TerminalPrivateSendInputFunction::SendInputOnFileThread, |
140 this, pid, text)); | 142 this, pid, text)); |
141 return true; | 143 return true; |
142 } | 144 } |
143 | 145 |
144 void TerminalPrivateSendInputFunction::SendInputOnFileThread(pid_t pid, | 146 void TerminalPrivateSendInputFunction::SendInputOnFileThread(pid_t pid, |
145 const std::string& text) { | 147 const std::string& text) { |
146 bool success = ProcessProxyRegistry::Get()->SendInput(pid, text); | 148 bool success = chromeos::ProcessProxyRegistry::Get()->SendInput(pid, text); |
147 | 149 |
148 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 150 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
149 base::Bind(&TerminalPrivateSendInputFunction::RespondOnUIThread, this, | 151 base::Bind(&TerminalPrivateSendInputFunction::RespondOnUIThread, this, |
150 success)); | 152 success)); |
151 } | 153 } |
152 | 154 |
153 void TerminalPrivateSendInputFunction::RespondOnUIThread(bool success) { | 155 void TerminalPrivateSendInputFunction::RespondOnUIThread(bool success) { |
154 SetResult(new base::FundamentalValue(success)); | 156 SetResult(new base::FundamentalValue(success)); |
155 SendResponse(true); | 157 SendResponse(true); |
156 } | 158 } |
(...skipping 10 matching lines...) Expand all Loading... |
167 | 169 |
168 // Registry lives on the FILE thread. | 170 // Registry lives on the FILE thread. |
169 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 171 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
170 base::Bind(&TerminalPrivateCloseTerminalProcessFunction:: | 172 base::Bind(&TerminalPrivateCloseTerminalProcessFunction:: |
171 CloseOnFileThread, this, pid)); | 173 CloseOnFileThread, this, pid)); |
172 | 174 |
173 return true; | 175 return true; |
174 } | 176 } |
175 | 177 |
176 void TerminalPrivateCloseTerminalProcessFunction::CloseOnFileThread(pid_t pid) { | 178 void TerminalPrivateCloseTerminalProcessFunction::CloseOnFileThread(pid_t pid) { |
177 bool success = ProcessProxyRegistry::Get()->CloseProcess(pid); | 179 bool success = chromeos::ProcessProxyRegistry::Get()->CloseProcess(pid); |
178 | 180 |
179 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 181 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
180 base::Bind(&TerminalPrivateCloseTerminalProcessFunction:: | 182 base::Bind(&TerminalPrivateCloseTerminalProcessFunction:: |
181 RespondOnUIThread, this, success)); | 183 RespondOnUIThread, this, success)); |
182 } | 184 } |
183 | 185 |
184 void TerminalPrivateCloseTerminalProcessFunction::RespondOnUIThread( | 186 void TerminalPrivateCloseTerminalProcessFunction::RespondOnUIThread( |
185 bool success) { | 187 bool success) { |
186 SetResult(new base::FundamentalValue(success)); | 188 SetResult(new base::FundamentalValue(success)); |
187 SendResponse(true); | 189 SendResponse(true); |
(...skipping 21 matching lines...) Expand all Loading... |
209 // Registry lives on the FILE thread. | 211 // Registry lives on the FILE thread. |
210 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 212 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
211 base::Bind(&TerminalPrivateOnTerminalResizeFunction::OnResizeOnFileThread, | 213 base::Bind(&TerminalPrivateOnTerminalResizeFunction::OnResizeOnFileThread, |
212 this, pid, width, height)); | 214 this, pid, width, height)); |
213 | 215 |
214 return true; | 216 return true; |
215 } | 217 } |
216 | 218 |
217 void TerminalPrivateOnTerminalResizeFunction::OnResizeOnFileThread(pid_t pid, | 219 void TerminalPrivateOnTerminalResizeFunction::OnResizeOnFileThread(pid_t pid, |
218 int width, int height) { | 220 int width, int height) { |
219 bool success = ProcessProxyRegistry::Get()->OnTerminalResize(pid, | 221 bool success = chromeos::ProcessProxyRegistry::Get()->OnTerminalResize( |
220 width, height); | 222 pid, width, height); |
221 | 223 |
222 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 224 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
223 base::Bind(&TerminalPrivateOnTerminalResizeFunction::RespondOnUIThread, | 225 base::Bind(&TerminalPrivateOnTerminalResizeFunction::RespondOnUIThread, |
224 this, success)); | 226 this, success)); |
225 } | 227 } |
226 | 228 |
227 void TerminalPrivateOnTerminalResizeFunction::RespondOnUIThread(bool success) { | 229 void TerminalPrivateOnTerminalResizeFunction::RespondOnUIThread(bool success) { |
228 SetResult(new base::FundamentalValue(success)); | 230 SetResult(new base::FundamentalValue(success)); |
229 SendResponse(true); | 231 SendResponse(true); |
230 } | 232 } |
OLD | NEW |