blob: 0932ed22058688d5920abd481a8487a8c2ffe035 [file] [log] [blame]
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001// 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)c2e0dbd2013-05-09 18:35:53 +010011#include "ui/shell_dialogs/select_file_dialog.h"
12
13class Browser;
Ben Murdocheb525c52013-07-10 11:40:50 +010014class GURL;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010015class Profile;
16
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010017extern const char kFileBrowserDomain[];
18extern const char kFileBrowserGalleryTaskId[];
19extern const char kFileBrowserWatchTaskId[];
20
21// File manager helper methods.
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010022namespace file_manager {
23namespace util {
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010024
25// Gets base file browser url.
26GURL GetFileBrowserExtensionUrl();
27GURL GetFileBrowserUrl();
28GURL GetMediaPlayerUrl();
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010029
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010030// Converts |relative_path| (e.g., "drive/root" or "Downloads") into external
31// filesystem URL (e.g., filesystem://id/external/drive/root).
32GURL 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)c2e0dbd2013-05-09 18:35:53 +010037// if |full_file_path| is not managed by the external filesystem provider.
38bool 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.
46bool 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.
52GURL 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.
61string16 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.
69void ViewRemovableDrive(const base::FilePath& path);
70
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010071// 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.
74void OpenActionChoiceDialog(const base::FilePath& path, bool advanced_mode);
75
76// Opens item with the default File Browser handler.
77void ViewItem(const base::FilePath& path);
78
79// Opens file browser on the folder containing the file, with the file selected.
80void ShowFileInFolder(const base::FilePath& path);
81
Ben Murdochbb1529c2013-08-08 10:24:53 +010082// Executes the built-in File Manager handler or tries to open |path| directly
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010083// in the browser. Returns false if neither is possible.
Ben Murdochbb1529c2013-08-08 10:24:53 +010084bool ExecuteBuiltinHandler(Browser* browser, const base::FilePath& path);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010085
86// Checks whether a pepper plugin for |file_extension| is enabled.
87bool ShouldBeOpenedWithPlugin(Profile* profile, const char* file_extension);
88
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010089// Returns the MIME type of |file_path|.
90std::string GetMimeTypeForPath(const base::FilePath& file_path);
91
Torne (Richard Coles)a36e5922013-08-05 13:57:33 +010092} // namespace util
93} // namespace file_manager
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010094
95#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_MANAGER_UTIL_H_