1a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// found in the LICENSE file. 4a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// 51320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// This file provides utility functions for fileManagerPrivate API. 6a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 7a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_ 8a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_ 9a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <vector> 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 12a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/callback_forward.h" 13a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class GURL; 15a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)class Profile; 16a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace base { 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class FilePath; 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 21a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)namespace content { 22a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)class RenderViewHost; 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace drive { 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class EventLogger; 27a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)} 28a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)namespace extensions { 304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)namespace api { 311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace file_manager_private { 324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)struct VolumeMetadata; 334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 37a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)namespace ui { 38a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)struct SelectedFileInfo; 39a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)} 40a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 41a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)namespace file_manager { 424e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)struct VolumeInfo; 444e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 45a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)namespace util { 46a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 474e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Converts the |volume_info| to VolumeMetadata to communicate with JavaScript 484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// via private API. 494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)void VolumeInfoToVolumeMetadata( 504e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) Profile* profile, 514e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) const VolumeInfo& volume_info, 521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci extensions::api::file_manager_private::VolumeMetadata* volume_metadata); 5358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 54a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// Returns the local FilePath associated with |url|. If the file isn't of the 55a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// type FileSystemBackend handles, returns an empty 56a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// FilePath. |render_view_host| and |profile| are needed to obtain the 57a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// FileSystemContext currently in use. 58a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// 59a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// Local paths will look like "/home/chronos/user/Downloads/foo/bar.txt" or 60a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// "/special/drive/foo/bar.txt". 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)base::FilePath GetLocalPathFromURL(content::RenderViewHost* render_view_host, 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Profile* profile, 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const GURL& url); 64a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 65a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// The callback type is used for GetSelectedFileInfo(). 66a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)typedef base::Callback<void(const std::vector<ui::SelectedFileInfo>&)> 67a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) GetSelectedFileInfoCallback; 68a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 693240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// Option enum to control how to set the ui::SelectedFileInfo::local_path 703240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// fields in GetSelectedFileInfo() for Drive files. 713240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// NO_LOCAL_PATH_RESOLUTION: 723240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// Does nothing. Set the Drive path as-is. 733240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// NEED_LOCAL_PATH_FOR_OPENING: 743240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// Sets the path to a local cache file. 753240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// NEED_LOCAL_PATH_FOR_SAVING: 763240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// Sets the path to a local cache file. Modification to the file is monitored 773240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// and automatically synced to the Drive server. 783240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdochenum GetSelectedFileInfoLocalPathOption { 793240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch NO_LOCAL_PATH_RESOLUTION, 803240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch NEED_LOCAL_PATH_FOR_OPENING, 813240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch NEED_LOCAL_PATH_FOR_SAVING, 823240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch}; 833240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch 84a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// Gets the information for |file_urls|. 85a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)void GetSelectedFileInfo(content::RenderViewHost* render_view_host, 86a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) Profile* profile, 87a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) const std::vector<GURL>& file_urls, 883240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch GetSelectedFileInfoLocalPathOption local_path_option, 89a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) GetSelectedFileInfoCallback callback); 90a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Grants permission to access per-profile folder (Downloads, Drive) of 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// |profile| for the process |render_view_process_id|. 935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SetupProfileFileAccessPermissions(int render_view_process_id, 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Profile* profile); 955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Get event logger to chrome://drive-internals page for the |profile|. 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)drive::EventLogger* GetLogger(Profile* profile); 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 99a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)} // namespace util 100a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)} // namespace file_manager 101a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 102a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_ 103