| 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 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h" | 5 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h" |
| 6 | 6 |
| 7 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" | 7 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 | 9 |
| 10 namespace chrome { | 10 namespace chrome { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (info.bsd_name().empty()) | 83 if (info.bsd_name().empty()) |
| 84 return; | 84 return; |
| 85 | 85 |
| 86 std::map<std::string, DiskInfoMac>::iterator it = | 86 std::map<std::string, DiskInfoMac>::iterator it = |
| 87 disk_info_map_.find(info.bsd_name()); | 87 disk_info_map_.find(info.bsd_name()); |
| 88 if (it != disk_info_map_.end()) { | 88 if (it != disk_info_map_.end()) { |
| 89 // If an attached notification was previously posted then post a detached | 89 // If an attached notification was previously posted then post a detached |
| 90 // notification now. This is used for devices that are being removed or | 90 // notification now. This is used for devices that are being removed or |
| 91 // devices that have changed. | 91 // devices that have changed. |
| 92 if (ShouldPostNotificationForDisk(it->second)) { | 92 if (ShouldPostNotificationForDisk(it->second)) { |
| 93 ProcessDetach(it->second.device_id()); | 93 receiver()->ProcessDetach(it->second.device_id()); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 if (update_type == UPDATE_DEVICE_REMOVED) { | 97 if (update_type == UPDATE_DEVICE_REMOVED) { |
| 98 if (it != disk_info_map_.end()) | 98 if (it != disk_info_map_.end()) |
| 99 disk_info_map_.erase(it); | 99 disk_info_map_.erase(it); |
| 100 } else { | 100 } else { |
| 101 disk_info_map_[info.bsd_name()] = info; | 101 disk_info_map_[info.bsd_name()] = info; |
| 102 MediaStorageUtil::RecordDeviceInfoHistogram(true, info.device_id(), | 102 MediaStorageUtil::RecordDeviceInfoHistogram(true, info.device_id(), |
| 103 info.device_name()); | 103 info.device_name()); |
| 104 if (ShouldPostNotificationForDisk(info)) { | 104 if (ShouldPostNotificationForDisk(info)) { |
| 105 string16 display_name = GetDisplayNameForDevice( | 105 string16 display_name = GetDisplayNameForDevice( |
| 106 info.total_size_in_bytes(), info.device_name()); | 106 info.total_size_in_bytes(), info.device_name()); |
| 107 ProcessAttach(info.device_id(), display_name, info.mount_point().value()); | 107 receiver()->ProcessAttach( |
| 108 info.device_id(), display_name, info.mount_point().value()); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 | 112 |
| 112 bool RemovableDeviceNotificationsMac::GetDeviceInfoForPath( | 113 bool RemovableDeviceNotificationsMac::GetDeviceInfoForPath( |
| 113 const base::FilePath& path, | 114 const base::FilePath& path, |
| 114 StorageInfo* device_info) const { | 115 StorageInfo* device_info) const { |
| 115 if (!path.IsAbsolute()) | 116 if (!path.IsAbsolute()) |
| 116 return false; | 117 return false; |
| 117 | 118 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) { | 194 it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) { |
| 194 if (it->second.mount_point() == mount_point) { | 195 if (it->second.mount_point() == mount_point) { |
| 195 *info = it->second; | 196 *info = it->second; |
| 196 return true; | 197 return true; |
| 197 } | 198 } |
| 198 } | 199 } |
| 199 return false; | 200 return false; |
| 200 } | 201 } |
| 201 | 202 |
| 202 } // namespace chrome | 203 } // namespace chrome |
| OLD | NEW |