Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / extensions / file_manager / private_api_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 utility functions for fileManagerPrivate API.
6
7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_
8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_
9
10 #include <vector>
11
12 #include "base/callback_forward.h"
13
14 class GURL;
15 class Profile;
16
17 namespace base {
18 class FilePath;
19 }
20
21 namespace content {
22 class RenderViewHost;
23 }
24
25 namespace drive {
26 class EventLogger;
27 }
28
29 namespace extensions {
30 namespace api {
31 namespace file_manager_private {
32 struct VolumeMetadata;
33 }
34 }
35 }
36
37 namespace ui {
38 struct SelectedFileInfo;
39 }
40
41 namespace file_manager {
42
43 struct VolumeInfo;
44
45 namespace util {
46
47 // Converts the |volume_info| to VolumeMetadata to communicate with JavaScript
48 // via private API.
49 void VolumeInfoToVolumeMetadata(
50     Profile* profile,
51     const VolumeInfo& volume_info,
52     extensions::api::file_manager_private::VolumeMetadata* volume_metadata);
53
54 // Returns the local FilePath associated with |url|. If the file isn't of the
55 // type FileSystemBackend handles, returns an empty
56 // FilePath. |render_view_host| and |profile| are needed to obtain the
57 // FileSystemContext currently in use.
58 //
59 // Local paths will look like "/home/chronos/user/Downloads/foo/bar.txt" or
60 // "/special/drive/foo/bar.txt".
61 base::FilePath GetLocalPathFromURL(content::RenderViewHost* render_view_host,
62                                    Profile* profile,
63                                    const GURL& url);
64
65 // The callback type is used for GetSelectedFileInfo().
66 typedef base::Callback<void(const std::vector<ui::SelectedFileInfo>&)>
67     GetSelectedFileInfoCallback;
68
69 // Option enum to control how to set the ui::SelectedFileInfo::local_path
70 // fields in GetSelectedFileInfo() for Drive files.
71 // NO_LOCAL_PATH_RESOLUTION:
72 //   Does nothing. Set the Drive path as-is.
73 // NEED_LOCAL_PATH_FOR_OPENING:
74 //   Sets the path to a local cache file.
75 // NEED_LOCAL_PATH_FOR_SAVING:
76 //   Sets the path to a local cache file. Modification to the file is monitored
77 //   and automatically synced to the Drive server.
78 enum GetSelectedFileInfoLocalPathOption {
79   NO_LOCAL_PATH_RESOLUTION,
80   NEED_LOCAL_PATH_FOR_OPENING,
81   NEED_LOCAL_PATH_FOR_SAVING,
82 };
83
84 // Gets the information for |file_urls|.
85 void GetSelectedFileInfo(content::RenderViewHost* render_view_host,
86                          Profile* profile,
87                          const std::vector<GURL>& file_urls,
88                          GetSelectedFileInfoLocalPathOption local_path_option,
89                          GetSelectedFileInfoCallback callback);
90
91 // Grants permission to access per-profile folder (Downloads, Drive) of
92 // |profile| for the process |render_view_process_id|.
93 void SetupProfileFileAccessPermissions(int render_view_process_id,
94                                        Profile* profile);
95
96 // Get event logger to chrome://drive-internals page for the |profile|.
97 drive::EventLogger* GetLogger(Profile* profile);
98
99 }  // namespace util
100 }  // namespace file_manager
101
102 #endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_