[Sync] Test Android passphrase creation UI
[chromium-blink-merge.git] / remoting / base / capabilities.cc
blob4e52ef86528e29d7feeb1e3be22004f9da9c12c1
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/base/capabilities.h"
7 #include <algorithm>
8 #include <vector>
10 #include "base/stl_util.h"
11 #include "base/strings/string_util.h"
13 namespace remoting {
15 bool HasCapability(const std::string& capabilities, const std::string& key) {
16 std::vector<std::string> caps;
17 Tokenize(capabilities, " ", &caps);
18 return std::find(caps.begin(), caps.end(), key) != caps.end();
21 std::string IntersectCapabilities(const std::string& client_capabilities,
22 const std::string& host_capabilities) {
23 std::vector<std::string> client_caps;
24 Tokenize(client_capabilities, " ", &client_caps);
25 std::sort(client_caps.begin(), client_caps.end());
27 std::vector<std::string> host_caps;
28 Tokenize(host_capabilities, " ", &host_caps);
29 std::sort(host_caps.begin(), host_caps.end());
31 std::vector<std::string> result =
32 base::STLSetIntersection<std::vector<std::string> >(
33 client_caps, host_caps);
35 return JoinString(result, " ");
38 } // namespace remoting