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 fileBrowserPrivate 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_
10 #include "base/callback_forward.h"
11 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
14 class ExtensionFunctionDispatcher;
22 namespace extensions {
24 namespace file_browser_private {
25 struct VolumeMetadata;
31 struct SelectedFileInfo;
34 namespace file_manager {
40 // Converts the |volume_info| to VolumeMetadata to communicate with JavaScript
42 void VolumeInfoToVolumeMetadata(
44 const VolumeInfo& volume_info,
45 extensions::api::file_browser_private::VolumeMetadata* volume_metadata);
47 // Returns the WebContents of the tab associated with the dispatcher. Returns
49 content::WebContents* GetWebContents(ExtensionFunctionDispatcher* dispatcher);
51 // Returns the ID of the tab associated with the dispatcher. Returns 0 on
53 int32 GetTabId(ExtensionFunctionDispatcher* dispatcher);
55 // Returns the local FilePath associated with |url|. If the file isn't of the
56 // type FileSystemBackend handles, returns an empty
57 // FilePath. |render_view_host| and |profile| are needed to obtain the
58 // FileSystemContext currently in use.
60 // Local paths will look like "/home/chronos/user/Downloads/foo/bar.txt" or
61 // "/special/drive/foo/bar.txt".
62 base::FilePath GetLocalPathFromURL(
63 content::RenderViewHost* render_view_host,
67 // The callback type is used for GetSelectedFileInfo().
68 typedef base::Callback<void(const std::vector<ui::SelectedFileInfo>&)>
69 GetSelectedFileInfoCallback;
71 // Option enum to control how to set the ui::SelectedFileInfo::local_path
72 // fields in GetSelectedFileInfo() for Drive files.
73 // NO_LOCAL_PATH_RESOLUTION:
74 // Does nothing. Set the Drive path as-is.
75 // NEED_LOCAL_PATH_FOR_OPENING:
76 // Sets the path to a local cache file.
77 // NEED_LOCAL_PATH_FOR_SAVING:
78 // Sets the path to a local cache file. Modification to the file is monitored
79 // and automatically synced to the Drive server.
80 enum GetSelectedFileInfoLocalPathOption {
81 NO_LOCAL_PATH_RESOLUTION,
82 NEED_LOCAL_PATH_FOR_OPENING,
83 NEED_LOCAL_PATH_FOR_SAVING,
86 // Gets the information for |file_urls|.
87 void GetSelectedFileInfo(content::RenderViewHost* render_view_host,
89 const std::vector<GURL>& file_urls,
90 GetSelectedFileInfoLocalPathOption local_path_option,
91 GetSelectedFileInfoCallback callback);
94 } // namespace file_manager
96 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_