| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 typedef base::Callback<void(const std::vector<MediaFileSystemInfo>&)> | 66 typedef base::Callback<void(const std::vector<MediaFileSystemInfo>&)> |
| 67 MediaFileSystemsCallback; | 67 MediaFileSystemsCallback; |
| 68 | 68 |
| 69 // Tracks usage of filesystems by extensions. | 69 // Tracks usage of filesystems by extensions. |
| 70 // This object lives on the UI thread. | 70 // This object lives on the UI thread. |
| 71 class MediaFileSystemRegistry | 71 class MediaFileSystemRegistry |
| 72 : public storage_monitor::RemovableStorageObserver, | 72 : public storage_monitor::RemovableStorageObserver, |
| 73 public MediaGalleriesPreferences::GalleryChangeObserver { | 73 public MediaGalleriesPreferences::GalleryChangeObserver { |
| 74 public: | 74 public: |
| 75 MediaFileSystemRegistry(); | 75 MediaFileSystemRegistry(); |
| 76 virtual ~MediaFileSystemRegistry(); | 76 ~MediaFileSystemRegistry() override; |
| 77 | 77 |
| 78 // Passes to |callback| the list of media filesystem IDs and paths for a | 78 // Passes to |callback| the list of media filesystem IDs and paths for a |
| 79 // given RVH. | 79 // given RVH. |
| 80 void GetMediaFileSystemsForExtension( | 80 void GetMediaFileSystemsForExtension( |
| 81 const content::RenderViewHost* rvh, | 81 const content::RenderViewHost* rvh, |
| 82 const extensions::Extension* extension, | 82 const extensions::Extension* extension, |
| 83 const MediaFileSystemsCallback& callback); | 83 const MediaFileSystemsCallback& callback); |
| 84 | 84 |
| 85 // Attempt to register the file system for |pref_id|. If |extension| does not | 85 // Attempt to register the file system for |pref_id|. If |extension| does not |
| 86 // have permission to |pref_id|, sends |callback| FILE_ERROR_NOT_FOUND. | 86 // have permission to |pref_id|, sends |callback| FILE_ERROR_NOT_FOUND. |
| 87 void RegisterMediaFileSystemForExtension( | 87 void RegisterMediaFileSystemForExtension( |
| 88 const content::RenderViewHost* rvh, | 88 const content::RenderViewHost* rvh, |
| 89 const extensions::Extension* extension, | 89 const extensions::Extension* extension, |
| 90 MediaGalleryPrefId pref_id, | 90 MediaGalleryPrefId pref_id, |
| 91 const base::Callback<void(base::File::Error result)>& callback); | 91 const base::Callback<void(base::File::Error result)>& callback); |
| 92 | 92 |
| 93 // Returns the media galleries preferences for the specified |profile|. | 93 // Returns the media galleries preferences for the specified |profile|. |
| 94 // Caller is responsible for ensuring that the preferences are initialized | 94 // Caller is responsible for ensuring that the preferences are initialized |
| 95 // before use. | 95 // before use. |
| 96 MediaGalleriesPreferences* GetPreferences(Profile* profile); | 96 MediaGalleriesPreferences* GetPreferences(Profile* profile); |
| 97 | 97 |
| 98 MediaScanManager* media_scan_manager(); | 98 MediaScanManager* media_scan_manager(); |
| 99 GalleryWatchManager* gallery_watch_manager(); | 99 GalleryWatchManager* gallery_watch_manager(); |
| 100 | 100 |
| 101 // RemovableStorageObserver implementation. | 101 // RemovableStorageObserver implementation. |
| 102 virtual void OnRemovableStorageDetached( | 102 void OnRemovableStorageDetached( |
| 103 const storage_monitor::StorageInfo& info) override; | 103 const storage_monitor::StorageInfo& info) override; |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 class MediaFileSystemContextImpl; | 106 class MediaFileSystemContextImpl; |
| 107 | 107 |
| 108 friend class MediaFileSystemContextImpl; | 108 friend class MediaFileSystemContextImpl; |
| 109 friend class MediaFileSystemRegistryTest; | 109 friend class MediaFileSystemRegistryTest; |
| 110 friend class TestMediaFileSystemContext; | 110 friend class TestMediaFileSystemContext; |
| 111 | 111 |
| 112 // Map an extension to the ExtensionGalleriesHost. | 112 // Map an extension to the ExtensionGalleriesHost. |
| 113 typedef std::map<std::string /*extension_id*/, | 113 typedef std::map<std::string /*extension_id*/, |
| 114 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; | 114 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; |
| 115 // Map a profile and extension to the ExtensionGalleriesHost. | 115 // Map a profile and extension to the ExtensionGalleriesHost. |
| 116 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap; | 116 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap; |
| 117 | 117 |
| 118 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, | 118 void OnPermissionRemoved(MediaGalleriesPreferences* pref, |
| 119 const std::string& extension_id, | 119 const std::string& extension_id, |
| 120 MediaGalleryPrefId pref_id) override; | 120 MediaGalleryPrefId pref_id) override; |
| 121 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, | 121 void OnGalleryRemoved(MediaGalleriesPreferences* pref, |
| 122 MediaGalleryPrefId pref_id) override; | 122 MediaGalleryPrefId pref_id) override; |
| 123 | 123 |
| 124 // Look up or create the extension gallery host. | 124 // Look up or create the extension gallery host. |
| 125 ExtensionGalleriesHost* GetExtensionGalleryHost( | 125 ExtensionGalleriesHost* GetExtensionGalleryHost( |
| 126 Profile* profile, | 126 Profile* profile, |
| 127 MediaGalleriesPreferences* preferences, | 127 MediaGalleriesPreferences* preferences, |
| 128 const std::string& extension_id); | 128 const std::string& extension_id); |
| 129 | 129 |
| 130 void OnExtensionGalleriesHostEmpty(Profile* profile, | 130 void OnExtensionGalleriesHostEmpty(Profile* profile, |
| 131 const std::string& extension_id); | 131 const std::string& extension_id); |
| 132 | 132 |
| 133 // This map owns all the ExtensionGalleriesHost objects created. | 133 // This map owns all the ExtensionGalleriesHost objects created. |
| 134 ExtensionGalleriesHostMap extension_hosts_map_; | 134 ExtensionGalleriesHostMap extension_hosts_map_; |
| 135 | 135 |
| 136 scoped_ptr<MediaFileSystemContext> file_system_context_; | 136 scoped_ptr<MediaFileSystemContext> file_system_context_; |
| 137 | 137 |
| 138 scoped_ptr<MediaScanManager> media_scan_manager_; | 138 scoped_ptr<MediaScanManager> media_scan_manager_; |
| 139 scoped_ptr<GalleryWatchManager> gallery_watch_manager_; | 139 scoped_ptr<GalleryWatchManager> gallery_watch_manager_; |
| 140 | 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); | 141 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 144 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
| OLD | NEW |