Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Unified Diff: remoting/base/capabilities.cc

Issue 13932020: Set the initial resolution of an RDP session to the client screen resolution if it is available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Clang Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/base/capabilities.h ('k') | remoting/base/capabilities_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/capabilities.cc
diff --git a/remoting/base/capabilities.cc b/remoting/base/capabilities.cc
new file mode 100644
index 0000000000000000000000000000000000000000..47756d26668843764ba038a240e1b9d1b7a36b88
--- /dev/null
+++ b/remoting/base/capabilities.cc
@@ -0,0 +1,44 @@
+// Copyright 2013 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/base/capabilities.h"
+
+#include <algorithm>
+#include <vector>
+
+#include "base/string_util.h"
+
+namespace remoting {
+
+bool HasCapability(const std::string& capabilities, const std::string& key) {
+ std::vector<std::string> caps;
+ Tokenize(capabilities, " ", &caps);
+ return std::find(caps.begin(), caps.end(), key) != caps.end();
+}
+
+std::string IntersectCapabilities(const std::string& client_capabilities,
+ const std::string& host_capabilities) {
+ std::vector<std::string> client_caps;
+ Tokenize(client_capabilities, " ", &client_caps);
+ std::sort(client_caps.begin(), client_caps.end());
+
+ std::vector<std::string> host_caps;
+ Tokenize(host_capabilities, " ", &host_caps);
+ std::sort(host_caps.begin(), host_caps.end());
+
+ std::vector<std::string> result(std::min(client_caps.size(),
+ host_caps.size()));
+ std::vector<std::string>::iterator end =
+ std::set_intersection(client_caps.begin(),
+ client_caps.end(),
+ host_caps.begin(),
+ host_caps.end(),
+ result.begin());
+ if (end != result.end())
+ result.erase(end, result.end());
+
+ return JoinString(result, " ");
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/base/capabilities.h ('k') | remoting/base/capabilities_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698