23bcf108522e34140661474eb6fa23ca1956985f
[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/manifest.h"
13
14
15 class GURL;
16
17 namespace base {
18 class DictionaryValue;
19 class FilePath;
20 }
21
22 // Utilities for manipulating the on-disk storage of applications.
23 namespace xwalk {
24 namespace application {
25
26 class ApplicationData;
27
28 // Loads and validates an application from the specified directory. Returns NULL
29 // on failure, with a description of the error in |error|.
30 scoped_refptr<ApplicationData> LoadApplication(
31     const base::FilePath& application_root,
32     Manifest::SourceType source_type,
33     std::string* error);
34
35 // The same as LoadApplication except use the provided |application_id|.
36 scoped_refptr<ApplicationData> LoadApplication(
37     const base::FilePath& application_root,
38     const std::string& application_id,
39     Manifest::SourceType source_type,
40     std::string* error);
41
42 // Loads an application manifest from the specified directory. Returns NULL
43 // on failure, with a description of the error in |error|.
44 base::DictionaryValue* LoadManifest(const base::FilePath& application_root,
45                                     std::string* error);
46
47 // Get a relative file path from an app:// URL.
48 base::FilePath ApplicationURLToRelativeFilePath(const GURL& url);
49
50 }  // namespace application
51 }  // namespace xwalk
52
53 #endif  // XWALK_APPLICATION_COMMON_APPLICATION_FILE_UTIL_H_