Daichi Hirono | 0cf590f8 | 2017-08-21 01:37:06 | [diff] [blame] | 1 | // Copyright 2017 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 | #ifndef COMPONENTS_EXO_FILE_HELPER_H_ |
| 6 | #define COMPONENTS_EXO_FILE_HELPER_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | class GURL; |
| 11 | |
| 12 | namespace base { |
| 13 | class FilePath; |
| 14 | } |
| 15 | |
| 16 | namespace exo { |
| 17 | |
| 18 | class FileHelper { |
| 19 | public: |
| 20 | virtual ~FileHelper() {} |
| 21 | |
| 22 | // Returns mime type which is used for list of Uris returned by this |
| 23 | // FileHelper. |
| 24 | virtual std::string GetMimeTypeForUriList() const = 0; |
| 25 | |
Daichi Hirono | f3f855c0 | 2018-01-16 01:50:16 | [diff] [blame] | 26 | // Converts native file path to URL which can be used by application with |
| 27 | // |app_id|. We don't expose enter file system to a container directly. |
| 28 | // Instead we mount specific directory in the containers' namespace. Thus we |
| 29 | // need to convert native path to file URL which points mount point in |
| 30 | // containers. The conversion should be container specific, now we only have |
| 31 | // ARC container though. |
| 32 | virtual bool GetUrlFromPath(const std::string& app_id, |
| 33 | const base::FilePath& path, |
| 34 | GURL* out) = 0; |
| 35 | |
Satoshi Niwa | e40eeeb | 2018-02-19 10:36:10 | [diff] [blame] | 36 | // Takes in |pickle| constructed by the web contents view and returns true if |
| 37 | // it contains any valid filesystem URLs. |
| 38 | virtual bool HasUrlsInPickle(const base::Pickle& pickle) = 0; |
| 39 | |
| 40 | using UrlsFromPickleCallback = |
| 41 | base::OnceCallback<void(const std::vector<GURL>& urls)>; |
| 42 | |
Satoshi Niwa | 22ac0e63 | 2018-01-30 04:41:03 | [diff] [blame] | 43 | // Takes in |pickle| constructed by the web contents view, reads filesystem |
| 44 | // URLs from it and converts the URLs to something that applications can |
| 45 | // understand. e.g. content:// URI for Android apps. |
Satoshi Niwa | e40eeeb | 2018-02-19 10:36:10 | [diff] [blame] | 46 | virtual void GetUrlsFromPickle(const std::string& app_id, |
Satoshi Niwa | 22ac0e63 | 2018-01-30 04:41:03 | [diff] [blame] | 47 | const base::Pickle& pickle, |
Satoshi Niwa | e40eeeb | 2018-02-19 10:36:10 | [diff] [blame] | 48 | UrlsFromPickleCallback callback) = 0; |
Daichi Hirono | 0cf590f8 | 2017-08-21 01:37:06 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | } // namespace exo |
| 52 | |
| 53 | #endif // COMPONENTS_EXO_FILE_HELPER_H_ |