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 std::string fsid; |
581 fileapi::kFileSystemTypeNativeMedia, path, &fs_name); | 582 if (StorageInfo::IsITunesDevice(device_id)) { |
| 583 NOTIMPLEMENTED(); |
| 584 } else if (StorageInfo::IsPicasaDevice(device_id)) { |
| 585 fsid = ImportedMediaGalleryRegistry::RegisterPicasaFilesystemOnUIThread( |
| 586 path); |
| 587 } else { |
| 588 fsid = IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| 589 fileapi::kFileSystemTypeNativeMedia, path, &fs_name); |
| 590 } |
| 591 |
582 CHECK(!fsid.empty()); | 592 CHECK(!fsid.empty()); |
583 return fsid; | 593 return fsid; |
584 } | 594 } |
585 | 595 |
586 virtual std::string RegisterFileSystemForMTPDevice( | 596 virtual std::string RegisterFileSystemForMTPDevice( |
587 const std::string& device_id, const base::FilePath& path, | 597 const std::string& device_id, const base::FilePath& path, |
588 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) OVERRIDE { | 598 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) OVERRIDE { |
589 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 599 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
590 DCHECK(!StorageInfo::IsMassStorageDevice(device_id)); | 600 DCHECK(!StorageInfo::IsMassStorageDevice(device_id)); |
591 | 601 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 // previously used. | 730 // previously used. |
721 PrefChangeRegistrarMap::iterator pref_it = | 731 PrefChangeRegistrarMap::iterator pref_it = |
722 pref_change_registrar_map_.find(profile); | 732 pref_change_registrar_map_.find(profile); |
723 DCHECK(pref_it != pref_change_registrar_map_.end()); | 733 DCHECK(pref_it != pref_change_registrar_map_.end()); |
724 delete pref_it->second; | 734 delete pref_it->second; |
725 pref_change_registrar_map_.erase(pref_it); | 735 pref_change_registrar_map_.erase(pref_it); |
726 } | 736 } |
727 } | 737 } |
728 | 738 |
729 } // namespace chrome | 739 } // namespace chrome |
OLD | NEW |