OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file provides functions for opening an item (file or directory) using | 5 // This file provides functions for opening an item (file or directory) using |
6 // the file manager. | 6 // the file manager. |
7 | 7 |
8 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_OPEN_UTIL_H_ | 8 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_OPEN_UTIL_H_ |
9 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_OPEN_UTIL_H_ | 9 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_OPEN_UTIL_H_ |
10 | 10 |
| 11 #include "base/callback_forward.h" |
| 12 #include "chrome/browser/platform_util.h" |
| 13 |
11 class Profile; | 14 class Profile; |
12 | 15 |
13 namespace base { | 16 namespace base { |
14 class FilePath; | 17 class FilePath; |
15 } | 18 } |
16 | 19 |
17 namespace file_manager { | 20 namespace file_manager { |
18 namespace util { | 21 namespace util { |
19 | 22 |
20 // Opens an item (file or directory). If the target is a directory, the | 23 // If |item_type| is OPEN_FILE: Opens an item using a file handler, a file |
21 // directory will be opened in the file manager. If the target is a file, the | 24 // browser handler, or the browser (open in a tab). The default handler has |
22 // file will be opened using a file handler, a file browser handler, or the | 25 // precedence over other handlers, if defined for the type of the target file. |
23 // browser (open in a tab). The default handler has precedence over other | 26 // |
24 // handlers, if defined for the type of the target file. | 27 // If |item_type| is OPEN_FOLDER: Open the directory at |file_path| using the |
25 void OpenItem(Profile* profile, const base::FilePath& file_path); | 28 // file browser. |
| 29 // |
| 30 // It is an error for |file_path| to not match the type implied by |item_type|. |
| 31 // This error will be reported to |callback|. |
| 32 // |
| 33 // If |callback| is null, shows an error message to the user indicating the |
| 34 // error if the operation is unsuccessful. No error messages will be displayed |
| 35 // if |callback| is non-null. |
| 36 void OpenItem(Profile* profile, |
| 37 const base::FilePath& file_path, |
| 38 platform_util::OpenItemType item_type, |
| 39 const platform_util::OpenOperationCallback& callback); |
26 | 40 |
27 // Opens the file manager for the folder containing the item specified by | 41 // Opens the file manager for the folder containing the item specified by |
28 // |file_path|, with the item selected. | 42 // |file_path|, with the item selected. |
29 void ShowItemInFolder(Profile* profile, const base::FilePath& file_path); | 43 void ShowItemInFolder(Profile* profile, |
| 44 const base::FilePath& file_path, |
| 45 const platform_util::OpenOperationCallback& callback); |
| 46 |
| 47 // Change the behavior of the above functions to do everything except launch any |
| 48 // extensions including a file browser. |
| 49 void DisableShellOperationsForTesting(); |
30 | 50 |
31 } // namespace util | 51 } // namespace util |
32 } // namespace file_manager | 52 } // namespace file_manager |
33 | 53 |
34 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_OPEN_UTIL_H_ | 54 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_OPEN_UTIL_H_ |
OLD | NEW |