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/package/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 #include "xwalk/application/common/tizen/signature_validator.h"
17 namespace application {
20 const char kIdNodeName[] = "application";
22 const char kIdNodeName[] = "widget";
26 WGTPackage::~WGTPackage() {
29 WGTPackage::WGTPackage(const base::FilePath& path)
31 if (!base::PathExists(path))
33 manifest_type_ = Manifest::TYPE_WIDGET;
34 base::FilePath extracted_path;
35 // FIXME : we should not call 'extract' here!
36 if (!ExtractToTemporaryDir(&extracted_path))
40 if (!xml.LoadFile(extracted_path.Append(FILE_PATH_LITERAL("config.xml"))
42 LOG(ERROR) << "Unable to load WGT package config.xml file.";
46 while (!xml.SkipToElement()) {
48 LOG(ERROR) << "Unable to read WGT package config.xml file.";
55 std::string node_name = xml.NodeName();
56 if (node_name == kIdNodeName) {
57 xml.NodeAttribute("id", &value);
66 SignatureValidator::Check(extracted_path) != SignatureValidator::INVALID;
68 id_ = GenerateId(value);
72 scoped_ptr<base::ScopedFILE> file(
73 new base::ScopedFILE(base::OpenFile(path, "rb")));
77 } // namespace application