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_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 namespace fileapi { | 25 namespace fileapi { |
26 class FileSystemURL; | 26 class FileSystemURL; |
27 } | 27 } |
28 | 28 |
29 namespace file_handler_util { | 29 namespace file_handler_util { |
30 | 30 |
31 // Specifies the task type for a task id that represents some file action, Drive | 31 // Specifies the task type for a task id that represents some file action, Drive |
32 // action, or Web Intent action. | 32 // action, or Web Intent action. |
33 extern const char kTaskFile[]; | 33 extern const char kTaskFile[]; |
34 extern const char kTaskDrive[]; | 34 extern const char kTaskDrive[]; |
35 extern const char kTaskWebIntent[]; | |
36 extern const char kTaskApp[]; | 35 extern const char kTaskApp[]; |
37 | 36 |
38 void UpdateFileHandlerUsageStats(Profile* profile, const std::string& task_id); | 37 void UpdateFileHandlerUsageStats(Profile* profile, const std::string& task_id); |
39 | 38 |
40 // Update the default file handler for the given sets of suffixes and MIME | 39 // Update the default file handler for the given sets of suffixes and MIME |
41 // types. | 40 // types. |
42 void UpdateDefaultTask(Profile* profile, | 41 void UpdateDefaultTask(Profile* profile, |
43 const std::string& task_id, | 42 const std::string& task_id, |
44 const std::set<std::string>& suffixes, | 43 const std::set<std::string>& suffixes, |
45 const std::set<std::string>& mime_types); | 44 const std::set<std::string>& mime_types); |
46 | 45 |
47 // Returns the task ID of the default task for the given |mime_type|/|suffix| | 46 // Returns the task ID of the default task for the given |mime_type|/|suffix| |
48 // combination. If it finds a MIME type match, then it prefers that over a | 47 // combination. If it finds a MIME type match, then it prefers that over a |
49 // suffix match. If it a default can't be found, then it returns the empty | 48 // suffix match. If it a default can't be found, then it returns the empty |
50 // string. | 49 // string. |
51 std::string GetDefaultTaskIdFromPrefs(Profile* profile, | 50 std::string GetDefaultTaskIdFromPrefs(Profile* profile, |
52 const std::string& mime_type, | 51 const std::string& mime_type, |
53 const std::string& suffix); | 52 const std::string& suffix); |
54 | 53 |
55 // Gets read-write file access permission flags. | 54 // Gets read-write file access permission flags. |
56 int GetReadWritePermissions(); | 55 int GetReadWritePermissions(); |
57 // Gets read-only file access permission flags. | 56 // Gets read-only file access permission flags. |
58 int GetReadOnlyPermissions(); | 57 int GetReadOnlyPermissions(); |
59 | 58 |
60 // Generates task id for the action specified by the extension. The |task_type| | 59 // Generates task id for the action specified by the extension. The |task_type| |
61 // must be one of kTaskFile, kTaskDrive, or kTaskWebIntent. | 60 // must be one of kTaskFile, kTaskDrive or kTaskApp. |
62 std::string MakeTaskID(const std::string& extension_id, | 61 std::string MakeTaskID(const std::string& extension_id, |
63 const std::string& task_type, | 62 const std::string& task_type, |
64 const std::string& action_id); | 63 const std::string& action_id); |
65 | 64 |
66 // Extracts action, type and extension id bound to the file task. Either | 65 // Extracts action, type and extension id bound to the file task. Either |
67 // |target_extension_id| or |action_id| are allowed to be NULL if caller isn't | 66 // |target_extension_id| or |action_id| are allowed to be NULL if caller isn't |
68 // interested in those values. Returns false on failure to parse. | 67 // interested in those values. Returns false on failure to parse. |
69 bool CrackTaskID(const std::string& task_id, | 68 bool CrackTaskID(const std::string& task_id, |
70 std::string* target_extension_id, | 69 std::string* target_extension_id, |
71 std::string* task_type, | 70 std::string* task_type, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 148 |
150 Profile* profile_; | 149 Profile* profile_; |
151 const GURL source_url_; | 150 const GURL source_url_; |
152 const std::string file_browser_id_; | 151 const std::string file_browser_id_; |
153 const std::string extension_id_; | 152 const std::string extension_id_; |
154 }; | 153 }; |
155 | 154 |
156 } // namespace file_handler_util | 155 } // namespace file_handler_util |
157 | 156 |
158 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ | 157 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ |
OLD | NEW |