| OLD | NEW |
| (Empty) |
| 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_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 #include <string> | |
| 10 #include <utility> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/callback.h" | |
| 14 #include "extensions/common/extension.h" | |
| 15 #include "extensions/common/manifest_handlers/file_handler_info.h" | |
| 16 | |
| 17 class Profile; | |
| 18 | |
| 19 namespace extensions { | |
| 20 | |
| 21 struct EntryInfo; | |
| 22 struct FileHandlerInfo; | |
| 23 struct GrantedFileEntry; | |
| 24 | |
| 25 // TODO(benwells): move this to platform_apps namespace. | |
| 26 namespace app_file_handler_util { | |
| 27 | |
| 28 extern const char kInvalidParameters[]; | |
| 29 extern const char kSecurityError[]; | |
| 30 | |
| 31 // Returns the file handler with the specified |handler_id|, or NULL if there | |
| 32 // is no such handler. | |
| 33 const FileHandlerInfo* FileHandlerForId(const Extension& app, | |
| 34 const std::string& handler_id); | |
| 35 | |
| 36 // Returns the handlers that can handle all files in |entries|. | |
| 37 std::vector<const FileHandlerInfo*> FindFileHandlersForEntries( | |
| 38 const Extension& extension, | |
| 39 const std::vector<EntryInfo> entries); | |
| 40 | |
| 41 bool FileHandlerCanHandleEntry(const FileHandlerInfo& handler, | |
| 42 const EntryInfo& entry); | |
| 43 | |
| 44 // Creates a new file entry and allows |renderer_id| to access |path|. This | |
| 45 // registers a new file system for |path|. | |
| 46 GrantedFileEntry CreateFileEntry(Profile* profile, | |
| 47 const Extension* extension, | |
| 48 int renderer_id, | |
| 49 const base::FilePath& path, | |
| 50 bool is_directory); | |
| 51 | |
| 52 // |directory_paths| contain the set of directories out of |paths|. | |
| 53 // For directories it makes sure they exist at their corresponding |paths|, | |
| 54 // while for regular files it makes sure they exist (i.e. not links) at |paths|, | |
| 55 // creating files if needed. If result is successful it calls |on_success|, | |
| 56 // otherwise calls |on_failure|. | |
| 57 void PrepareFilesForWritableApp( | |
| 58 const std::vector<base::FilePath>& paths, | |
| 59 Profile* profile, | |
| 60 const std::set<base::FilePath>& directory_paths, | |
| 61 const base::Closure& on_success, | |
| 62 const base::Callback<void(const base::FilePath&)>& on_failure); | |
| 63 | |
| 64 // Returns whether |extension| has the fileSystem.write permission. | |
| 65 bool HasFileSystemWritePermission(const Extension* extension); | |
| 66 | |
| 67 // Validates a file entry and populates |file_path| with the absolute path if it | |
| 68 // is valid. | |
| 69 bool ValidateFileEntryAndGetPath(const std::string& filesystem_name, | |
| 70 const std::string& filesystem_path, | |
| 71 int render_process_id, | |
| 72 base::FilePath* file_path, | |
| 73 std::string* error); | |
| 74 | |
| 75 } // namespace app_file_handler_util | |
| 76 | |
| 77 } // namespace extensions | |
| 78 | |
| 79 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_ | |
| OLD | NEW |