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 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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/memory/weak_ptr.h" | |
| 19 #include "base/prefs/pref_change_registrar.h" | 20 #include "base/prefs/pref_change_registrar.h" |
| 20 #include "chrome/browser/media_galleries/fileapi/mtp_device_file_system_config.h " | 21 #include "chrome/browser/media_galleries/fileapi/mtp_device_file_system_config.h " |
| 21 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 22 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
| 22 #include "chrome/browser/storage_monitor/removable_storage_observer.h" | 23 #include "chrome/browser/storage_monitor/removable_storage_observer.h" |
| 23 | 24 |
| 24 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 25 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| 25 #include "chrome/browser/media_galleries/mtp_device_delegate_impl.h" | 26 #include "chrome/browser/media_galleries/mtp_device_delegate_impl.h" |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 class Profile; | 29 class Profile; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 MediaFileSystemRegistry(); | 75 MediaFileSystemRegistry(); |
| 75 virtual ~MediaFileSystemRegistry(); | 76 virtual ~MediaFileSystemRegistry(); |
| 76 | 77 |
| 77 // 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 |
| 78 // given RVH. Called on the UI thread. | 79 // given RVH. Called on the UI thread. |
| 79 void GetMediaFileSystemsForExtension( | 80 void GetMediaFileSystemsForExtension( |
| 80 const content::RenderViewHost* rvh, | 81 const content::RenderViewHost* rvh, |
| 81 const extensions::Extension* extension, | 82 const extensions::Extension* extension, |
| 82 const MediaFileSystemsCallback& callback); | 83 const MediaFileSystemsCallback& callback); |
| 83 | 84 |
| 84 // Returns the initialized media galleries preferences for the specified | 85 // Call the given callback with preferences. This is asynchronous so that |
| 85 // |profile|. This method should be used instead of calling | 86 // StorageMonitor may be initialized lazily in order to set up the returned |
| 87 // preferences. | |
| 88 // This method should be used instead of calling | |
| 86 // MediaGalleriesPreferences directly because this method also ensures that | 89 // MediaGalleriesPreferences directly because this method also ensures that |
| 87 // currently attached removable devices are added to the preferences. | 90 // currently attached removable devices are added to the preferences. |
| 88 // Called on the UI thread. | 91 // Called on the UI thread. |
| 89 MediaGalleriesPreferences* GetPreferences(Profile* profile); | 92 void GetPreferencesAsync( |
|
vandebo (ex-Chrome)
2013/05/17 22:19:58
nit picky: maybe leave this name the same and rena
Greg Billock
2013/05/18 06:28:40
Fiddled this with the new interface.
| |
| 93 Profile* profile, | |
| 94 base::Callback<void(MediaGalleriesPreferences*)> callback); | |
| 90 | 95 |
| 91 // RemovableStorageObserver implementation. | 96 // RemovableStorageObserver implementation. |
| 92 virtual void OnRemovableStorageDetached(const StorageInfo& info) OVERRIDE; | 97 virtual void OnRemovableStorageDetached(const StorageInfo& info) OVERRIDE; |
| 93 | 98 |
| 94 size_t GetExtensionGalleriesHostCountForTests() const; | 99 size_t GetExtensionGalleriesHostCountForTests() const; |
| 95 | 100 |
| 96 // See TransientDeviceIds::GetTransientIdForDeviceId(). | 101 // See TransientDeviceIds::GetTransientIdForDeviceId(). |
| 97 uint64 GetTransientIdForDeviceId(const std::string& device_id); | 102 uint64 GetTransientIdForDeviceId(const std::string& device_id); |
| 98 | 103 |
| 99 private: | 104 private: |
| 100 friend class TestMediaFileSystemContext; | 105 friend class TestMediaFileSystemContext; |
| 101 class MediaFileSystemContextImpl; | 106 class MediaFileSystemContextImpl; |
| 102 | 107 |
| 108 MediaGalleriesPreferences* GetPreferences(Profile* profile); | |
| 109 | |
| 110 // Bottom half of |GetMediaFileSystemsForExtensions|, called after the | |
| 111 // StorageMonitor is initialized. | |
| 112 void GetMediaFileSystemsPostStorageMonitorInit( | |
|
vandebo (ex-Chrome)
2013/05/17 22:19:58
GetMediaFileSystemsWithPreferences ?
Greg Billock
2013/05/18 06:28:40
Done.
| |
| 113 const content::RenderViewHost* rvh, | |
| 114 const extensions::Extension* extension, | |
| 115 const MediaFileSystemsCallback& callback, | |
| 116 MediaGalleriesPreferences* preferences); | |
| 117 | |
| 118 // Notify the registry when the storage monitor has been initialized. | |
| 119 void OnStorageMonitorInitialized( | |
| 120 Profile* profile, | |
| 121 base::Callback<void(MediaGalleriesPreferences*)> callback); | |
| 122 | |
| 103 // Map an extension to the ExtensionGalleriesHost. | 123 // Map an extension to the ExtensionGalleriesHost. |
| 104 typedef std::map<std::string /*extension_id*/, | 124 typedef std::map<std::string /*extension_id*/, |
| 105 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; | 125 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; |
| 106 // Map a profile and extension to the ExtensionGalleriesHost. | 126 // Map a profile and extension to the ExtensionGalleriesHost. |
| 107 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap; | 127 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap; |
| 108 // Map a profile to a PrefChangeRegistrar. | 128 // Map a profile to a PrefChangeRegistrar. |
| 109 typedef std::map<Profile*, PrefChangeRegistrar*> PrefChangeRegistrarMap; | 129 typedef std::map<Profile*, PrefChangeRegistrar*> PrefChangeRegistrarMap; |
| 110 | 130 |
| 111 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 131 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| 112 // Map a MTP or PTP device location to the raw pointer of | 132 // Map a MTP or PTP device location to the raw pointer of |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 138 | 158 |
| 139 PrefChangeRegistrarMap pref_change_registrar_map_; | 159 PrefChangeRegistrarMap pref_change_registrar_map_; |
| 140 | 160 |
| 141 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 161 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| 142 // Only accessed on the UI thread. | 162 // Only accessed on the UI thread. |
| 143 MTPDeviceDelegateMap mtp_device_delegate_map_; | 163 MTPDeviceDelegateMap mtp_device_delegate_map_; |
| 144 #endif | 164 #endif |
| 145 | 165 |
| 146 scoped_ptr<MediaFileSystemContext> file_system_context_; | 166 scoped_ptr<MediaFileSystemContext> file_system_context_; |
| 147 | 167 |
| 168 base::WeakPtrFactory<MediaFileSystemRegistry> weak_ptr_factory_; | |
| 169 | |
| 148 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); | 170 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); |
| 149 }; | 171 }; |
| 150 | 172 |
| 151 } // namespace chrome | 173 } // namespace chrome |
| 152 | 174 |
| 153 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 175 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
| OLD | NEW |