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 #ifndef XWALK_APPLICATION_COMMON_PACKAGE_PACKAGE_H_
6 #define XWALK_APPLICATION_COMMON_PACKAGE_PACKAGE_H_
11 #include "base/files/file_path.h"
12 #include "base/files/scoped_file.h"
13 #include "base/files/scoped_temp_dir.h"
14 #include "base/memory/scoped_ptr.h"
17 namespace application {
19 // Base class for all types of packages (right now .wgt and .xpk)
20 // The actual zip file, id, is_valid_, source_path_ are common in all packages
21 // specifics like signature checking for XPK are taken care of in
22 // XPKPackage::Validate()
31 bool IsValid() const { return is_valid_; }
32 const std::string& Id() const { return id_; }
33 const std::string& name() const { return name_; }
34 Type type() const { return type_; }
35 // Factory method for creating a package
36 static scoped_ptr<Package> Create(const base::FilePath& path);
37 // The function will unzip the XPK/WGT file and return the target path where
38 // to decompress by the parameter |target_path|.
39 virtual bool ExtractToTemporaryDir(base::FilePath* result_path);
40 // The function will unzip the XPK/WGT file to the given folder.
41 virtual bool ExtractTo(const base::FilePath& target_path);
44 explicit Package(const base::FilePath& source_path);
45 // Unzipping of the zipped file happens in a temporary directory
46 bool CreateTempDirectory();
47 scoped_ptr<base::ScopedFILE> file_;
50 base::FilePath source_path_;
53 // Temporary directory for unpacking.
54 base::ScopedTempDir temp_dir_;
55 // Represent if the package has been extracted.
60 } // namespace application
63 #endif // XWALK_APPLICATION_COMMON_PACKAGE_PACKAGE_H_