| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTENSIONS_FILE_MANAGER_UTIL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_FILE_MANAGER_UTIL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_FILE_MANAGER_UTIL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_FILE_MANAGER_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "chrome/browser/ui/select_file_dialog.h" | 12 #include "chrome/browser/ui/select_file_dialog.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 | 14 |
| 15 class Profile; | 15 class Profile; |
| 16 | 16 |
| 17 extern const char kFileBrowserDomain[]; | 17 extern const char kFileBrowserDomain[]; |
| 18 | 18 |
| 19 // Helper class for wiring file browser component extension with the rest of UI. | 19 // File manager helper methods. |
| 20 class FileManagerUtil { | 20 namespace file_manager_util { |
| 21 public: | |
| 22 // Gets base file browser url. | |
| 23 static GURL GetFileBrowserExtensionUrl(); | |
| 24 static GURL GetFileBrowserUrl(); | |
| 25 static GURL GetMediaPlayerUrl(); | |
| 26 static GURL GetMediaPlayerPlaylistUrl(); | |
| 27 | 21 |
| 28 // Converts |full_file_path| into external filesystem: url. Returns false | 22 // Gets base file browser url. |
| 29 // if |full_file_path| is not managed by the external filesystem provider. | 23 GURL GetFileBrowserExtensionUrl(); |
| 30 static bool ConvertFileToFileSystemUrl(Profile* profile, | 24 GURL GetFileBrowserUrl(); |
| 31 const FilePath& full_file_path, const GURL& origin_url, GURL* url); | 25 GURL GetMediaPlayerUrl(); |
| 26 GURL GetMediaPlayerPlaylistUrl(); |
| 32 | 27 |
| 33 // Converts |full_file_path| into |relative_path| within the external provider | 28 // Converts |full_file_path| into external filesystem: url. Returns false |
| 34 // in File API. Returns false if |full_file_path| is not managed by the | 29 // if |full_file_path| is not managed by the external filesystem provider. |
| 35 // external filesystem provider. | 30 bool ConvertFileToFileSystemUrl(Profile* profile, |
| 36 static bool ConvertFileToRelativeFileSystemPath(Profile* profile, | 31 const FilePath& full_file_path, const GURL& origin_url, GURL* url); |
| 37 const FilePath& full_file_path, FilePath* relative_path); | |
| 38 | 32 |
| 39 // Gets base file browser url for. | 33 // Converts |full_file_path| into |relative_path| within the external provider |
| 40 static GURL GetFileBrowserUrlWithParams( | 34 // in File API. Returns false if |full_file_path| is not managed by the |
| 41 SelectFileDialog::Type type, | 35 // external filesystem provider. |
| 42 const string16& title, | 36 bool ConvertFileToRelativeFileSystemPath(Profile* profile, |
| 43 const FilePath& default_virtual_path, | 37 const FilePath& full_file_path, FilePath* relative_path); |
| 44 const SelectFileDialog::FileTypeInfo* file_types, | |
| 45 int file_type_index, | |
| 46 const FilePath::StringType& default_extension); | |
| 47 | 38 |
| 48 // Opens file browser UI in its own tab on file system location defined with | 39 // Gets base file browser url for. |
| 49 // |dir|. | 40 GURL GetFileBrowserUrlWithParams( |
| 50 static void ViewFolder(const FilePath& dir); | 41 SelectFileDialog::Type type, |
| 42 const string16& title, |
| 43 const FilePath& default_virtual_path, |
| 44 const SelectFileDialog::FileTypeInfo* file_types, |
| 45 int file_type_index, |
| 46 const FilePath::StringType& default_extension); |
| 51 | 47 |
| 52 static void ViewItem(const FilePath& full_path, bool enqueue); | 48 // Opens file browser UI in its own tab on file system location defined with |
| 49 // |dir|. |
| 50 void ViewFolder(const FilePath& dir); |
| 53 | 51 |
| 54 private: | 52 void ViewItem(const FilePath& full_path, bool enqueue); |
| 55 FileManagerUtil() {} | |
| 56 // Helper to convert numeric dialog type to a string. | |
| 57 static std::string GetDialogTypeAsString(SelectFileDialog::Type dialog_type); | |
| 58 | 53 |
| 59 DISALLOW_COPY_AND_ASSIGN(FileManagerUtil); | 54 } // namespace file_manager_util |
| 60 }; | |
| 61 | 55 |
| 62 #endif // CHROME_BROWSER_EXTENSIONS_FILE_MANAGER_UTIL_H_ | 56 #endif // CHROME_BROWSER_EXTENSIONS_FILE_MANAGER_UTIL_H_ |
| OLD | NEW |