Index: remoting/host/desktop_resizer.cc |
diff --git a/remoting/host/desktop_resizer.cc b/remoting/host/desktop_resizer.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a61c14876fbc9f401fc9708737d42413682cf621 |
--- /dev/null |
+++ b/remoting/host/desktop_resizer.cc |
@@ -0,0 +1,44 @@ |
+// 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. |
+ |
+#include "remoting/host/desktop_resizer.h" |
+ |
+namespace remoting { |
+ |
+DesktopResizer::~DesktopResizer() { |
+} |
+ |
+DesktopResizer::HostStatusObserver::HostStatusObserver( |
+ DesktopResizer* desktop_resizer) |
+ : desktop_resizer_(desktop_resizer), |
+ original_size_(SkISize::Make(0, 0)) { |
+} |
+ |
+void DesktopResizer::HostStatusObserver::OnClientAuthenticated( |
+ const std::string& jid) { |
+ original_size_ = desktop_resizer_->GetSize(); |
+} |
+ |
+void DesktopResizer::HostStatusObserver::OnClientDisconnected( |
+ const std::string& jid) { |
+ SkISize zero = SkISize::Make(0, 0); |
+ if (original_size_ != zero) { |
+ desktop_resizer_->SetSize(original_size_); |
+ original_size_ = zero; |
+ } |
+} |
+ |
+void DesktopResizer::HostStatusObserver::OnClientDimensionsChanged( |
+ const SkISize& size) { |
+ // Set a sensible minimum size for the host desktop. Note that the |
+ // implementation is free to impose a stricter minimum size and/or |
+ // a maximum size in addition to this. |
+ const int kMinWidth = 640; |
+ const int kMinHeight = 480; |
+ SkISize new_size(SkISize::Make(std::max(kMinWidth, size.width()), |
+ std::max(kMinHeight, size.height()))); |
+ desktop_resizer_->SetSize(new_size); |
+} |
+ |
+} // namespace remoting |