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"
11 #include "xwalk/application/common/installer/tizen/signature_validator.h"
14 namespace application {
17 const char kIdNodeName[] = "application";
19 const char kIdNodeName[] = "widget";
23 WGTPackage::~WGTPackage() {
26 WGTPackage::WGTPackage(const base::FilePath& path)
28 if (!base::PathExists(path))
31 base::FilePath extracted_path;
32 if (!Extract(&extracted_path))
36 if (!xml.LoadFile(extracted_path.Append(FILE_PATH_LITERAL("config.xml"))
38 LOG(ERROR) << "Unable to load WGT package config.xml file.";
42 while (!xml.SkipToElement()) {
44 LOG(ERROR) << "Unable to read WGT package config.xml file.";
51 std::string node_name = xml.NodeName();
52 if (node_name == kIdNodeName) {
53 xml.NodeAttribute("id", &value);
62 SignatureValidator::Check(extracted_path) != SignatureValidator::INVALID;
64 id_ = GenerateId(value);
68 scoped_ptr<base::ScopedFILE> file(
69 new base::ScopedFILE(base::OpenFile(path, "rb")));
73 } // namespace application