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 |
34 std::vector<const FileHandlerInfo*> | 38 std::vector<const FileHandlerInfo*> |
35 FindFileHandlersForMimeTypes(const Extension& extension, | 39 FindFileHandlers(const Extension& extension, |
benwells
2013/05/07 08:05:17
Nit: please rename to just FileHandlersForFiles an
Sam McNally
2013/05/07 08:25:54
Done.
| |
36 const std::set<std::string>& mime_types); | 40 const PathAndMimeTypeSet& files); |
37 | 41 |
38 bool FileHandlerCanHandleFile( | 42 bool FileHandlerCanHandleFile( |
39 const FileHandlerInfo& handler, | 43 const FileHandlerInfo& handler, |
40 const std::string& mime_type, | 44 const std::string& mime_type, |
41 const base::FilePath& path); | 45 const base::FilePath& path); |
42 bool FileHandlerCanHandleFileWithMimeType( | |
43 const FileHandlerInfo& handler, | |
44 const std::string& mime_type); | |
45 | 46 |
46 // Represents a file entry that a user has given an extension permission to | 47 // 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 | 48 // access. Intended to be persisted to disk (in the Preferences file), so should |
48 // remain serializable. | 49 // remain serializable. |
49 struct SavedFileEntry { | 50 struct SavedFileEntry { |
50 SavedFileEntry(const std::string& id, | 51 SavedFileEntry(const std::string& id, |
51 const base::FilePath& path, | 52 const base::FilePath& path, |
52 bool writable) | 53 bool writable) |
53 : id(id), | 54 : id(id), |
54 path(path), | 55 path(path), |
(...skipping 18 matching lines...) Expand all Loading... | |
73 const std::string& extension_id, | 74 const std::string& extension_id, |
74 int renderer_id, | 75 int renderer_id, |
75 const base::FilePath& path, | 76 const base::FilePath& path, |
76 bool writable); | 77 bool writable); |
77 | 78 |
78 } // namespace app_file_handler_util | 79 } // namespace app_file_handler_util |
79 | 80 |
80 } // namespace extensions | 81 } // namespace extensions |
81 | 82 |
82 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_ | 83 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_ |
OLD | NEW |