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))
28 base::FilePath extracted_path;
29 if (!Extract(&extracted_path))
33 if (!xml.LoadFile(extracted_path.Append(FILE_PATH_LITERAL("config.xml"))
35 LOG(ERROR) << "Unable to load WGT package config.xml file.";
39 while (!xml.SkipToElement()) {
41 LOG(ERROR) << "Unable to read WGT package config.xml file.";
48 std::string node_name = xml.NodeName();
49 if (node_name == kIdNodeName) {
50 xml.NodeAttribute("id", &value);
56 id_ = GenerateId(value);
60 scoped_ptr<ScopedStdioHandle> file(
61 new ScopedStdioHandle(base::OpenFile(path, "rb")));
66 } // namespace application