- add sources.
[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 fileBrowserPrivate 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 "base/callback_forward.h"
11 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
12 #include "url/gurl.h"
13
14 class ExtensionFunctionDispatcher;
15 class Profile;
16
17 namespace content {
18 class RenderViewHost;
19 class WebContents;
20 }
21
22 namespace extensions {
23 namespace api {
24 namespace file_browser_private {
25 struct VolumeMetadata;
26 }
27 }
28 }
29
30 namespace ui {
31 struct SelectedFileInfo;
32 }
33
34 namespace file_manager {
35
36 struct VolumeInfo;
37
38 namespace util {
39
40 // Converts the |volume_info| to VolumeMetadata to communicate with JavaScript
41 // via private API.
42 void VolumeInfoToVolumeMetadata(
43     Profile* profile,
44     const VolumeInfo& volume_info,
45     extensions::api::file_browser_private::VolumeMetadata* volume_metadata);
46
47 // Returns the WebContents of the tab associated with the dispatcher. Returns
48 // NULL on error.
49 content::WebContents* GetWebContents(ExtensionFunctionDispatcher* dispatcher);
50
51 // Returns the ID of the tab associated with the dispatcher. Returns 0 on
52 // error.
53 int32 GetTabId(ExtensionFunctionDispatcher* dispatcher);
54
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.
59 //
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,
64     Profile* profile,
65     const GURL& url);
66
67 // The callback type is used for GetSelectedFileInfo().
68 typedef base::Callback<void(const std::vector<ui::SelectedFileInfo>&)>
69     GetSelectedFileInfoCallback;
70
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,
84 };
85
86 // Gets the information for |file_urls|.
87 void GetSelectedFileInfo(content::RenderViewHost* render_view_host,
88                          Profile* profile,
89                          const std::vector<GURL>& file_urls,
90                          GetSelectedFileInfoLocalPathOption local_path_option,
91                          GetSelectedFileInfoCallback callback);
92
93 }  // namespace util
94 }  // namespace file_manager
95
96 #endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_