1 // Copyright (c) 2013 Intel Corporation. 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 "xwalk/application/browser/installer/wgt_package.h"
7 #include "base/file_util.h"
8 #include "third_party/libxml/chromium/libxml_utils.h"
9 #include "xwalk/application/common/id_util.h"
12 namespace application {
15 const char kIdNodeName[] = "application";
17 const char kIdNodeName[] = "widget";
21 WGTPackage::~WGTPackage() {
24 WGTPackage::WGTPackage(const base::FilePath& path)
26 if (!base::PathExists(path))
29 base::FilePath extracted_path;
30 if (!Extract(&extracted_path))
34 if (!xml.LoadFile(extracted_path.Append(FILE_PATH_LITERAL("config.xml"))
36 LOG(ERROR) << "Unable to load WGT package config.xml file.";
40 while (!xml.SkipToElement()) {
42 LOG(ERROR) << "Unable to read WGT package config.xml file.";
49 std::string node_name = xml.NodeName();
50 if (node_name == kIdNodeName) {
51 xml.NodeAttribute("id", &value);
57 id_ = GenerateId(value);
61 scoped_ptr<ScopedStdioHandle> file(
62 new ScopedStdioHandle(base::OpenFile(path, "rb")));
67 } // namespace application