- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / file_manager / fileapi_util.h
1 // Copyright 2013 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 // This file provides File API related utilities.
6
7 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILEAPI_UTIL_H_
8 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILEAPI_UTIL_H_
9
10 #include <string>
11 #include "url/gurl.h"
12
13 class Profile;
14
15 namespace base {
16 class FilePath;
17 }
18
19 namespace content {
20 class RenderViewHost;
21 }
22
23 namespace fileapi {
24 class FileSystemContext;
25 }
26
27 namespace file_manager {
28 namespace util {
29
30 // Returns a file system context associated with the given profile and the
31 // extension ID.
32 fileapi::FileSystemContext* GetFileSystemContextForExtensionId(
33     Profile* profile,
34     const std::string& extension_id);
35
36 // Returns a file system context associated with the given profile and the
37 // render view host.
38 fileapi::FileSystemContext* GetFileSystemContextForRenderViewHost(
39     Profile* profile,
40     content::RenderViewHost* render_view_host);
41
42 // Converts |relative_path| (e.g., "drive/root" or "Downloads") into external
43 // filesystem URL (e.g., filesystem://id/external/drive/root).
44 GURL ConvertRelativeFilePathToFileSystemUrl(const base::FilePath& relative_path,
45                                             const std::string& extension_id);
46
47 // Converts |absolute_path| (e.g., "/special/drive/root" or
48 // "/home/chronos/user/Downloads") into external filesystem URL. Returns false
49 // if |absolute_path| is not managed by the external filesystem provider.
50 bool ConvertAbsoluteFilePathToFileSystemUrl(
51     Profile* profile,
52     const base::FilePath& absolute_path,
53     const std::string& extension_id,
54     GURL* url);
55
56 // Converts |absolute_path| into |relative_path| within the external
57 // provider in File API. Returns false if |absolute_path| is not managed
58 // by the external filesystem provider.
59 bool ConvertAbsoluteFilePathToRelativeFileSystemPath(
60     Profile* profile,
61     const std::string& extension_id,
62     const base::FilePath& absolute_path,
63     base::FilePath* relative_path);
64
65 }  // namespace util
66 }  // namespace file_manager
67
68 #endif  // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILEAPI_UTIL_H_