blob: bce9b0ce2555fa06f115db41bcaa53cc6715670a [file] [log] [blame]
Anand K Mistry110478e2019-10-29 15:24:11 +11001// Copyright 2019 The Chromium OS 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 CROS_DISKS_SMBFS_HELPER_H_
6#define CROS_DISKS_SMBFS_HELPER_H_
7
8#include <memory>
9#include <string>
10#include <vector>
11
Sergei Datsenko44612ac2020-11-30 09:35:56 +110012#include "cros-disks/fuse_mounter.h"
Anand K Mistry110478e2019-10-29 15:24:11 +110013
14namespace cros_disks {
15
16class Platform;
17
18// A helper for mounting SmbFs.
19//
20// SmbFs URIs are of the form:
21// smbfs://mojo_id
22//
23// |mojo_id| is an opaque string, which is the string representation of a
24// base::UnguessableToken created by calling base::UnguessableToken::ToString().
25// It is used to bootstrap a Mojo IPC connection to Chrome.
Sergei Datsenko44612ac2020-11-30 09:35:56 +110026class SmbfsHelper : public FUSEMounterHelper {
Anand K Mistry110478e2019-10-29 15:24:11 +110027 public:
28 SmbfsHelper(const Platform* platform, brillo::ProcessReaper* process_reaper);
Qijiang Fan6bc59e12020-11-11 02:51:06 +090029 SmbfsHelper(const SmbfsHelper&) = delete;
30 SmbfsHelper& operator=(const SmbfsHelper&) = delete;
31
Anand K Mistry110478e2019-10-29 15:24:11 +110032 ~SmbfsHelper() override;
33
Sergei Datsenko44612ac2020-11-30 09:35:56 +110034 bool CanMount(const std::string& source,
35 const std::vector<std::string>& params,
36 base::FilePath* suggested_name) const override;
37
38 protected:
39 MountErrorType ConfigureSandbox(const std::string& source,
40 const base::FilePath& target_path,
41 std::vector<std::string> params,
42 SandboxedProcess* sandbox) const override;
Anand K Mistry110478e2019-10-29 15:24:11 +110043
44 private:
Sergei Datsenko44612ac2020-11-30 09:35:56 +110045 const FUSESandboxedProcessFactory sandbox_factory_;
46
Anand K Mistry110478e2019-10-29 15:24:11 +110047 friend class SmbfsHelperTest;
Anand K Mistry110478e2019-10-29 15:24:11 +110048};
49
50} // namespace cros_disks
51
52#endif // CROS_DISKS_SMBFS_HELPER_H_