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.h" |
17 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
18 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
20 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 21 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
21 #include "components/storage_monitor/removable_storage_observer.h" | 22 #include "components/storage_monitor/removable_storage_observer.h" |
22 | 23 |
23 class ExtensionGalleriesHost; | 24 class ExtensionGalleriesHost; |
24 class MediaFileSystemContext; | 25 class MediaFileSystemContext; |
25 class MediaGalleriesPreferences; | 26 class MediaGalleriesPreferences; |
26 class MediaScanManager; | 27 class MediaScanManager; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 MediaFileSystemRegistry(); | 74 MediaFileSystemRegistry(); |
74 virtual ~MediaFileSystemRegistry(); | 75 virtual ~MediaFileSystemRegistry(); |
75 | 76 |
76 // 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 |
77 // given RVH. | 78 // given RVH. |
78 void GetMediaFileSystemsForExtension( | 79 void GetMediaFileSystemsForExtension( |
79 const content::RenderViewHost* rvh, | 80 const content::RenderViewHost* rvh, |
80 const extensions::Extension* extension, | 81 const extensions::Extension* extension, |
81 const MediaFileSystemsCallback& callback); | 82 const MediaFileSystemsCallback& callback); |
82 | 83 |
| 84 // Attempt to register the file system for |pref_id|. If |extension| does not |
| 85 // have permission to |pref_id|, sends |callback| FILE_ERROR_NOT_FOUND. |
| 86 void RegisterMediaFileSystemForExtension( |
| 87 const content::RenderViewHost* rvh, |
| 88 const extensions::Extension* extension, |
| 89 MediaGalleryPrefId pref_id, |
| 90 const base::Callback<void(base::File::Error result)>& callback); |
| 91 |
83 // Returns the media galleries preferences for the specified |profile|. | 92 // Returns the media galleries preferences for the specified |profile|. |
84 // Caller is responsible for ensuring that the preferences are initialized | 93 // Caller is responsible for ensuring that the preferences are initialized |
85 // before use. | 94 // before use. |
86 MediaGalleriesPreferences* GetPreferences(Profile* profile); | 95 MediaGalleriesPreferences* GetPreferences(Profile* profile); |
87 | 96 |
88 MediaScanManager* media_scan_manager(); | 97 MediaScanManager* media_scan_manager(); |
89 | 98 |
90 // RemovableStorageObserver implementation. | 99 // RemovableStorageObserver implementation. |
91 virtual void OnRemovableStorageDetached( | 100 virtual void OnRemovableStorageDetached( |
92 const storage_monitor::StorageInfo& info) OVERRIDE; | 101 const storage_monitor::StorageInfo& info) OVERRIDE; |
(...skipping 10 matching lines...) Expand all Loading... |
103 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; | 112 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; |
104 // Map a profile and extension to the ExtensionGalleriesHost. | 113 // Map a profile and extension to the ExtensionGalleriesHost. |
105 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap; | 114 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap; |
106 | 115 |
107 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, | 116 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, |
108 const std::string& extension_id, | 117 const std::string& extension_id, |
109 MediaGalleryPrefId pref_id) OVERRIDE; | 118 MediaGalleryPrefId pref_id) OVERRIDE; |
110 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, | 119 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, |
111 MediaGalleryPrefId pref_id) OVERRIDE; | 120 MediaGalleryPrefId pref_id) OVERRIDE; |
112 | 121 |
| 122 // Look up or create the extension gallery host. |
| 123 ExtensionGalleriesHost* GetExtensionGalleryHost( |
| 124 Profile* profile, |
| 125 MediaGalleriesPreferences* preferences, |
| 126 const std::string& extension_id); |
| 127 |
113 void OnExtensionGalleriesHostEmpty(Profile* profile, | 128 void OnExtensionGalleriesHostEmpty(Profile* profile, |
114 const std::string& extension_id); | 129 const std::string& extension_id); |
115 | 130 |
116 // This map owns all the ExtensionGalleriesHost objects created. | 131 // This map owns all the ExtensionGalleriesHost objects created. |
117 ExtensionGalleriesHostMap extension_hosts_map_; | 132 ExtensionGalleriesHostMap extension_hosts_map_; |
118 | 133 |
119 scoped_ptr<MediaFileSystemContext> file_system_context_; | 134 scoped_ptr<MediaFileSystemContext> file_system_context_; |
120 | 135 |
121 scoped_ptr<MediaScanManager> media_scan_manager_; | 136 scoped_ptr<MediaScanManager> media_scan_manager_; |
122 | 137 |
123 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); | 138 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); |
124 }; | 139 }; |
125 | 140 |
126 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 141 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
OLD | NEW |