OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // chromeos::RemovableDeviceNotificationsCros implementation. | 5 // chromeos::RemovableDeviceNotificationsCros implementation. |
6 | 6 |
7 #include "chrome/browser/storage_monitor/removable_device_notifications_chromeos
.h" | 7 #include "chrome/browser/storage_monitor/removable_device_notifications_chromeos
.h" |
8 | 8 |
| 9 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/storage_monitor/media_device_notifications_utils.h" | 16 #include "chrome/browser/storage_monitor/media_device_notifications_utils.h" |
16 #include "chrome/browser/storage_monitor/media_storage_util.h" | 17 #include "chrome/browser/storage_monitor/media_storage_util.h" |
| 18 #include "chrome/browser/storage_monitor/media_transfer_protocol_device_observer
_linux.h" |
17 #include "chrome/browser/storage_monitor/removable_device_constants.h" | 19 #include "chrome/browser/storage_monitor/removable_device_constants.h" |
| 20 #include "chrome/common/chrome_switches.h" |
18 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
19 | 22 |
20 namespace chromeos { | 23 namespace chromeos { |
21 | 24 |
22 namespace { | 25 namespace { |
23 | 26 |
24 // Constructs a device name using label or manufacturer (vendor and product) | 27 // Constructs a device name using label or manufacturer (vendor and product) |
25 // name details. | 28 // name details. |
26 string16 GetDeviceName(const disks::DiskMountManager::Disk& disk) { | 29 string16 GetDeviceName(const disks::DiskMountManager::Disk& disk) { |
27 if (disk.device_type() == DEVICE_TYPE_SD) { | 30 if (disk.device_type() == DEVICE_TYPE_SD) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 86 } |
84 | 87 |
85 } // namespace | 88 } // namespace |
86 | 89 |
87 using content::BrowserThread; | 90 using content::BrowserThread; |
88 | 91 |
89 RemovableDeviceNotificationsCros::RemovableDeviceNotificationsCros() { | 92 RemovableDeviceNotificationsCros::RemovableDeviceNotificationsCros() { |
90 DCHECK(disks::DiskMountManager::GetInstance()); | 93 DCHECK(disks::DiskMountManager::GetInstance()); |
91 disks::DiskMountManager::GetInstance()->AddObserver(this); | 94 disks::DiskMountManager::GetInstance()->AddObserver(this); |
92 CheckExistingMountPointsOnUIThread(); | 95 CheckExistingMountPointsOnUIThread(); |
| 96 |
| 97 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
| 98 media_transfer_protocol_device_observer_.reset( |
| 99 new chrome::MediaTransferProtocolDeviceObserverLinux()); |
| 100 media_transfer_protocol_device_observer_->SetNotifications(receiver()); |
| 101 } |
93 } | 102 } |
94 | 103 |
95 RemovableDeviceNotificationsCros::~RemovableDeviceNotificationsCros() { | 104 RemovableDeviceNotificationsCros::~RemovableDeviceNotificationsCros() { |
96 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); | 105 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); |
97 if (manager) { | 106 if (manager) { |
98 manager->RemoveObserver(this); | 107 manager->RemoveObserver(this); |
99 } | 108 } |
100 } | 109 } |
101 | 110 |
102 void RemovableDeviceNotificationsCros::CheckExistingMountPointsOnUIThread() { | 111 void RemovableDeviceNotificationsCros::CheckExistingMountPointsOnUIThread() { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 storage_size_in_bytes | 255 storage_size_in_bytes |
247 }; | 256 }; |
248 mount_map_.insert(std::make_pair(mount_info.mount_path, object_info)); | 257 mount_map_.insert(std::make_pair(mount_info.mount_path, object_info)); |
249 receiver()->ProcessAttach( | 258 receiver()->ProcessAttach( |
250 device_id, | 259 device_id, |
251 chrome::GetDisplayNameForDevice(storage_size_in_bytes, device_label), | 260 chrome::GetDisplayNameForDevice(storage_size_in_bytes, device_label), |
252 mount_info.mount_path); | 261 mount_info.mount_path); |
253 } | 262 } |
254 | 263 |
255 } // namespace chromeos | 264 } // namespace chromeos |
OLD | NEW |