| 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 // MediaFileSystemRegistry implementation. | 5 // MediaFileSystemRegistry implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/media_gallery/media_file_system_registry.h" | 7 #include "chrome/browser/media_gallery/media_file_system_registry.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 PrefIdFsInfoMap::const_iterator existing_info = pref_id_map_.find(*id); | 104 PrefIdFsInfoMap::const_iterator existing_info = pref_id_map_.find(*id); |
| 105 if (existing_info != pref_id_map_.end()) { | 105 if (existing_info != pref_id_map_.end()) { |
| 106 result.push_back(existing_info->second); | 106 result.push_back(existing_info->second); |
| 107 continue; | 107 continue; |
| 108 } | 108 } |
| 109 const MediaGalleryPrefInfo& gallery_info = | 109 const MediaGalleryPrefInfo& gallery_info = |
| 110 galleries_info.find(*id)->second; | 110 galleries_info.find(*id)->second; |
| 111 const std::string& device_id = gallery_info.device_id; | 111 const std::string& device_id = gallery_info.device_id; |
| 112 // TODO(kmadhusu) handle MTP devices. | 112 // TODO(kmadhusu) handle MTP devices. |
| 113 DCHECK(MediaStorageUtil::IsMassStorageDevice(device_id)); | 113 DCHECK(MediaStorageUtil::IsMassStorageDevice(device_id)); |
| 114 FilePath path = MediaStorageUtil::FindDevicePathById(device_id); | 114 FilePath path = gallery_info.AbsolutePath(); |
| 115 // TODO(vandebo) we also need to check that these galleries are attached. | 115 // TODO(vandebo) we also need to check that these galleries are attached. |
| 116 // For now, just skip over entries that we couldn't find. | 116 // For now, just skip over entries that we couldn't find. |
| 117 if (path.empty()) | 117 if (!path.IsAbsolute()) |
| 118 continue; | 118 continue; |
| 119 CHECK(!path.empty()); | |
| 120 path = path.Append(gallery_info.path); | |
| 121 | 119 |
| 122 MediaFileSystemRegistry::MediaFSInfo new_entry; | 120 MediaFileSystemRegistry::MediaFSInfo new_entry; |
| 123 new_entry.name = gallery_info.display_name; | 121 new_entry.name = gallery_info.display_name; |
| 124 new_entry.path = path; | 122 new_entry.path = path; |
| 125 new_entry.fsid = RegisterFileSystem(device_id, path); | 123 new_entry.fsid = RegisterFileSystem(device_id, path); |
| 126 result.push_back(new_entry); | 124 result.push_back(new_entry); |
| 127 pref_id_map_[*id] = new_entry; | 125 pref_id_map_[*id] = new_entry; |
| 128 } | 126 } |
| 129 | 127 |
| 130 // TODO(vandebo) We need a way of getting notification when permission for | 128 // TODO(vandebo) We need a way of getting notification when permission for |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 extension_hosts_map_.find(profile); | 411 extension_hosts_map_.find(profile); |
| 414 DCHECK(extension_hosts != extension_hosts_map_.end()); | 412 DCHECK(extension_hosts != extension_hosts_map_.end()); |
| 415 ExtensionHostMap::size_type erase_count = | 413 ExtensionHostMap::size_type erase_count = |
| 416 extension_hosts->second.erase(extension_id); | 414 extension_hosts->second.erase(extension_id); |
| 417 DCHECK_EQ(1U, erase_count); | 415 DCHECK_EQ(1U, erase_count); |
| 418 if (extension_hosts->second.empty()) | 416 if (extension_hosts->second.empty()) |
| 419 extension_hosts_map_.erase(extension_hosts); | 417 extension_hosts_map_.erase(extension_hosts); |
| 420 } | 418 } |
| 421 | 419 |
| 422 } // namespace chrome | 420 } // namespace chrome |
| OLD | NEW |