Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 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 | #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_MANAGER_UTIL_H_ |
| 6 | #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_MANAGER_UTIL_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/files/file_path.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 11 | #include "ui/shell_dialogs/select_file_dialog.h" |
| 12 | |
| 13 | class Browser; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 14 | class GURL; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 15 | class Profile; |
| 16 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 17 | extern const char kFileBrowserDomain[]; |
| 18 | extern const char kFileBrowserGalleryTaskId[]; |
| 19 | extern const char kFileBrowserWatchTaskId[]; |
| 20 | |
| 21 | // File manager helper methods. |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 22 | namespace file_manager { |
| 23 | namespace util { |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 24 | |
| 25 | // Gets base file browser url. |
| 26 | GURL GetFileBrowserExtensionUrl(); |
| 27 | GURL GetFileBrowserUrl(); |
| 28 | GURL GetMediaPlayerUrl(); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 29 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 30 | // Converts |relative_path| (e.g., "drive/root" or "Downloads") into external |
| 31 | // filesystem URL (e.g., filesystem://id/external/drive/root). |
| 32 | GURL ConvertRelativePathToFileSystemUrl(const base::FilePath& relative_path, |
| 33 | const std::string& extension_id); |
| 34 | |
| 35 | // Converts |full_file_path| (e.g., "/special/drive/root" or |
| 36 | // "/home/chronos/user/Downloads") into external filesystem URL. Returns false |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 37 | // if |full_file_path| is not managed by the external filesystem provider. |
| 38 | bool ConvertFileToFileSystemUrl(Profile* profile, |
| 39 | const base::FilePath& full_file_path, |
| 40 | const std::string& extension_id, |
| 41 | GURL* url); |
| 42 | |
| 43 | // Converts |full_file_path| into |relative_path| within the external provider |
| 44 | // in File API. Returns false if |full_file_path| is not managed by the |
| 45 | // external filesystem provider. |
| 46 | bool ConvertFileToRelativeFileSystemPath(Profile* profile, |
| 47 | const std::string& extension_id, |
| 48 | const base::FilePath& full_file_path, |
| 49 | base::FilePath* relative_path); |
| 50 | |
| 51 | // Gets base file browser url for. |
| 52 | GURL GetFileBrowserUrlWithParams( |
| 53 | ui::SelectFileDialog::Type type, |
| 54 | const string16& title, |
| 55 | const base::FilePath& default_virtual_path, |
| 56 | const ui::SelectFileDialog::FileTypeInfo* file_types, |
| 57 | int file_type_index, |
| 58 | const base::FilePath::StringType& default_extension); |
| 59 | |
| 60 | // Get file dialog title string from its type. |
| 61 | string16 GetTitleFromType(ui::SelectFileDialog::Type type); |
| 62 | |
| 63 | // Shows a freshly mounted removable drive. |
| 64 | // If there is another File Browser instance open this call does nothing. |
| 65 | // The mount event will cause file_manager.js to show the new drive in |
| 66 | // the left panel, and that is all we want. |
| 67 | // If there is no File Browser open, this call opens a new one pointing to |
| 68 | // |path|. In this case the tab will automatically close on |path| unmount. |
| 69 | void ViewRemovableDrive(const base::FilePath& path); |
| 70 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 71 | // Opens an action choice dialog for an external drive. |
| 72 | // One of the actions is opening the File Manager. Passes |advanced_mode| |
| 73 | // flag to the dialog. If it is enabled, then auto-choice gets disabled. |
| 74 | void OpenActionChoiceDialog(const base::FilePath& path, bool advanced_mode); |
| 75 | |
| 76 | // Opens item with the default File Browser handler. |
| 77 | void ViewItem(const base::FilePath& path); |
| 78 | |
| 79 | // Opens file browser on the folder containing the file, with the file selected. |
| 80 | void ShowFileInFolder(const base::FilePath& path); |
| 81 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 82 | // Executes the built-in File Manager handler or tries to open |path| directly |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 83 | // in the browser. Returns false if neither is possible. |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 84 | bool ExecuteBuiltinHandler(Browser* browser, const base::FilePath& path); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 85 | |
| 86 | // Checks whether a pepper plugin for |file_extension| is enabled. |
| 87 | bool ShouldBeOpenedWithPlugin(Profile* profile, const char* file_extension); |
| 88 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 89 | // Returns the MIME type of |file_path|. |
| 90 | std::string GetMimeTypeForPath(const base::FilePath& file_path); |
| 91 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 92 | } // namespace util |
| 93 | } // namespace file_manager |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 94 | |
| 95 | #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_MANAGER_UTIL_H_ |