BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / chromeos / file_manager / fake_disk_mount_manager.cc
blob5c82c983e5854d794f981d53af6786d94f8b7d82
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.
5 #include "chrome/browser/chromeos/file_manager/fake_disk_mount_manager.h"
7 #include "base/callback.h"
8 #include "base/stl_util.h"
10 namespace file_manager {
12 FakeDiskMountManager::MountRequest::MountRequest(
13 const std::string& source_path,
14 const std::string& source_format,
15 const std::string& mount_label,
16 chromeos::MountType type)
17 : source_path(source_path),
18 source_format(source_format),
19 mount_label(mount_label),
20 type(type) {
23 FakeDiskMountManager::UnmountRequest::UnmountRequest(
24 const std::string& mount_path,
25 chromeos::UnmountOptions options)
26 : mount_path(mount_path),
27 options(options) {
30 FakeDiskMountManager::FakeDiskMountManager() {
33 FakeDiskMountManager::~FakeDiskMountManager() {
34 STLDeleteValues(&disks_);
37 void FakeDiskMountManager::AddObserver(Observer* observer) {
38 DCHECK(observer);
39 observers_.AddObserver(observer);
42 void FakeDiskMountManager::RemoveObserver(Observer* observer) {
43 DCHECK(observer);
44 observers_.RemoveObserver(observer);
47 const chromeos::disks::DiskMountManager::DiskMap&
48 FakeDiskMountManager::disks() const {
49 return disks_;
52 const chromeos::disks::DiskMountManager::Disk*
53 FakeDiskMountManager::FindDiskBySourcePath(
54 const std::string& source_path) const {
55 DiskMap::const_iterator iter = disks_.find(source_path);
56 if (iter == disks_.end())
57 return NULL;
58 return iter->second;
61 const chromeos::disks::DiskMountManager::MountPointMap&
62 FakeDiskMountManager::mount_points() const {
63 return mount_points_;
66 void FakeDiskMountManager::EnsureMountInfoRefreshed(
67 const EnsureMountInfoRefreshedCallback& callback,
68 bool force) {
69 callback.Run(true);
72 void FakeDiskMountManager::MountPath(const std::string& source_path,
73 const std::string& source_format,
74 const std::string& mount_label,
75 chromeos::MountType type) {
76 mount_requests_.push_back(
77 MountRequest(source_path, source_format, mount_label, type));
79 const MountPointInfo mount_point(
80 source_path,
81 source_path,
82 type,
83 chromeos::disks::MOUNT_CONDITION_NONE);
84 mount_points_.insert(make_pair(source_path, mount_point));
85 FOR_EACH_OBSERVER(DiskMountManager::Observer, observers_,
86 OnMountEvent(DiskMountManager::MOUNTING,
87 chromeos::MOUNT_ERROR_NONE,
88 mount_point));
91 void FakeDiskMountManager::UnmountPath(const std::string& mount_path,
92 chromeos::UnmountOptions options,
93 const UnmountPathCallback& callback) {
94 unmount_requests_.push_back(UnmountRequest(mount_path, options));
96 MountPointMap::iterator iter = mount_points_.find(mount_path);
97 if (iter == mount_points_.end())
98 return;
99 const MountPointInfo mount_point = iter->second;
100 mount_points_.erase(iter);
101 FOR_EACH_OBSERVER(DiskMountManager::Observer, observers_,
102 OnMountEvent(DiskMountManager::UNMOUNTING,
103 chromeos::MOUNT_ERROR_NONE,
104 mount_point));
105 // Currently |callback| is just ignored.
108 void FakeDiskMountManager::FormatMountedDevice(const std::string& mount_path) {
111 void FakeDiskMountManager::UnmountDeviceRecursively(
112 const std::string& device_path,
113 const UnmountDeviceRecursivelyCallbackType& callback) {
116 bool FakeDiskMountManager::AddDiskForTest(Disk* disk) {
117 DCHECK(disk);
118 return disks_.insert(make_pair(disk->device_path(), disk)).second;
121 bool FakeDiskMountManager::AddMountPointForTest(
122 const MountPointInfo& mount_point) {
123 return false;
126 void FakeDiskMountManager::InvokeDiskEventForTest(
127 chromeos::disks::DiskMountManager::DiskEvent event,
128 const chromeos::disks::DiskMountManager::Disk* disk) {
129 FOR_EACH_OBSERVER(chromeos::disks::DiskMountManager::Observer,
130 observers_,
131 OnDiskEvent(event, disk));
134 } // namespace file_manager