blob: af51cf38d9ece8b953d9c8f8de0b414e304aee98 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// 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_ARC_VOLUME_MOUNTER_ARC_VOLUME_MOUNTER_BRIDGE_H_
#define COMPONENTS_ARC_VOLUME_MOUNTER_ARC_VOLUME_MOUNTER_BRIDGE_H_
#include <string>
#include "base/macros.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "components/arc/common/volume_mounter.mojom.h"
#include "components/arc/connection_observer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace content {
class BrowserContext;
} // namespace content
namespace arc {
class ArcBridgeService;
// This class handles Volume mount/unmount requests from cros-disks and
// send them to Android.
class ArcVolumeMounterBridge
: public KeyedService,
public chromeos::disks::DiskMountManager::Observer,
public ConnectionObserver<mojom::VolumeMounterInstance> {
public:
// Returns singleton instance for the given BrowserContext,
// or nullptr if the browser |context| is not allowed to use ARC.
static ArcVolumeMounterBridge* GetForBrowserContext(
content::BrowserContext* context);
ArcVolumeMounterBridge(content::BrowserContext* context,
ArcBridgeService* bridge_service);
~ArcVolumeMounterBridge() override;
// ConnectionObserver<mojom::VolumeMounterInstance> overrides:
void OnConnectionReady() override;
// chromeos::disks::DiskMountManager::Observer overrides:
void OnDiskEvent(
chromeos::disks::DiskMountManager::DiskEvent event,
const chromeos::disks::DiskMountManager::Disk* disk) override;
void OnDeviceEvent(chromeos::disks::DiskMountManager::DeviceEvent event,
const std::string& device_path) override;
void OnMountEvent(chromeos::disks::DiskMountManager::MountEvent event,
chromeos::MountError error_code,
const chromeos::disks::DiskMountManager::MountPointInfo&
mount_info) override;
void OnFormatEvent(chromeos::disks::DiskMountManager::FormatEvent event,
chromeos::FormatError error_code,
const std::string& device_path) override;
void OnRenameEvent(chromeos::disks::DiskMountManager::RenameEvent event,
chromeos::RenameError error_code,
const std::string& device_path) override;
private:
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.
DISALLOW_COPY_AND_ASSIGN(ArcVolumeMounterBridge);
};
} // namespace arc
#endif // COMPONENTS_ARC_VOLUME_MOUNTER_ARC_VOLUME_MOUNTER_BRIDGE_H_
|