| 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/transient_device_ids.h" | 20 #include "chrome/browser/media_gallery/transient_device_ids.h" |
| 21 #include "chrome/browser/system_monitor/removable_storage_observer.h" |
| 22 #include "webkit/fileapi/media/mtp_device_file_system_config.h" | 22 #include "webkit/fileapi/media/mtp_device_file_system_config.h" |
| 23 | 23 |
| 24 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 24 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| 25 #include "chrome/browser/media_gallery/mtp_device_delegate_impl.h" | 25 #include "chrome/browser/media_gallery/mtp_device_delegate_impl.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 class Profile; | 28 class Profile; |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 class RenderViewHost; | 31 class RenderViewHost; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 53 MediaFileSystemInfo(); | 53 MediaFileSystemInfo(); |
| 54 | 54 |
| 55 std::string name; // JSON string, must not contain slashes. | 55 std::string name; // JSON string, must not contain slashes. |
| 56 FilePath path; | 56 FilePath path; |
| 57 std::string fsid; | 57 std::string fsid; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 typedef base::Callback<void(const std::vector<MediaFileSystemInfo>&)> | 60 typedef base::Callback<void(const std::vector<MediaFileSystemInfo>&)> |
| 61 MediaFileSystemsCallback; | 61 MediaFileSystemsCallback; |
| 62 | 62 |
| 63 class MediaFileSystemRegistry | 63 class MediaFileSystemRegistry : public RemovableStorageObserver { |
| 64 : public base::SystemMonitor::DevicesChangedObserver { | |
| 65 public: | 64 public: |
| 66 MediaFileSystemRegistry(); | 65 MediaFileSystemRegistry(); |
| 67 virtual ~MediaFileSystemRegistry(); | 66 virtual ~MediaFileSystemRegistry(); |
| 68 | 67 |
| 69 // Passes to |callback| the list of media filesystem IDs and paths for a | 68 // Passes to |callback| the list of media filesystem IDs and paths for a |
| 70 // given RVH. Called on the UI thread. | 69 // given RVH. Called on the UI thread. |
| 71 void GetMediaFileSystemsForExtension( | 70 void GetMediaFileSystemsForExtension( |
| 72 const content::RenderViewHost* rvh, | 71 const content::RenderViewHost* rvh, |
| 73 const extensions::Extension* extension, | 72 const extensions::Extension* extension, |
| 74 const MediaFileSystemsCallback& callback); | 73 const MediaFileSystemsCallback& callback); |
| 75 | 74 |
| 76 // Returns the initialized media galleries preferences for the specified | 75 // Returns the initialized media galleries preferences for the specified |
| 77 // |profile|. This method should be used instead of calling | 76 // |profile|. This method should be used instead of calling |
| 78 // MediaGalleriesPreferences directly because this method also ensures that | 77 // MediaGalleriesPreferences directly because this method also ensures that |
| 79 // currently attached removable devices are added to the preferences. | 78 // currently attached removable devices are added to the preferences. |
| 80 // Called on the UI thread. | 79 // Called on the UI thread. |
| 81 MediaGalleriesPreferences* GetPreferences(Profile* profile); | 80 MediaGalleriesPreferences* GetPreferences(Profile* profile); |
| 82 | 81 |
| 83 // base::SystemMonitor::DevicesChangedObserver implementation. | 82 // RemovableStorageObserver implementation. |
| 84 virtual void OnRemovableStorageAttached( | 83 virtual void OnRemovableStorageAttached( |
| 85 const std::string& id, | 84 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; |
| 86 const string16& name, | 85 virtual void OnRemovableStorageDetached( |
| 87 const FilePath::StringType& location) OVERRIDE; | 86 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; |
| 88 virtual void OnRemovableStorageDetached(const std::string& id) OVERRIDE; | |
| 89 | 87 |
| 90 size_t GetExtensionHostCountForTests() const; | 88 size_t GetExtensionHostCountForTests() const; |
| 91 | 89 |
| 92 std::string GetTransientIdForDeviceId(const std::string& device_id) const; | 90 std::string GetTransientIdForDeviceId(const std::string& device_id) const; |
| 93 | 91 |
| 94 // Keys used in gallery names, which are JSON strings. | 92 // Keys used in gallery names, which are JSON strings. |
| 95 static const char kDeviceIdKey[]; | 93 static const char kDeviceIdKey[]; |
| 96 static const char kGalleryIdKey[]; | 94 static const char kGalleryIdKey[]; |
| 97 static const char kNameKey[]; | 95 static const char kNameKey[]; |
| 98 | 96 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 scoped_ptr<MediaFileSystemContext> file_system_context_; | 144 scoped_ptr<MediaFileSystemContext> file_system_context_; |
| 147 | 145 |
| 148 TransientDeviceIds transient_device_ids_; | 146 TransientDeviceIds transient_device_ids_; |
| 149 | 147 |
| 150 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); | 148 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); |
| 151 }; | 149 }; |
| 152 | 150 |
| 153 } // namespace chrome | 151 } // namespace chrome |
| 154 | 152 |
| 155 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 153 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
| OLD | NEW |