OLD | NEW |
| (Empty) |
1 // Copyright 2013 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 // This file provides utility functions for file browser handlers. | |
6 // https://developer.chrome.com/extensions/fileBrowserHandler.html | |
7 | |
8 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_BROWSER_HANDLERS_H_ | |
9 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_BROWSER_HANDLERS_H_ | |
10 | |
11 #include <string> | |
12 #include <vector> | |
13 | |
14 #include "base/basictypes.h" | |
15 #include "base/callback_forward.h" | |
16 #include "chrome/browser/chromeos/extensions/file_manager/file_tasks.h" | |
17 | |
18 class FileBrowserHandler; | |
19 class GURL; | |
20 class PrefService; | |
21 class Profile; | |
22 | |
23 namespace base { | |
24 class FilePath; | |
25 } | |
26 | |
27 namespace extensions { | |
28 class Extension; | |
29 } | |
30 | |
31 namespace fileapi { | |
32 class FileSystemURL; | |
33 } | |
34 | |
35 namespace file_manager { | |
36 namespace file_browser_handlers { | |
37 | |
38 // Tasks are stored as a vector in order of priorities. | |
39 typedef std::vector<const FileBrowserHandler*> FileBrowserHandlerList; | |
40 | |
41 // Returns true if the given task is a fallback file browser handler. Such | |
42 // handlers are Files.app's internal handlers as well as quick office | |
43 // extensions. | |
44 bool IsFallbackFileBrowserHandler(const file_tasks::TaskDescriptor& task); | |
45 | |
46 // Finds file browser handlers set as default from |common_tasks| for | |
47 // |file_list|. If no handlers are set as default, choose the the firstly | |
48 // found fallback handler as default. | |
49 FileBrowserHandlerList FindDefaultFileBrowserHandlers( | |
50 const PrefService& pref_service, | |
51 const std::vector<base::FilePath>& file_list, | |
52 const FileBrowserHandlerList& common_tasks); | |
53 | |
54 // Returns the list of file browser handlers that can open all files in | |
55 // |file_list|. | |
56 FileBrowserHandlerList FindCommonFileBrowserHandlers( | |
57 Profile* profile, | |
58 const std::vector<GURL>& file_list); | |
59 | |
60 // Finds a file browser handler for a file whose URL is |url| and whose path | |
61 // is |path|. Returns the default handler if one is defined (The default | |
62 // handler is the one that is assigned to the file manager task button by | |
63 // default). If the default handler is not found, tries to match the url with | |
64 // one of the file browser handlers. | |
65 const FileBrowserHandler* FindFileBrowserHandlerForURLAndPath( | |
66 Profile* profile, | |
67 const GURL& url, | |
68 const base::FilePath& path); | |
69 | |
70 // Executes a file browser handler specified by |extension| of the given | |
71 // action ID for |file_urls|. Returns false if undeclared handlers are | |
72 // found. |done| is on completion. See also the comment at ExecuteFileTask() | |
73 // for other parameters. | |
74 bool ExecuteFileBrowserHandler( | |
75 Profile* profile, | |
76 const extensions::Extension* extension, | |
77 int32 tab_id, | |
78 const std::string& action_id, | |
79 const std::vector<fileapi::FileSystemURL>& file_urls, | |
80 const file_tasks::FileTaskFinishedCallback& done); | |
81 | |
82 } // namespace file_browser_handlers | |
83 } // namespace file_manager | |
84 | |
85 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_BROWSER_HANDLERS
_H_ | |
OLD | NEW |