| 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_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 8 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
| 9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 9 #define CHROME_BROWSER_MEDIA_GALLERY_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/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 18 #include "base/file_path.h" | 18 #include "base/file_path.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/prefs/public/pref_change_registrar.h" | 21 #include "base/prefs/public/pref_change_registrar.h" |
| 22 #include "base/prefs/public/pref_observer.h" |
| 22 #include "base/system_monitor/system_monitor.h" | 23 #include "base/system_monitor/system_monitor.h" |
| 23 #include "content/public/browser/notification_observer.h" | |
| 24 #include "webkit/fileapi/media/mtp_device_file_system_config.h" | 24 #include "webkit/fileapi/media/mtp_device_file_system_config.h" |
| 25 | 25 |
| 26 class Profile; | 26 class Profile; |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 class RenderViewHost; | 29 class RenderViewHost; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace extensions { | 32 namespace extensions { |
| 33 class Extension; | 33 class Extension; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 // Revoke the passed |fsid|. | 75 // Revoke the passed |fsid|. |
| 76 virtual void RevokeFileSystem(const std::string& fsid) = 0; | 76 virtual void RevokeFileSystem(const std::string& fsid) = 0; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 typedef base::Callback<void(const std::vector<MediaFileSystemInfo>&)> | 79 typedef base::Callback<void(const std::vector<MediaFileSystemInfo>&)> |
| 80 MediaFileSystemsCallback; | 80 MediaFileSystemsCallback; |
| 81 | 81 |
| 82 class MediaFileSystemRegistry | 82 class MediaFileSystemRegistry |
| 83 : public base::SystemMonitor::DevicesChangedObserver, | 83 : public base::SystemMonitor::DevicesChangedObserver, |
| 84 public content::NotificationObserver { | 84 public PrefObserver { |
| 85 public: | 85 public: |
| 86 // The instance is lazily created per browser process. | 86 // The instance is lazily created per browser process. |
| 87 static MediaFileSystemRegistry* GetInstance(); | 87 static MediaFileSystemRegistry* GetInstance(); |
| 88 | 88 |
| 89 // Passes to |callback| the list of media filesystem IDs and paths for a | 89 // Passes to |callback| the list of media filesystem IDs and paths for a |
| 90 // given RVH. Called on the UI thread. | 90 // given RVH. Called on the UI thread. |
| 91 void GetMediaFileSystemsForExtension( | 91 void GetMediaFileSystemsForExtension( |
| 92 const content::RenderViewHost* rvh, | 92 const content::RenderViewHost* rvh, |
| 93 const extensions::Extension* extension, | 93 const extensions::Extension* extension, |
| 94 const MediaFileSystemsCallback& callback); | 94 const MediaFileSystemsCallback& callback); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 124 // ScopedMtpDeviceMapEntry. | 124 // ScopedMtpDeviceMapEntry. |
| 125 typedef std::map<const FilePath::StringType, | 125 typedef std::map<const FilePath::StringType, |
| 126 base::WeakPtr<ScopedMtpDeviceMapEntry> > | 126 base::WeakPtr<ScopedMtpDeviceMapEntry> > |
| 127 MTPDeviceDelegateMap; | 127 MTPDeviceDelegateMap; |
| 128 #endif | 128 #endif |
| 129 | 129 |
| 130 // Obtain an instance of this class via GetInstance(). | 130 // Obtain an instance of this class via GetInstance(). |
| 131 MediaFileSystemRegistry(); | 131 MediaFileSystemRegistry(); |
| 132 virtual ~MediaFileSystemRegistry(); | 132 virtual ~MediaFileSystemRegistry(); |
| 133 | 133 |
| 134 // NotificationObserver implementation. | 134 // PrefObserver implementation. |
| 135 virtual void Observe(int type, | 135 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 136 const content::NotificationSource& source, | 136 const std::string& pref_name) OVERRIDE; |
| 137 const content::NotificationDetails& details) OVERRIDE; | |
| 138 | 137 |
| 139 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 138 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| 140 // Returns ScopedMtpDeviceMapEntry object for the given |device_location|. | 139 // Returns ScopedMtpDeviceMapEntry object for the given |device_location|. |
| 141 ScopedMtpDeviceMapEntry* GetOrCreateScopedMtpDeviceMapEntry( | 140 ScopedMtpDeviceMapEntry* GetOrCreateScopedMtpDeviceMapEntry( |
| 142 const FilePath::StringType& device_location); | 141 const FilePath::StringType& device_location); |
| 143 | 142 |
| 144 // Removes the ScopedMtpDeviceMapEntry associated with the given | 143 // Removes the ScopedMtpDeviceMapEntry associated with the given |
| 145 // |device_location|. | 144 // |device_location|. |
| 146 void RemoveScopedMtpDeviceMapEntry( | 145 void RemoveScopedMtpDeviceMapEntry( |
| 147 const FilePath::StringType& device_location); | 146 const FilePath::StringType& device_location); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 162 #endif | 161 #endif |
| 163 | 162 |
| 164 scoped_ptr<MediaFileSystemContext> file_system_context_; | 163 scoped_ptr<MediaFileSystemContext> file_system_context_; |
| 165 | 164 |
| 166 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); | 165 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); |
| 167 }; | 166 }; |
| 168 | 167 |
| 169 } // namespace chrome | 168 } // namespace chrome |
| 170 | 169 |
| 171 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 170 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
| OLD | NEW |