| 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 registers pictures directories and media devices as | 5 // MediaFileSystemRegistry registers pictures directories and media devices as |
| 6 // File API filesystems and keeps track of the path to filesystem ID mappings. | 6 // File API filesystems and keeps track of the path to filesystem ID mappings. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 8 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
| 9 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 9 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 MediaFileSystemRegistry(); | 69 MediaFileSystemRegistry(); |
| 70 virtual ~MediaFileSystemRegistry(); | 70 virtual ~MediaFileSystemRegistry(); |
| 71 | 71 |
| 72 // Passes to |callback| the list of media filesystem IDs and paths for a | 72 // Passes to |callback| the list of media filesystem IDs and paths for a |
| 73 // given RVH. Called on the UI thread. | 73 // given RVH. Called on the UI thread. |
| 74 void GetMediaFileSystemsForExtension( | 74 void GetMediaFileSystemsForExtension( |
| 75 const content::RenderViewHost* rvh, | 75 const content::RenderViewHost* rvh, |
| 76 const extensions::Extension* extension, | 76 const extensions::Extension* extension, |
| 77 const MediaFileSystemsCallback& callback); | 77 const MediaFileSystemsCallback& callback); |
| 78 | 78 |
| 79 // Returns the initialized media galleries preferences for the specified | 79 // Returns the media galleries preferences for the specified |profile|. |
| 80 // |profile|. This method should be used instead of calling | 80 // Called on the UI thread. Caller is responsible for ensuring that the |
| 81 // MediaGalleriesPreferences directly because this method also ensures that | 81 // preferences are initialized before use. |
| 82 // currently attached removable devices are added to the preferences. | |
| 83 // Called on the UI thread. | |
| 84 // Note: Caller must ensure that the storage monitor is initialized before | |
| 85 // calling this method. | |
| 86 MediaGalleriesPreferences* GetPreferences(Profile* profile); | 82 MediaGalleriesPreferences* GetPreferences(Profile* profile); |
| 87 | 83 |
| 88 // RemovableStorageObserver implementation. | 84 // RemovableStorageObserver implementation. |
| 89 virtual void OnRemovableStorageDetached(const StorageInfo& info) OVERRIDE; | 85 virtual void OnRemovableStorageDetached(const StorageInfo& info) OVERRIDE; |
| 90 | 86 |
| 91 private: | 87 private: |
| 92 friend class MediaFileSystemRegistryTest; | 88 friend class MediaFileSystemRegistryTest; |
| 93 friend class TestMediaFileSystemContext; | 89 friend class TestMediaFileSystemContext; |
| 94 class MediaFileSystemContextImpl; | 90 class MediaFileSystemContextImpl; |
| 95 | 91 |
| 96 // Map an extension to the ExtensionGalleriesHost. | 92 // Map an extension to the ExtensionGalleriesHost. |
| 97 typedef std::map<std::string /*extension_id*/, | 93 typedef std::map<std::string /*extension_id*/, |
| 98 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; | 94 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; |
| 99 // Map a profile and extension to the ExtensionGalleriesHost. | 95 // Map a profile and extension to the ExtensionGalleriesHost. |
| 100 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap; | 96 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap; |
| 101 | 97 |
| 102 // Map a MTP or PTP device location to the raw pointer of | 98 // Map a MTP or PTP device location to the raw pointer of |
| 103 // ScopedMTPDeviceMapEntry. It is safe to store a raw pointer in this | 99 // ScopedMTPDeviceMapEntry. It is safe to store a raw pointer in this |
| 104 // map. | 100 // map. |
| 105 typedef std::map<const base::FilePath::StringType, ScopedMTPDeviceMapEntry*> | 101 typedef std::map<const base::FilePath::StringType, ScopedMTPDeviceMapEntry*> |
| 106 MTPDeviceDelegateMap; | 102 MTPDeviceDelegateMap; |
| 107 | 103 |
| 104 void FinishGetMediaFileSystemsForExtension( |
| 105 const content::RenderViewHost* rvh, |
| 106 const extensions::Extension* extension, |
| 107 const MediaFileSystemsCallback& callback); |
| 108 |
| 108 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, | 109 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, |
| 109 const std::string& extension_id, | 110 const std::string& extension_id, |
| 110 MediaGalleryPrefId pref_id) OVERRIDE; | 111 MediaGalleryPrefId pref_id) OVERRIDE; |
| 111 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, | 112 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, |
| 112 MediaGalleryPrefId pref_id) OVERRIDE; | 113 MediaGalleryPrefId pref_id) OVERRIDE; |
| 113 | 114 |
| 114 // Returns ScopedMTPDeviceMapEntry object for the given |device_location|. | 115 // Returns ScopedMTPDeviceMapEntry object for the given |device_location|. |
| 115 scoped_refptr<ScopedMTPDeviceMapEntry> GetOrCreateScopedMTPDeviceMapEntry( | 116 scoped_refptr<ScopedMTPDeviceMapEntry> GetOrCreateScopedMTPDeviceMapEntry( |
| 116 const base::FilePath::StringType& device_location); | 117 const base::FilePath::StringType& device_location); |
| 117 | 118 |
| 118 // Removes the ScopedMTPDeviceMapEntry associated with the given | 119 // Removes the ScopedMTPDeviceMapEntry associated with the given |
| 119 // |device_location|. | 120 // |device_location|. |
| 120 void RemoveScopedMTPDeviceMapEntry( | 121 void RemoveScopedMTPDeviceMapEntry( |
| 121 const base::FilePath::StringType& device_location); | 122 const base::FilePath::StringType& device_location); |
| 122 | 123 |
| 123 void OnExtensionGalleriesHostEmpty(Profile* profile, | 124 void OnExtensionGalleriesHostEmpty(Profile* profile, |
| 124 const std::string& extension_id); | 125 const std::string& extension_id); |
| 125 | 126 |
| 127 base::WeakPtrFactory<MediaFileSystemRegistry> weak_factory_; |
| 128 |
| 126 // Only accessed on the UI thread. This map owns all the | 129 // Only accessed on the UI thread. This map owns all the |
| 127 // ExtensionGalleriesHost objects created. | 130 // ExtensionGalleriesHost objects created. |
| 128 ExtensionGalleriesHostMap extension_hosts_map_; | 131 ExtensionGalleriesHostMap extension_hosts_map_; |
| 129 | 132 |
| 130 // Only accessed on the UI thread. | 133 // Only accessed on the UI thread. |
| 131 MTPDeviceDelegateMap mtp_device_delegate_map_; | 134 MTPDeviceDelegateMap mtp_device_delegate_map_; |
| 132 | 135 |
| 133 scoped_ptr<MediaFileSystemContext> file_system_context_; | 136 scoped_ptr<MediaFileSystemContext> file_system_context_; |
| 134 | 137 |
| 135 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); | 138 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); |
| 136 }; | 139 }; |
| 137 | 140 |
| 138 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 141 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
| OLD | NEW |