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