OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/signaling/jid_util.h" | 5 #include "remoting/signaling/jid_util.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 | 8 |
9 namespace remoting { | 9 namespace remoting { |
10 | 10 |
11 std::string NormalizeJid(const std::string& jid) { | 11 std::string NormalizeJid(const std::string& jid) { |
12 std::string bare_jid; | 12 std::string bare_jid; |
13 std::string resource; | 13 std::string resource; |
14 if (SplitJidResource(jid, &bare_jid, &resource)) { | 14 if (SplitJidResource(jid, &bare_jid, &resource)) { |
15 return base::StringToLowerASCII(bare_jid) + "/" + resource; | 15 return base::ToLowerASCII(bare_jid) + "/" + resource; |
16 } | 16 } |
17 return base::StringToLowerASCII(bare_jid); | 17 return base::ToLowerASCII(bare_jid); |
18 } | 18 } |
19 | 19 |
20 bool SplitJidResource(const std::string& full_jid, | 20 bool SplitJidResource(const std::string& full_jid, |
21 std::string* bare_jid, | 21 std::string* bare_jid, |
22 std::string* resource) { | 22 std::string* resource) { |
23 size_t slash_index = full_jid.find('/'); | 23 size_t slash_index = full_jid.find('/'); |
24 if (slash_index == std::string::npos) { | 24 if (slash_index == std::string::npos) { |
25 if (bare_jid) { | 25 if (bare_jid) { |
26 *bare_jid = full_jid; | 26 *bare_jid = full_jid; |
27 } | 27 } |
28 if (resource) { | 28 if (resource) { |
29 resource->clear(); | 29 resource->clear(); |
30 } | 30 } |
31 return false; | 31 return false; |
32 } | 32 } |
33 | 33 |
34 if (bare_jid) { | 34 if (bare_jid) { |
35 *bare_jid = full_jid.substr(0, slash_index); | 35 *bare_jid = full_jid.substr(0, slash_index); |
36 } | 36 } |
37 if (resource) { | 37 if (resource) { |
38 *resource = full_jid.substr(slash_index + 1); | 38 *resource = full_jid.substr(slash_index + 1); |
39 } | 39 } |
40 return true; | 40 return true; |
41 } | 41 } |
42 | 42 |
43 } // namespace remoting | 43 } // namespace remoting |
OLD | NEW |