Home | History | Annotate | Download | only in file_manager
      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_FILE_MANAGER_FILE_BROWSER_HANDLERS_H_
      9 #define CHROME_BROWSER_CHROMEOS_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/file_manager/file_tasks.h"
     17 
     18 class FileBrowserHandler;
     19 class GURL;
     20 class Profile;
     21 
     22 namespace base {
     23 class FilePath;
     24 }
     25 
     26 namespace extensions {
     27 class Extension;
     28 }
     29 
     30 namespace fileapi {
     31 class FileSystemURL;
     32 }
     33 
     34 namespace file_manager {
     35 namespace file_browser_handlers {
     36 
     37 // Tasks are stored as a vector in order of priorities.
     38 typedef std::vector<const FileBrowserHandler*> FileBrowserHandlerList;
     39 
     40 // Returns true if the given task is a fallback file browser handler. Such
     41 // handlers are Files.app's internal handlers as well as quick office
     42 // extensions.
     43 bool IsFallbackFileBrowserHandler(const file_tasks::TaskDescriptor& task);
     44 
     45 // Returns the list of file browser handlers that can open all files in
     46 // |file_list|.
     47 FileBrowserHandlerList FindFileBrowserHandlers(
     48     Profile* profile,
     49     const std::vector<GURL>& file_list);
     50 
     51 // Executes a file browser handler specified by |extension| of the given
     52 // action ID for |file_urls|. Returns false if undeclared handlers are
     53 // found. |done| is on completion. See also the comment at ExecuteFileTask()
     54 // for other parameters.
     55 bool ExecuteFileBrowserHandler(
     56     Profile* profile,
     57     const extensions::Extension* extension,
     58     const std::string& action_id,
     59     const std::vector<fileapi::FileSystemURL>& file_urls,
     60     const file_tasks::FileTaskFinishedCallback& done);
     61 
     62 }  // namespace file_browser_handlers
     63 }  // namespace file_manager
     64 
     65 #endif  // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_BROWSER_HANDLERS_H_
     66