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 struct SelectedFileInfo
;
25 namespace file_manager
{
28 // Returns the ID of the tab associated with the dispatcher. Returns 0 on
30 int32
GetTabId(ExtensionFunctionDispatcher
* dispatcher
);
32 // Returns the local FilePath associated with |url|. If the file isn't of the
33 // type FileSystemBackend handles, returns an empty
34 // FilePath. |render_view_host| and |profile| are needed to obtain the
35 // FileSystemContext currently in use.
37 // Local paths will look like "/home/chronos/user/Downloads/foo/bar.txt" or
38 // "/special/drive/foo/bar.txt".
39 base::FilePath
GetLocalPathFromURL(
40 content::RenderViewHost
* render_view_host
,
44 // The callback type is used for GetSelectedFileInfo().
45 typedef base::Callback
<void(const std::vector
<ui::SelectedFileInfo
>&)>
46 GetSelectedFileInfoCallback
;
48 // Option enum to control how to set the ui::SelectedFileInfo::local_path
49 // fields in GetSelectedFileInfo() for Drive files.
50 // NO_LOCAL_PATH_RESOLUTION:
51 // Does nothing. Set the Drive path as-is.
52 // NEED_LOCAL_PATH_FOR_OPENING:
53 // Sets the path to a local cache file.
54 // NEED_LOCAL_PATH_FOR_SAVING:
55 // Sets the path to a local cache file. Modification to the file is monitored
56 // and automatically synced to the Drive server.
57 enum GetSelectedFileInfoLocalPathOption
{
58 NO_LOCAL_PATH_RESOLUTION
,
59 NEED_LOCAL_PATH_FOR_OPENING
,
60 NEED_LOCAL_PATH_FOR_SAVING
,
63 // Gets the information for |file_urls|.
64 void GetSelectedFileInfo(content::RenderViewHost
* render_view_host
,
66 const std::vector
<GURL
>& file_urls
,
67 GetSelectedFileInfoLocalPathOption local_path_option
,
68 GetSelectedFileInfoCallback callback
);
71 } // namespace file_manager
73 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_