Upstream version 9.38.207.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / common / application_file_util.h
1 // Copyright (c) 2012 The Chromium Authors. 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.
4
5 #ifndef XWALK_APPLICATION_COMMON_APPLICATION_FILE_UTIL_H_
6 #define XWALK_APPLICATION_COMMON_APPLICATION_FILE_UTIL_H_
7
8 #include <string>
9 #include <map>
10
11 #include "base/memory/ref_counted.h"
12 #include "xwalk/application/common/application_data.h"
13
14 class GURL;
15
16 namespace base {
17 class DictionaryValue;
18 class FilePath;
19 }
20
21 // Utilities for manipulating the on-disk storage of applications.
22 namespace xwalk {
23 namespace application {
24
25 class FileDeleter {
26  public:
27   FileDeleter(const base::FilePath& path, bool recursive);
28   ~FileDeleter();
29
30   void Dismiss() { path_.clear(); }
31   const base::FilePath& path() const { return path_; }
32
33  private:
34   base::FilePath path_;
35   bool recursive_;
36 };
37
38 // Loads an application manifest from the specified directory. Returns NULL
39 // on failure, with a description of the error in |error|.
40 scoped_ptr<Manifest> LoadManifest(
41     const base::FilePath& file_path, Manifest::Type type, std::string* error);
42
43 base::FilePath GetManifestPath(
44     const base::FilePath& app_directory, Manifest::Type type);
45
46 // Loads and validates an application from the specified directory. Returns NULL
47 // on failure, with a description of the error in |error|.
48 scoped_refptr<ApplicationData> LoadApplication(
49     const base::FilePath& app_root, const std::string& app_id,
50     ApplicationData::SourceType source_type, Manifest::Type manifest_type,
51     std::string* error);
52
53 // Get a relative file path from an app:// URL.
54 base::FilePath ApplicationURLToRelativeFilePath(const GURL& url);
55
56 }  // namespace application
57 }  // namespace xwalk
58
59 #endif  // XWALK_APPLICATION_COMMON_APPLICATION_FILE_UTIL_H_