| 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/file_path.h" | 17 #include "base/file_path.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/prefs/public/pref_change_registrar.h" | 19 #include "base/prefs/public/pref_change_registrar.h" |
| 20 #include "base/system_monitor/system_monitor.h" | |
| 21 #include "chrome/browser/media_gallery/media_galleries_preferences.h" | 20 #include "chrome/browser/media_gallery/media_galleries_preferences.h" |
| 22 #include "chrome/browser/media_gallery/transient_device_ids.h" | 21 #include "chrome/browser/media_gallery/transient_device_ids.h" |
| 22 #include "chrome/browser/system_monitor/removable_storage_observer.h" |
| 23 #include "webkit/fileapi/media/mtp_device_file_system_config.h" | 23 #include "webkit/fileapi/media/mtp_device_file_system_config.h" |
| 24 | 24 |
| 25 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 25 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| 26 #include "chrome/browser/media_gallery/mtp_device_delegate_impl.h" | 26 #include "chrome/browser/media_gallery/mtp_device_delegate_impl.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 class Profile; | 29 class Profile; |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 class RenderViewHost; | 32 class RenderViewHost; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 62 std::string fsid; | 62 std::string fsid; |
| 63 MediaGalleryPrefId pref_id; | 63 MediaGalleryPrefId pref_id; |
| 64 uint64 transient_device_id; | 64 uint64 transient_device_id; |
| 65 bool removable; | 65 bool removable; |
| 66 bool media_device; | 66 bool media_device; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 typedef base::Callback<void(const std::vector<MediaFileSystemInfo>&)> | 69 typedef base::Callback<void(const std::vector<MediaFileSystemInfo>&)> |
| 70 MediaFileSystemsCallback; | 70 MediaFileSystemsCallback; |
| 71 | 71 |
| 72 class MediaFileSystemRegistry | 72 class MediaFileSystemRegistry : public RemovableStorageObserver { |
| 73 : public base::SystemMonitor::DevicesChangedObserver { | |
| 74 public: | 73 public: |
| 75 MediaFileSystemRegistry(); | 74 MediaFileSystemRegistry(); |
| 76 virtual ~MediaFileSystemRegistry(); | 75 virtual ~MediaFileSystemRegistry(); |
| 77 | 76 |
| 78 // Passes to |callback| the list of media filesystem IDs and paths for a | 77 // Passes to |callback| the list of media filesystem IDs and paths for a |
| 79 // given RVH. Called on the UI thread. | 78 // given RVH. Called on the UI thread. |
| 80 void GetMediaFileSystemsForExtension( | 79 void GetMediaFileSystemsForExtension( |
| 81 const content::RenderViewHost* rvh, | 80 const content::RenderViewHost* rvh, |
| 82 const extensions::Extension* extension, | 81 const extensions::Extension* extension, |
| 83 const MediaFileSystemsCallback& callback); | 82 const MediaFileSystemsCallback& callback); |
| 84 | 83 |
| 85 // Returns the initialized media galleries preferences for the specified | 84 // Returns the initialized media galleries preferences for the specified |
| 86 // |profile|. This method should be used instead of calling | 85 // |profile|. This method should be used instead of calling |
| 87 // MediaGalleriesPreferences directly because this method also ensures that | 86 // MediaGalleriesPreferences directly because this method also ensures that |
| 88 // currently attached removable devices are added to the preferences. | 87 // currently attached removable devices are added to the preferences. |
| 89 // Called on the UI thread. | 88 // Called on the UI thread. |
| 90 MediaGalleriesPreferences* GetPreferences(Profile* profile); | 89 MediaGalleriesPreferences* GetPreferences(Profile* profile); |
| 91 | 90 |
| 92 // base::SystemMonitor::DevicesChangedObserver implementation. | 91 // RemovableStorageObserver implementation. |
| 93 virtual void OnRemovableStorageAttached( | 92 virtual void OnRemovableStorageAttached( |
| 94 const std::string& id, | 93 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; |
| 95 const string16& name, | 94 virtual void OnRemovableStorageDetached( |
| 96 const FilePath::StringType& location) OVERRIDE; | 95 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; |
| 97 virtual void OnRemovableStorageDetached(const std::string& id) OVERRIDE; | |
| 98 | 96 |
| 99 size_t GetExtensionHostCountForTests() const; | 97 size_t GetExtensionHostCountForTests() const; |
| 100 | 98 |
| 101 // See TransientDeviceIds::GetTransientIdForDeviceId(). | 99 // See TransientDeviceIds::GetTransientIdForDeviceId(). |
| 102 uint64 GetTransientIdForDeviceId(const std::string& device_id); | 100 uint64 GetTransientIdForDeviceId(const std::string& device_id); |
| 103 | 101 |
| 104 // Keys for metadata about a media gallery file system. | 102 // Keys for metadata about a media gallery file system. |
| 105 static const char kDeviceIdKey[]; | 103 static const char kDeviceIdKey[]; |
| 106 static const char kGalleryIdKey[]; | 104 static const char kGalleryIdKey[]; |
| 107 static const char kNameKey[]; | 105 static const char kNameKey[]; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 scoped_ptr<MediaFileSystemContext> file_system_context_; | 154 scoped_ptr<MediaFileSystemContext> file_system_context_; |
| 157 | 155 |
| 158 TransientDeviceIds transient_device_ids_; | 156 TransientDeviceIds transient_device_ids_; |
| 159 | 157 |
| 160 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); | 158 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); |
| 161 }; | 159 }; |
| 162 | 160 |
| 163 } // namespace chrome | 161 } // namespace chrome |
| 164 | 162 |
| 165 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 163 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
| OLD | NEW |