Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" | |
| 19 #include "chrome/browser/media_galleries/media_file_system_context.h" | 20 #include "chrome/browser/media_galleries/media_file_system_context.h" |
| 20 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" | 21 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" |
| 21 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" | 22 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" |
| 22 #include "chrome/browser/media_galleries/scoped_mtp_device_map_entry.h" | 23 #include "chrome/browser/media_galleries/scoped_mtp_device_map_entry.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/storage_monitor/media_storage_util.h" | 25 #include "chrome/browser/storage_monitor/media_storage_util.h" |
| 25 #include "chrome/browser/storage_monitor/storage_monitor.h" | 26 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/extensions/extension.h" | 29 #include "chrome/common/extensions/extension.h" |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 // specified by |device_id| and |path|. | 570 // specified by |device_id| and |path|. |
| 570 virtual std::string RegisterFileSystemForMassStorage( | 571 virtual std::string RegisterFileSystemForMassStorage( |
| 571 const std::string& device_id, const base::FilePath& path) OVERRIDE { | 572 const std::string& device_id, const base::FilePath& path) OVERRIDE { |
| 572 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 573 DCHECK(StorageInfo::IsMassStorageDevice(device_id)); | 574 DCHECK(StorageInfo::IsMassStorageDevice(device_id)); |
| 574 | 575 |
| 575 // Sanity checks for |path|. | 576 // Sanity checks for |path|. |
| 576 CHECK(path.IsAbsolute()); | 577 CHECK(path.IsAbsolute()); |
| 577 CHECK(!path.ReferencesParent()); | 578 CHECK(!path.ReferencesParent()); |
| 578 std::string fs_name(extension_misc::kMediaFileSystemPathPart); | 579 std::string fs_name(extension_misc::kMediaFileSystemPathPart); |
| 579 const std::string fsid = | 580 |
| 580 IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 581 StorageInfo::Type type; |
| 582 CHECK(StorageInfo::CrackDeviceId(device_id, &type, NULL)); | |
|
vandebo (ex-Chrome)
2013/05/22 18:21:48
We should probably leave this abstraction intact.
| |
| 583 | |
| 584 std::string fsid; | |
| 585 switch (type) { | |
| 586 case StorageInfo::ITUNES: | |
| 587 NOTIMPLEMENTED(); | |
| 588 break; | |
| 589 case StorageInfo::PICASA: | |
| 590 fsid = ImportedMediaGalleryRegistry::RegisterPicasaFilesystemOnUIThread( | |
| 591 path); | |
| 592 break; | |
| 593 default: | |
| 594 fsid = IsolatedContext::GetInstance()->RegisterFileSystemForPath( | |
| 581 fileapi::kFileSystemTypeNativeMedia, path, &fs_name); | 595 fileapi::kFileSystemTypeNativeMedia, path, &fs_name); |
| 596 break; | |
| 597 } | |
| 582 CHECK(!fsid.empty()); | 598 CHECK(!fsid.empty()); |
| 583 return fsid; | 599 return fsid; |
| 584 } | 600 } |
| 585 | 601 |
| 586 virtual std::string RegisterFileSystemForMTPDevice( | 602 virtual std::string RegisterFileSystemForMTPDevice( |
| 587 const std::string& device_id, const base::FilePath& path, | 603 const std::string& device_id, const base::FilePath& path, |
| 588 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) OVERRIDE { | 604 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) OVERRIDE { |
| 589 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 605 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 590 DCHECK(!StorageInfo::IsMassStorageDevice(device_id)); | 606 DCHECK(!StorageInfo::IsMassStorageDevice(device_id)); |
| 591 | 607 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 // previously used. | 736 // previously used. |
| 721 PrefChangeRegistrarMap::iterator pref_it = | 737 PrefChangeRegistrarMap::iterator pref_it = |
| 722 pref_change_registrar_map_.find(profile); | 738 pref_change_registrar_map_.find(profile); |
| 723 DCHECK(pref_it != pref_change_registrar_map_.end()); | 739 DCHECK(pref_it != pref_change_registrar_map_.end()); |
| 724 delete pref_it->second; | 740 delete pref_it->second; |
| 725 pref_change_registrar_map_.erase(pref_it); | 741 pref_change_registrar_map_.erase(pref_it); |
| 726 } | 742 } |
| 727 } | 743 } |
| 728 | 744 |
| 729 } // namespace chrome | 745 } // namespace chrome |
| OLD | NEW |