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/common/installer/wgt_package.h"
7 #include "base/file_util.h"
8 #include "base/files/scoped_file.h"
9 #include "third_party/libxml/chromium/libxml_utils.h"
10 #include "xwalk/application/common/id_util.h"
13 namespace application {
16 const char kIdNodeName[] = "application";
18 const char kIdNodeName[] = "widget";
22 WGTPackage::~WGTPackage() {
25 WGTPackage::WGTPackage(const base::FilePath& path)
27 if (!base::PathExists(path))
30 base::FilePath extracted_path;
31 if (!Extract(&extracted_path))
35 if (!xml.LoadFile(extracted_path.Append(FILE_PATH_LITERAL("config.xml"))
37 LOG(ERROR) << "Unable to load WGT package config.xml file.";
41 while (!xml.SkipToElement()) {
43 LOG(ERROR) << "Unable to read WGT package config.xml file.";
50 std::string node_name = xml.NodeName();
51 if (node_name == kIdNodeName) {
52 xml.NodeAttribute("id", &value);
61 id_ = GenerateId(value);
66 scoped_ptr<base::ScopedFILE> file(
67 new base::ScopedFILE(base::OpenFile(path, "rb")));
72 } // namespace application