OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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. | |
4 | |
5 #include "chrome/browser/chromeos/dbus/introspect_util.h" | |
6 | |
7 #include "third_party/libxml/chromium/libxml_utils.h" | |
8 | |
9 namespace { | |
10 | |
11 // String constants used for parsing D-Bus Introspection XML data. | |
12 const char kInterfaceNode[] = "interface"; | |
13 const char kInterfaceNameAttribute[] = "name"; | |
14 | |
15 } | |
16 | |
17 namespace chromeos { | |
18 | |
19 std::vector<std::string> GetInterfacesFromIntrospectResult( | |
20 const std::string& xml_data) { | |
21 std::vector<std::string> interfaces; | |
22 | |
23 XmlReader reader; | |
24 if (!reader.Load(xml_data)) | |
25 return interfaces; | |
26 | |
27 do { | |
28 // Skip to the next open tag, exit when done. | |
29 while (!reader.SkipToElement()) { | |
30 if (!reader.Read()) { | |
31 return interfaces; | |
32 } | |
33 } | |
34 | |
35 // Only look at interface nodes. | |
36 if (reader.NodeName() != kInterfaceNode) | |
37 continue; | |
38 | |
39 // Skip if missing the interface name. | |
40 std::string interface_name; | |
41 if (!reader.NodeAttribute(kInterfaceNameAttribute, &interface_name)) | |
42 continue; | |
43 | |
44 interfaces.push_back(interface_name); | |
45 } while (reader.Read()); | |
46 | |
47 return interfaces; | |
48 } | |
49 | |
50 } | |
OLD | NEW |