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 #ifndef CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_ | 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_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
| 10 #include <utility> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "chrome/common/extensions/api/file_handlers/file_handlers_parser.h" | 13 #include "chrome/common/extensions/api/file_handlers/file_handlers_parser.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 | 15 |
15 class Profile; | 16 class Profile; |
16 | 17 |
17 namespace extensions { | 18 namespace extensions { |
18 | 19 |
19 // TODO(benwells): move this to platform_apps namespace. | 20 // TODO(benwells): move this to platform_apps namespace. |
20 namespace app_file_handler_util { | 21 namespace app_file_handler_util { |
21 | 22 |
| 23 // A set of pairs of path and its corresponding MIME type. |
| 24 typedef std::set<std::pair<base::FilePath, std::string> > PathAndMimeTypeSet; |
| 25 |
22 // Returns the file handler with the specified |handler_id|, or NULL if there | 26 // Returns the file handler with the specified |handler_id|, or NULL if there |
23 // is no such handler. | 27 // is no such handler. |
24 const FileHandlerInfo* FileHandlerForId(const Extension& app, | 28 const FileHandlerInfo* FileHandlerForId(const Extension& app, |
25 const std::string& handler_id); | 29 const std::string& handler_id); |
26 | 30 |
27 // Returns the first file handler that can handle the given MIME type or | 31 // Returns the first file handler that can handle the given MIME type or |
28 // filename, or NULL if is no such handler. | 32 // filename, or NULL if is no such handler. |
29 const FileHandlerInfo* FirstFileHandlerForFile( | 33 const FileHandlerInfo* FirstFileHandlerForFile( |
30 const Extension& app, | 34 const Extension& app, |
31 const std::string& mime_type, | 35 const std::string& mime_type, |
32 const base::FilePath& path); | 36 const base::FilePath& path); |
33 | 37 |
| 38 // Returns the handlers that can handle all files in |files|. The paths in |
| 39 // |files| must be populated, but the MIME types are optional. |
34 std::vector<const FileHandlerInfo*> | 40 std::vector<const FileHandlerInfo*> |
35 FindFileHandlersForMimeTypes(const Extension& extension, | 41 FindFileHandlersForFiles(const Extension& extension, |
36 const std::set<std::string>& mime_types); | 42 const PathAndMimeTypeSet& files); |
37 | 43 |
38 bool FileHandlerCanHandleFile( | 44 bool FileHandlerCanHandleFile( |
39 const FileHandlerInfo& handler, | 45 const FileHandlerInfo& handler, |
40 const std::string& mime_type, | 46 const std::string& mime_type, |
41 const base::FilePath& path); | 47 const base::FilePath& path); |
42 bool FileHandlerCanHandleFileWithMimeType( | |
43 const FileHandlerInfo& handler, | |
44 const std::string& mime_type); | |
45 | 48 |
46 // Represents a file entry that a user has given an extension permission to | 49 // Represents a file entry that a user has given an extension permission to |
47 // access. Intended to be persisted to disk (in the Preferences file), so should | 50 // access. Intended to be persisted to disk (in the Preferences file), so should |
48 // remain serializable. | 51 // remain serializable. |
49 struct SavedFileEntry { | 52 struct SavedFileEntry { |
50 SavedFileEntry(const std::string& id, | 53 SavedFileEntry(const std::string& id, |
51 const base::FilePath& path, | 54 const base::FilePath& path, |
52 bool writable) | 55 bool writable) |
53 : id(id), | 56 : id(id), |
54 path(path), | 57 path(path), |
(...skipping 18 matching lines...) Expand all Loading... |
73 const std::string& extension_id, | 76 const std::string& extension_id, |
74 int renderer_id, | 77 int renderer_id, |
75 const base::FilePath& path, | 78 const base::FilePath& path, |
76 bool writable); | 79 bool writable); |
77 | 80 |
78 } // namespace app_file_handler_util | 81 } // namespace app_file_handler_util |
79 | 82 |
80 } // namespace extensions | 83 } // namespace extensions |
81 | 84 |
82 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_ | 85 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_ |
OLD | NEW |