Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: chrome/browser/media_galleries/media_file_system_registry.cc

Issue 15988011: Refine StorageMonitor storage device getter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix SystemInfoStorageApiTest failures in browser_tests Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (ContainsKey(extension_hosts_map_, profile)) 459 if (ContainsKey(extension_hosts_map_, profile))
460 return preferences; 460 return preferences;
461 461
462 // Create an empty entry so the initialization code below only gets called 462 // Create an empty entry so the initialization code below only gets called
463 // once per profile. 463 // once per profile.
464 extension_hosts_map_[profile] = ExtensionHostMap(); 464 extension_hosts_map_[profile] = ExtensionHostMap();
465 465
466 // TODO(gbillock): Move this stanza to MediaGalleriesPreferences init code. 466 // TODO(gbillock): Move this stanza to MediaGalleriesPreferences init code.
467 StorageMonitor* monitor = StorageMonitor::GetInstance(); 467 StorageMonitor* monitor = StorageMonitor::GetInstance();
468 DCHECK(monitor->IsInitialized()); 468 DCHECK(monitor->IsInitialized());
469 std::vector<StorageInfo> existing_devices = monitor->GetAttachedStorage(); 469 std::vector<StorageInfo> existing_devices =
470 monitor->GetAllAvailableStorages();
470 for (size_t i = 0; i < existing_devices.size(); i++) { 471 for (size_t i = 0; i < existing_devices.size(); i++) {
471 if (!StorageInfo::IsMediaDevice(existing_devices[i].device_id())) 472 if (!(StorageInfo::IsMediaDevice(existing_devices[i].device_id()) &&
473 StorageInfo::IsRemovableDevice(existing_devices[i].device_id())))
472 continue; 474 continue;
473 if (!existing_devices[i].name().empty()) { 475 if (!existing_devices[i].name().empty()) {
474 preferences->AddGalleryWithName(existing_devices[i].device_id(), 476 preferences->AddGalleryWithName(existing_devices[i].device_id(),
475 existing_devices[i].name(), 477 existing_devices[i].name(),
476 base::FilePath(), 478 base::FilePath(),
477 false /*not user added*/); 479 false /*not user added*/);
478 } else { 480 } else {
479 preferences->AddGallery(existing_devices[i].device_id(), 481 preferences->AddGallery(existing_devices[i].device_id(),
480 base::FilePath(), 482 base::FilePath(),
481 false, 483 false,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 // previously used. 708 // previously used.
707 PrefChangeRegistrarMap::iterator pref_it = 709 PrefChangeRegistrarMap::iterator pref_it =
708 pref_change_registrar_map_.find(profile); 710 pref_change_registrar_map_.find(profile);
709 DCHECK(pref_it != pref_change_registrar_map_.end()); 711 DCHECK(pref_it != pref_change_registrar_map_.end());
710 delete pref_it->second; 712 delete pref_it->second;
711 pref_change_registrar_map_.erase(pref_it); 713 pref_change_registrar_map_.erase(pref_it);
712 } 714 }
713 } 715 }
714 716
715 } // namespace chrome 717 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698