summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authortbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 02:36:31 +0000
committertbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 02:36:31 +0000
commit0d2786c4ee50b3e5758e912eb4912ae81639bee8 (patch)
tree05c29b64caf33f2d63412ea92eff9e509493a35f /chrome/browser/chromeos
parent1382a2756e2d15473479fb87187b3aa9ddbc63c2 (diff)
downloadchromium_src-0d2786c4ee50b3e5758e912eb4912ae81639bee8.zip
chromium_src-0d2786c4ee50b3e5758e912eb4912ae81639bee8.tar.gz
chromium_src-0d2786c4ee50b3e5758e912eb4912ae81639bee8.tar.bz2
[HTerm-Crosh] Add support for terminal window resizing to terminal API
Add method terminalPrivate.onTerminalResize that will be called by hterm when its window gets resized. This is needed by some app we might run in pseudo-terminal that need to know window size to work properly. BUG=chromium-os:25947 TEST=Open some file in crosh using vi, and verify that the file is shown in full terminal screen. Review URL: https://chromiumcodereview.appspot.com/9121035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/process_proxy/process_proxy.cc13
-rw-r--r--chrome/browser/chromeos/process_proxy/process_proxy.h10
-rw-r--r--chrome/browser/chromeos/process_proxy/process_proxy_registry.cc8
-rw-r--r--chrome/browser/chromeos/process_proxy/process_proxy_registry.h11
4 files changed, 35 insertions, 7 deletions
diff --git a/chrome/browser/chromeos/process_proxy/process_proxy.cc b/chrome/browser/chromeos/process_proxy/process_proxy.cc
index 04b2c3f..a5b3ac9 100644
--- a/chrome/browser/chromeos/process_proxy/process_proxy.cc
+++ b/chrome/browser/chromeos/process_proxy/process_proxy.cc
@@ -156,6 +156,19 @@ bool ProcessProxy::Write(const std::string& text) {
return (bytes_written == static_cast<int>(data_size));
}
+bool ProcessProxy::OnTerminalResize(int width, int height) {
+ if (width < 0 || height < 0)
+ return false;
+
+ winsize ws;
+ // Number of rows.
+ ws.ws_row = height;
+ // Number of columns.
+ ws.ws_col = width;
+
+ return (HANDLE_EINTR(ioctl(pt_pair_[PT_MASTER_FD], TIOCSWINSZ, &ws)) != -1);
+}
+
ProcessProxy::~ProcessProxy() {
// In case watcher did not started, we may get deleted without calling Close.
// In that case we have to clean up created pipes. If watcher had been
diff --git a/chrome/browser/chromeos/process_proxy/process_proxy.h b/chrome/browser/chromeos/process_proxy/process_proxy.h
index d3507f0..fb50655 100644
--- a/chrome/browser/chromeos/process_proxy/process_proxy.h
+++ b/chrome/browser/chromeos/process_proxy/process_proxy.h
@@ -26,7 +26,7 @@ class ProcessProxy : public base::RefCountedThreadSafe<ProcessProxy> {
public:
ProcessProxy();
- // Open a process using command |command|. |pid| is set to new process' pid.
+ // Opens a process using command |command|. |pid| is set to new process' pid.
bool Open(const std::string& command, pid_t* pid);
// Triggers watcher object on |watch_thread|. |watch_thread| gets blocked, so
@@ -35,12 +35,16 @@ class ProcessProxy : public base::RefCountedThreadSafe<ProcessProxy> {
bool StartWatchingOnThread(base::Thread* watch_thread,
const ProcessOutputCallback& callback);
- // Send some data to the process.
+ // Sends some data to the process.
bool Write(const std::string& text);
- // Close. Must be called if we want this to be eventually deleted.
+ // Closes the process.
+ // Must be called if we want this to be eventually deleted.
void Close();
+ // Notifies underlaying process of terminal size change.
+ bool OnTerminalResize(int width, int height);
+
private:
friend class base::RefCountedThreadSafe<ProcessProxy>;
// We want this be used as ref counted object only.
diff --git a/chrome/browser/chromeos/process_proxy/process_proxy_registry.cc b/chrome/browser/chromeos/process_proxy/process_proxy_registry.cc
index 5c5a09f..22191fc 100644
--- a/chrome/browser/chromeos/process_proxy/process_proxy_registry.cc
+++ b/chrome/browser/chromeos/process_proxy/process_proxy_registry.cc
@@ -115,6 +115,14 @@ bool ProcessProxyRegistry::CloseProcess(pid_t pid) {
return true;
}
+bool ProcessProxyRegistry::OnTerminalResize(pid_t pid, int width, int height) {
+ std::map<pid_t, ProcessProxyInfo>::iterator it = proxy_map_.find(pid);
+ if (it == proxy_map_.end())
+ return false;
+
+ return it->second.proxy->OnTerminalResize(width, height);
+}
+
void ProcessProxyRegistry::OnProcessOutput(pid_t pid,
ProcessOutputType type, const std::string& data) {
const char* type_str = ProcessOutputTypeToString(type);
diff --git a/chrome/browser/chromeos/process_proxy/process_proxy_registry.h b/chrome/browser/chromeos/process_proxy/process_proxy_registry.h
index b6aa71a..776f3a1 100644
--- a/chrome/browser/chromeos/process_proxy/process_proxy_registry.h
+++ b/chrome/browser/chromeos/process_proxy/process_proxy_registry.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -40,12 +40,14 @@ class ProcessProxyRegistry {
// Starts new ProcessProxy (which starts new process).
bool OpenProcess(const std::string& command, pid_t* pid,
const ProcessOutputCallbackWithPid& callback);
- // Send data to the process with id |pid|.
+ // Sends data to the process with id |pid|.
bool SendInput(pid_t pid, const std::string& data);
- // Stop the process with id |pid|.
+ // Stops the process with id |pid|.
bool CloseProcess(pid_t pid);
+ // Reports terminal resize to process proxy.
+ bool OnTerminalResize(pid_t pid, int width, int height);
- // Gets called when output gets detected. Currently used for testing.
+ // Currently used for testing.
void SetOutputCallback(const ProcessOutputCallback& callback);
private:
@@ -54,6 +56,7 @@ class ProcessProxyRegistry {
ProcessProxyRegistry();
~ProcessProxyRegistry();
+ // Gets called when output gets detected.
void OnProcessOutput(pid_t pid,
ProcessOutputType type,
const std::string& data);