summaryrefslogtreecommitdiff
path: root/chromium/components/exo/file_helper.h
blob: 80c746badeaec30030ec6887b13b0e0f2f1e6508 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_EXO_FILE_HELPER_H_
#define COMPONENTS_EXO_FILE_HELPER_H_

#include <string>

class GURL;

namespace base {
class FilePath;
}

namespace exo {

class FileHelper {
 public:
  virtual ~FileHelper() {}

  // Returns mime type which is used for list of Uris returned by this
  // FileHelper.
  virtual std::string GetMimeTypeForUriList() const = 0;

  // Converts native file path to URL which can be used by application with
  // |app_id|.  We don't expose enter file system to a container directly.
  // Instead we mount specific directory in the containers' namespace.  Thus we
  // need to convert native path to file URL which points mount point in
  // containers.  The conversion should be container specific, now we only have
  // ARC container though.
  virtual bool GetUrlFromPath(const std::string& app_id,
                              const base::FilePath& path,
                              GURL* out) = 0;

  // Takes in |pickle| constructed by the web contents view and returns true if
  // it contains any valid filesystem URLs.
  virtual bool HasUrlsInPickle(const base::Pickle& pickle) = 0;

  using UrlsFromPickleCallback =
      base::OnceCallback<void(const std::vector<GURL>& urls)>;

  // Takes in |pickle| constructed by the web contents view, reads filesystem
  // URLs from it and converts the URLs to something that applications can
  // understand.  e.g. content:// URI for Android apps.
  virtual void GetUrlsFromPickle(const std::string& app_id,
                                 const base::Pickle& pickle,
                                 UrlsFromPickleCallback callback) = 0;
};

}  // namespace exo

#endif  // COMPONENTS_EXO_FILE_HELPER_H_