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"
9 #include "base/files/file_util.h"
10 #include "base/files/scoped_file.h"
11 #include "third_party/libxml/chromium/libxml_utils.h"
12 #include "xwalk/application/common/id_util.h"
15 #include "xwalk/application/common/tizen/signature_validator.h"
19 namespace application {
24 const char kIdNodeName[] = "application";
26 const char kIdNodeName[] = "widget";
31 WGTPackage::~WGTPackage() {
34 WGTPackage::WGTPackage(const base::FilePath& path)
35 : Package(path, Manifest::TYPE_WIDGET) {
36 if (!base::PathExists(path))
38 base::FilePath extracted_path;
39 // FIXME : we should not call 'extract' here!
40 if (!ExtractToTemporaryDir(&extracted_path))
44 if (!xml.LoadFile(extracted_path.Append(FILE_PATH_LITERAL("config.xml"))
46 LOG(ERROR) << "Unable to load WGT package config.xml file.";
50 while (!xml.SkipToElement()) {
52 LOG(ERROR) << "Unable to read WGT package config.xml file.";
59 std::string node_name = xml.NodeName();
60 if (node_name == kIdNodeName) {
61 xml.NodeAttribute("id", &value);
69 is_valid_ = SignatureValidator::Check(extracted_path) !=
70 SignatureValidator::INVALID;
72 id_ = GenerateId(value);
76 scoped_ptr<base::ScopedFILE> file(
77 new base::ScopedFILE(base::OpenFile(path, "rb")));
82 } // namespace application