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_galleries/media_file_system_registry.h" | 7 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 Profile* profile) { | 461 Profile* profile) { |
462 MediaGalleriesPreferences* preferences = | 462 MediaGalleriesPreferences* preferences = |
463 MediaGalleriesPreferencesFactory::GetForProfile(profile); | 463 MediaGalleriesPreferencesFactory::GetForProfile(profile); |
464 if (ContainsKey(extension_hosts_map_, profile)) | 464 if (ContainsKey(extension_hosts_map_, profile)) |
465 return preferences; | 465 return preferences; |
466 | 466 |
467 // Create an empty entry so the initialization code below only gets called | 467 // Create an empty entry so the initialization code below only gets called |
468 // once per profile. | 468 // once per profile. |
469 extension_hosts_map_[profile] = ExtensionHostMap(); | 469 extension_hosts_map_[profile] = ExtensionHostMap(); |
470 | 470 |
471 // TODO(gbillock): Move this stanza to MediaGalleriesPreferences init code. | |
vandebo (ex-Chrome)
2013/05/31 18:05:03
I think we still want to do this, leave in todo?
Greg Billock
2013/06/01 01:48:46
Yeah, I think this was impossible with the getting
| |
472 // StorageMonitor may be NULL in unit tests. | 471 // StorageMonitor may be NULL in unit tests. |
472 // TODO(gbillock): Make sure all tests have a storage monitor and remove this. | |
473 StorageMonitor* monitor = StorageMonitor::GetInstance(); | 473 StorageMonitor* monitor = StorageMonitor::GetInstance(); |
474 if (!monitor) | 474 if (!monitor) |
475 return preferences; | 475 return preferences; |
476 DCHECK(monitor->IsInitialized()); | |
476 std::vector<StorageInfo> existing_devices = monitor->GetAttachedStorage(); | 477 std::vector<StorageInfo> existing_devices = monitor->GetAttachedStorage(); |
477 for (size_t i = 0; i < existing_devices.size(); i++) { | 478 for (size_t i = 0; i < existing_devices.size(); i++) { |
478 if (!StorageInfo::IsMediaDevice(existing_devices[i].device_id())) | 479 if (!StorageInfo::IsMediaDevice(existing_devices[i].device_id())) |
479 continue; | 480 continue; |
480 if (!existing_devices[i].name().empty()) { | 481 if (!existing_devices[i].name().empty()) { |
481 preferences->AddGalleryWithName(existing_devices[i].device_id(), | 482 preferences->AddGalleryWithName(existing_devices[i].device_id(), |
482 existing_devices[i].name(), | 483 existing_devices[i].name(), |
483 base::FilePath(), | 484 base::FilePath(), |
484 false /*not user added*/); | 485 false /*not user added*/); |
485 } else { | 486 } else { |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
730 // previously used. | 731 // previously used. |
731 PrefChangeRegistrarMap::iterator pref_it = | 732 PrefChangeRegistrarMap::iterator pref_it = |
732 pref_change_registrar_map_.find(profile); | 733 pref_change_registrar_map_.find(profile); |
733 DCHECK(pref_it != pref_change_registrar_map_.end()); | 734 DCHECK(pref_it != pref_change_registrar_map_.end()); |
734 delete pref_it->second; | 735 delete pref_it->second; |
735 pref_change_registrar_map_.erase(pref_it); | 736 pref_change_registrar_map_.erase(pref_it); |
736 } | 737 } |
737 } | 738 } |
738 | 739 |
739 } // namespace chrome | 740 } // namespace chrome |
OLD | NEW |