diff options
author | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 17:04:23 +0000 |
---|---|---|
committer | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 17:04:23 +0000 |
commit | ca376bec682660d84888acb7046f7531f7f1ca66 (patch) | |
tree | baa94f4bd3dce3dbe77ca64b27eb4ae039500dd9 /remoting | |
parent | 2c225270c09e184b4958c149103dbd62ac6deb44 (diff) | |
download | chromium_src-ca376bec682660d84888acb7046f7531f7f1ca66.zip chromium_src-ca376bec682660d84888acb7046f7531f7f1ca66.tar.gz chromium_src-ca376bec682660d84888acb7046f7531f7f1ca66.tar.bz2 |
Fixed continue window bugs and added 60s auto-shutdown timeout.
BUG=92415
TEST=Manual
Review URL: http://codereview.chromium.org/7714026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98253 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/chromoting_host.cc | 2 | ||||
-rw-r--r-- | remoting/host/desktop_environment.cc | 50 | ||||
-rw-r--r-- | remoting/host/desktop_environment.h | 8 | ||||
-rw-r--r-- | remoting/webapp/me2mom/choice.css | 4 | ||||
-rw-r--r-- | remoting/webapp/me2mom/client_session.js | 7 | ||||
-rw-r--r-- | remoting/webapp/me2mom/remoting.js | 3 |
6 files changed, 61 insertions, 13 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index dd8299d..46282da 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -358,7 +358,7 @@ void ChromotingHost::PauseSession(bool pause) { for (client = clients_.begin(); client != clients_.end(); ++client) { client->get()->set_awaiting_continue_approval(pause); } - desktop_environment_->OnPause(!pause); + desktop_environment_->OnPause(pause); } void ChromotingHost::SetUiStrings(const UiStrings& ui_strings) { diff --git a/remoting/host/desktop_environment.cc b/remoting/host/desktop_environment.cc index 14620b0..ada7c2a 100644 --- a/remoting/host/desktop_environment.cc +++ b/remoting/host/desktop_environment.cc @@ -15,7 +15,12 @@ #include "remoting/host/event_executor.h" #include "remoting/host/local_input_monitor.h" -static const int kContinueWindowTimeoutMs = 10 * 60 * 1000; +// Milliseconds before the continue window is shown. +static const int kContinueWindowShowTimeoutMs = 10 * 60 * 1000; + +// Milliseconds before the continue window is automatically dismissed and +// the connection is closed. +static const int kContinueWindowHideTimeoutMs = 60 * 1000; namespace remoting { @@ -32,7 +37,7 @@ namespace remoting { // MessageLoopProxy. class UIThreadProxy : public base::RefCountedThreadSafe<UIThreadProxy> { public: - UIThreadProxy(base::MessageLoopProxy* message_loop) + explicit UIThreadProxy(base::MessageLoopProxy* message_loop) : message_loop_(message_loop) { } @@ -119,7 +124,7 @@ DesktopEnvironment::DesktopEnvironment(ChromotingHostContext* context, continue_window_(continue_window), local_input_monitor_(local_input_monitor), is_monitoring_local_inputs_(false), - continue_timer_started_(false), + continue_timer_state_(INACTIVE), proxy_(new UIThreadProxy(context->ui_message_loop())) { } @@ -170,7 +175,10 @@ void DesktopEnvironment::ProcessOnLastDisconnect() { } void DesktopEnvironment::ProcessOnPause(bool pause) { - StartContinueWindowTimer(!pause); + if (!pause) { + continue_timer_state_ = INACTIVE; + StartContinueWindowTimer(true); + } } void DesktopEnvironment::MonitorLocalInputs(bool enable) { @@ -210,16 +218,18 @@ void DesktopEnvironment::ShowContinueWindow(bool show) { void DesktopEnvironment::StartContinueWindowTimer(bool start) { DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); - if (start && !continue_timer_started_) { + if (start && continue_timer_state_ == INACTIVE) { continue_timer_target_time_ = base::Time::Now() + - base::TimeDelta::FromMilliseconds(kContinueWindowTimeoutMs); + base::TimeDelta::FromMilliseconds(kContinueWindowShowTimeoutMs); proxy_->CallOnUIThreadDelayed( FROM_HERE, base::Bind(&DesktopEnvironment::ContinueWindowTimerFunc, base::Unretained(this)), - kContinueWindowTimeoutMs); + kContinueWindowShowTimeoutMs); + continue_timer_state_ = SHOW_DIALOG; + } else if (!start) { + continue_timer_state_ = INACTIVE; } - continue_timer_started_ = start; } void DesktopEnvironment::ContinueWindowTimerFunc() { @@ -230,9 +240,27 @@ void DesktopEnvironment::ContinueWindowTimerFunc() { if (continue_timer_target_time_ > base::Time::Now()) return; - continue_timer_started_ = false; - host_->PauseSession(true); - ShowContinueWindow(true); + switch (continue_timer_state_) { + case INACTIVE: + // This function will still be called, even if the timeout was cancelled. + return; + case SHOW_DIALOG: + host_->PauseSession(true); + ShowContinueWindow(true); + continue_timer_target_time_ = base::Time::Now() + + base::TimeDelta::FromMilliseconds(kContinueWindowHideTimeoutMs); + proxy_->CallOnUIThreadDelayed( + FROM_HERE, base::Bind(&DesktopEnvironment::ContinueWindowTimerFunc, + base::Unretained(this)), + kContinueWindowHideTimeoutMs); + continue_timer_state_ = SHUTDOWN_HOST; + break; + case SHUTDOWN_HOST: + continue_timer_state_ = INACTIVE; + ShowContinueWindow(false); + host_->Shutdown(NULL); + break; + } } diff --git a/remoting/host/desktop_environment.h b/remoting/host/desktop_environment.h index 9537461..0fc00c9 100644 --- a/remoting/host/desktop_environment.h +++ b/remoting/host/desktop_environment.h @@ -58,6 +58,12 @@ class DesktopEnvironment { void OnPause(bool pause); private: + enum ContinueTimerState { + INACTIVE, // The timer is not running or has been cancelled. + SHOW_DIALOG, // Show the continue dialog when the timer expires. + SHUTDOWN_HOST // Shutdown the Chromoting host when the timer expires. + }; + void ProcessOnConnect(const std::string& username); void ProcessOnLastDisconnect(); void ProcessOnPause(bool pause); @@ -105,7 +111,7 @@ class DesktopEnvironment { bool is_monitoring_local_inputs_; // Timer controlling the "continue session" dialog. - bool continue_timer_started_; + ContinueTimerState continue_timer_state_; base::Time continue_timer_target_time_; scoped_refptr<UIThreadProxy> proxy_; diff --git a/remoting/webapp/me2mom/choice.css b/remoting/webapp/me2mom/choice.css index 5e4140a..945f1a3 100644 --- a/remoting/webapp/me2mom/choice.css +++ b/remoting/webapp/me2mom/choice.css @@ -140,6 +140,10 @@ label { margin-bottom: 10px; } +.hide-scrollbars { + overflow-y: hidden; +} + .top-primary { font-size: 14px; position: absolute; diff --git a/remoting/webapp/me2mom/client_session.js b/remoting/webapp/me2mom/client_session.js index d697019..1dc22aa 100644 --- a/remoting/webapp/me2mom/client_session.js +++ b/remoting/webapp/me2mom/client_session.js @@ -395,9 +395,16 @@ remoting.ClientSession.prototype.toggleScaleToFit = function(shouldScale) { this.plugin.width = this.plugin.desktopWidth; this.plugin.height = this.plugin.desktopHeight; } + remoting.debug.log('window size is now: ' + + window.innerWidth + ' x ' + window.innerHeight + '.'); remoting.debug.log('plugin size is now: ' + this.plugin.width + ' x ' + this.plugin.height + '.'); this.plugin.setScaleToFit(shouldScale); + if (shouldScale) { + addClass(document.all[0], 'hide-scrollbars'); + } else { + removeClass(document.all[0], 'hide-scrollbars'); + } remoting.debug.log('scale to fit is now: ' + shouldScale); }; diff --git a/remoting/webapp/me2mom/remoting.js b/remoting/webapp/me2mom/remoting.js index 3165fe5..acd1d13 100644 --- a/remoting/webapp/me2mom/remoting.js +++ b/remoting/webapp/me2mom/remoting.js @@ -634,3 +634,6 @@ remoting.promptClose = function() { } }()); + +// Shortcut to save typing now that this is the only way to show the debug log. +var tdl = remoting.toggleDebugLog;
\ No newline at end of file |