Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / file_manager / private_api_util.h
blob6516048469404c4a03507d9778ef5539bea77f1e
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.
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 <vector>
12 #include "base/callback_forward.h"
14 class GURL;
15 class Profile;
17 namespace base {
18 class FilePath;
21 namespace content {
22 class RenderFrameHost;
25 namespace drive {
26 class EventLogger;
29 namespace extensions {
30 namespace api {
31 namespace file_manager_private {
32 struct VolumeMetadata;
37 namespace ui {
38 struct SelectedFileInfo;
41 namespace file_manager {
43 class Volume;
45 namespace util {
47 // Converts the |volume| to VolumeMetadata to communicate with JavaScript via
48 // private API.
49 void VolumeToVolumeMetadata(
50 Profile* profile,
51 const Volume& volume,
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,
62 Profile* profile,
63 const GURL& url);
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,
86 Profile* profile,
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,
94 Profile* profile);
96 // Get event logger to chrome://drive-internals page for the |profile|.
97 drive::EventLogger* GetLogger(Profile* profile);
99 } // namespace util
100 } // namespace file_manager
102 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_