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.
5 // This file provides utility functions for fileManagerPrivate API.
7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_
8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_
12 #include "base/callback_forward.h"
22 class RenderFrameHost
;
29 namespace extensions
{
31 namespace file_manager_private
{
32 struct VolumeMetadata
;
38 struct SelectedFileInfo
;
41 namespace file_manager
{
47 // Converts the |volume| to VolumeMetadata to communicate with JavaScript via
49 void VolumeToVolumeMetadata(
52 extensions::api::file_manager_private::VolumeMetadata
* volume_metadata
);
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_frame_host| and |profile| are needed to obtain the
57 // FileSystemContext currently in use.
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::RenderFrameHost
* render_frame_host
,
65 // The callback type is used for GetSelectedFileInfo().
66 typedef base::Callback
<void(const std::vector
<ui::SelectedFileInfo
>&)>
67 GetSelectedFileInfoCallback
;
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
,
84 // Gets the information for |file_urls|.
85 void GetSelectedFileInfo(content::RenderFrameHost
* render_frame_host
,
87 const std::vector
<GURL
>& file_urls
,
88 GetSelectedFileInfoLocalPathOption local_path_option
,
89 GetSelectedFileInfoCallback callback
);
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
,
96 // Get event logger to chrome://drive-internals page for the |profile|.
97 drive::EventLogger
* GetLogger(Profile
* profile
);
100 } // namespace file_manager
102 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_