| 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 // Defines the Chrome Extensions Media Galleries API functions for accessing | 5 // Defines the Chrome Extensions Media Galleries API functions for accessing |
| 6 // user's media files, as specified in the extension API IDL. | 6 // user's media files, as specified in the extension API IDL. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ | 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ |
| 9 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ | 9 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ |
| 10 | 10 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class MediaGalleriesGetMediaFileSystemsFunction | 90 class MediaGalleriesGetMediaFileSystemsFunction |
| 91 : public ChromeAsyncExtensionFunction { | 91 : public ChromeAsyncExtensionFunction { |
| 92 public: | 92 public: |
| 93 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMediaFileSystems", | 93 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMediaFileSystems", |
| 94 MEDIAGALLERIES_GETMEDIAFILESYSTEMS) | 94 MEDIAGALLERIES_GETMEDIAFILESYSTEMS) |
| 95 | 95 |
| 96 protected: | 96 protected: |
| 97 virtual ~MediaGalleriesGetMediaFileSystemsFunction(); | 97 virtual ~MediaGalleriesGetMediaFileSystemsFunction(); |
| 98 virtual bool RunImpl() OVERRIDE; | 98 virtual bool RunAsync() OVERRIDE; |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 // Bottom half for RunImpl, invoked after the preferences is initialized. | 101 // Bottom half for RunAsync, invoked after the preferences is initialized. |
| 102 void OnPreferencesInit( | 102 void OnPreferencesInit( |
| 103 MediaGalleries::GetMediaFileSystemsInteractivity interactive); | 103 MediaGalleries::GetMediaFileSystemsInteractivity interactive); |
| 104 | 104 |
| 105 // Always show the dialog. | 105 // Always show the dialog. |
| 106 void AlwaysShowDialog(const std::vector<MediaFileSystemInfo>& filesystems); | 106 void AlwaysShowDialog(const std::vector<MediaFileSystemInfo>& filesystems); |
| 107 | 107 |
| 108 // If no galleries are found, show the dialog, otherwise return them. | 108 // If no galleries are found, show the dialog, otherwise return them. |
| 109 void ShowDialogIfNoGalleries( | 109 void ShowDialogIfNoGalleries( |
| 110 const std::vector<MediaFileSystemInfo>& filesystems); | 110 const std::vector<MediaFileSystemInfo>& filesystems); |
| 111 | 111 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 class MediaGalleriesGetAllMediaFileSystemMetadataFunction | 127 class MediaGalleriesGetAllMediaFileSystemMetadataFunction |
| 128 : public ChromeAsyncExtensionFunction { | 128 : public ChromeAsyncExtensionFunction { |
| 129 public: | 129 public: |
| 130 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getAllMediaFileSystemMetadata", | 130 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getAllMediaFileSystemMetadata", |
| 131 MEDIAGALLERIES_GETALLMEDIAFILESYSTEMMETADATA) | 131 MEDIAGALLERIES_GETALLMEDIAFILESYSTEMMETADATA) |
| 132 | 132 |
| 133 protected: | 133 protected: |
| 134 virtual ~MediaGalleriesGetAllMediaFileSystemMetadataFunction(); | 134 virtual ~MediaGalleriesGetAllMediaFileSystemMetadataFunction(); |
| 135 virtual bool RunImpl() OVERRIDE; | 135 virtual bool RunAsync() OVERRIDE; |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 // Bottom half for RunImpl, invoked after the preferences is initialized. | 138 // Bottom half for RunAsync, invoked after the preferences is initialized. |
| 139 // Gets the list of permitted galleries and checks if they are available. | 139 // Gets the list of permitted galleries and checks if they are available. |
| 140 void OnPreferencesInit(); | 140 void OnPreferencesInit(); |
| 141 | 141 |
| 142 // Callback to run upon getting the list of available devices. | 142 // Callback to run upon getting the list of available devices. |
| 143 // Sends the list of media filesystem metadata back to the extension. | 143 // Sends the list of media filesystem metadata back to the extension. |
| 144 void OnGetGalleries( | 144 void OnGetGalleries( |
| 145 const MediaGalleryPrefIdSet& permitted_gallery_ids, | 145 const MediaGalleryPrefIdSet& permitted_gallery_ids, |
| 146 const storage_monitor::MediaStorageUtil::DeviceIdSet* available_devices); | 146 const storage_monitor::MediaStorageUtil::DeviceIdSet* available_devices); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 class MediaGalleriesAddUserSelectedFolderFunction | 149 class MediaGalleriesAddUserSelectedFolderFunction |
| 150 : public ChromeAsyncExtensionFunction { | 150 : public ChromeAsyncExtensionFunction { |
| 151 public: | 151 public: |
| 152 DECLARE_EXTENSION_FUNCTION("mediaGalleries.addUserSelectedFolder", | 152 DECLARE_EXTENSION_FUNCTION("mediaGalleries.addUserSelectedFolder", |
| 153 MEDIAGALLERIES_ADDUSERSELECTEDFOLDER) | 153 MEDIAGALLERIES_ADDUSERSELECTEDFOLDER) |
| 154 | 154 |
| 155 protected: | 155 protected: |
| 156 virtual ~MediaGalleriesAddUserSelectedFolderFunction(); | 156 virtual ~MediaGalleriesAddUserSelectedFolderFunction(); |
| 157 virtual bool RunImpl() OVERRIDE; | 157 virtual bool RunAsync() OVERRIDE; |
| 158 | 158 |
| 159 private: | 159 private: |
| 160 // Bottom half for RunImpl, invoked after the preferences is initialized. | 160 // Bottom half for RunAsync, invoked after the preferences is initialized. |
| 161 void OnPreferencesInit(); | 161 void OnPreferencesInit(); |
| 162 | 162 |
| 163 // Callback for the directory prompt request, with the input from the user. | 163 // Callback for the directory prompt request, with the input from the user. |
| 164 // If |selected_directory| is empty, then the user canceled. | 164 // If |selected_directory| is empty, then the user canceled. |
| 165 // Either handle the user canceled case or add the selected gallery. | 165 // Either handle the user canceled case or add the selected gallery. |
| 166 void OnDirectorySelected(const base::FilePath& selected_directory); | 166 void OnDirectorySelected(const base::FilePath& selected_directory); |
| 167 | 167 |
| 168 // Callback for the directory prompt request. |pref_id| is for the gallery | 168 // Callback for the directory prompt request. |pref_id| is for the gallery |
| 169 // the user just added. |filesystems| is the entire list of file systems. | 169 // the user just added. |filesystems| is the entire list of file systems. |
| 170 // The fsid for the file system that corresponds to |pref_id| will be | 170 // The fsid for the file system that corresponds to |pref_id| will be |
| 171 // appended to the list of file systems returned to the caller. The | 171 // appended to the list of file systems returned to the caller. The |
| 172 // Javascript binding for this API will interpret the list appropriately. | 172 // Javascript binding for this API will interpret the list appropriately. |
| 173 void ReturnGalleriesAndId( | 173 void ReturnGalleriesAndId( |
| 174 MediaGalleryPrefId pref_id, | 174 MediaGalleryPrefId pref_id, |
| 175 const std::vector<MediaFileSystemInfo>& filesystems); | 175 const std::vector<MediaFileSystemInfo>& filesystems); |
| 176 | 176 |
| 177 // A helper method that calls | 177 // A helper method that calls |
| 178 // MediaFileSystemRegistry::GetMediaFileSystemsForExtension(). | 178 // MediaFileSystemRegistry::GetMediaFileSystemsForExtension(). |
| 179 void GetMediaFileSystemsForExtension(const MediaFileSystemsCallback& cb); | 179 void GetMediaFileSystemsForExtension(const MediaFileSystemsCallback& cb); |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 class MediaGalleriesDropPermissionForMediaFileSystemFunction | 182 class MediaGalleriesDropPermissionForMediaFileSystemFunction |
| 183 : public ChromeAsyncExtensionFunction { | 183 : public ChromeAsyncExtensionFunction { |
| 184 public: | 184 public: |
| 185 DECLARE_EXTENSION_FUNCTION("mediaGalleries.dropPermissionForMediaFileSystem", | 185 DECLARE_EXTENSION_FUNCTION("mediaGalleries.dropPermissionForMediaFileSystem", |
| 186 MEDIAGALLERIES_DROPPERMISSIONFORMEDIAFILESYSTEM) | 186 MEDIAGALLERIES_DROPPERMISSIONFORMEDIAFILESYSTEM) |
| 187 | 187 |
| 188 protected: | 188 protected: |
| 189 virtual ~MediaGalleriesDropPermissionForMediaFileSystemFunction(); | 189 virtual ~MediaGalleriesDropPermissionForMediaFileSystemFunction(); |
| 190 virtual bool RunImpl() OVERRIDE; | 190 virtual bool RunAsync() OVERRIDE; |
| 191 | 191 |
| 192 private: | 192 private: |
| 193 // Bottom half for RunImpl, invoked after the preferences is initialized. | 193 // Bottom half for RunAsync, invoked after the preferences is initialized. |
| 194 void OnPreferencesInit(MediaGalleryPrefId pref_id); | 194 void OnPreferencesInit(MediaGalleryPrefId pref_id); |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 class MediaGalleriesStartMediaScanFunction | 197 class MediaGalleriesStartMediaScanFunction |
| 198 : public ChromeAsyncExtensionFunction { | 198 : public ChromeAsyncExtensionFunction { |
| 199 public: | 199 public: |
| 200 DECLARE_EXTENSION_FUNCTION("mediaGalleries.startMediaScan", | 200 DECLARE_EXTENSION_FUNCTION("mediaGalleries.startMediaScan", |
| 201 MEDIAGALLERIES_STARTMEDIASCAN) | 201 MEDIAGALLERIES_STARTMEDIASCAN) |
| 202 | 202 |
| 203 protected: | 203 protected: |
| 204 virtual ~MediaGalleriesStartMediaScanFunction(); | 204 virtual ~MediaGalleriesStartMediaScanFunction(); |
| 205 virtual bool RunImpl() OVERRIDE; | 205 virtual bool RunAsync() OVERRIDE; |
| 206 | 206 |
| 207 private: | 207 private: |
| 208 // Bottom half for RunImpl, invoked after the preferences is initialized. | 208 // Bottom half for RunAsync, invoked after the preferences is initialized. |
| 209 void OnPreferencesInit(); | 209 void OnPreferencesInit(); |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 class MediaGalleriesCancelMediaScanFunction | 212 class MediaGalleriesCancelMediaScanFunction |
| 213 : public ChromeAsyncExtensionFunction { | 213 : public ChromeAsyncExtensionFunction { |
| 214 public: | 214 public: |
| 215 DECLARE_EXTENSION_FUNCTION("mediaGalleries.cancelMediaScan", | 215 DECLARE_EXTENSION_FUNCTION("mediaGalleries.cancelMediaScan", |
| 216 MEDIAGALLERIES_CANCELMEDIASCAN) | 216 MEDIAGALLERIES_CANCELMEDIASCAN) |
| 217 | 217 |
| 218 protected: | 218 protected: |
| 219 virtual ~MediaGalleriesCancelMediaScanFunction(); | 219 virtual ~MediaGalleriesCancelMediaScanFunction(); |
| 220 virtual bool RunImpl() OVERRIDE; | 220 virtual bool RunAsync() OVERRIDE; |
| 221 | 221 |
| 222 private: | 222 private: |
| 223 // Bottom half for RunImpl, invoked after the preferences is initialized. | 223 // Bottom half for RunAsync, invoked after the preferences is initialized. |
| 224 void OnPreferencesInit(); | 224 void OnPreferencesInit(); |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 class MediaGalleriesAddScanResultsFunction | 227 class MediaGalleriesAddScanResultsFunction |
| 228 : public ChromeAsyncExtensionFunction { | 228 : public ChromeAsyncExtensionFunction { |
| 229 public: | 229 public: |
| 230 DECLARE_EXTENSION_FUNCTION("mediaGalleries.addScanResults", | 230 DECLARE_EXTENSION_FUNCTION("mediaGalleries.addScanResults", |
| 231 MEDIAGALLERIES_ADDSCANRESULTS) | 231 MEDIAGALLERIES_ADDSCANRESULTS) |
| 232 | 232 |
| 233 protected: | 233 protected: |
| 234 virtual ~MediaGalleriesAddScanResultsFunction(); | 234 virtual ~MediaGalleriesAddScanResultsFunction(); |
| 235 virtual bool RunImpl() OVERRIDE; | 235 virtual bool RunAsync() OVERRIDE; |
| 236 | 236 |
| 237 // Pulled out for testing. | 237 // Pulled out for testing. |
| 238 virtual MediaGalleriesScanResultDialogController* MakeDialog( | 238 virtual MediaGalleriesScanResultDialogController* MakeDialog( |
| 239 content::WebContents* web_contents, | 239 content::WebContents* web_contents, |
| 240 const extensions::Extension& extension, | 240 const extensions::Extension& extension, |
| 241 const base::Closure& on_finish); | 241 const base::Closure& on_finish); |
| 242 | 242 |
| 243 private: | 243 private: |
| 244 // Bottom half for RunImpl, invoked after the preferences is initialized. | 244 // Bottom half for RunAsync, invoked after the preferences is initialized. |
| 245 void OnPreferencesInit(); | 245 void OnPreferencesInit(); |
| 246 | 246 |
| 247 // Grabs galleries from the media file system registry and passes them to | 247 // Grabs galleries from the media file system registry and passes them to |
| 248 // ReturnGalleries(). | 248 // ReturnGalleries(). |
| 249 void GetAndReturnGalleries(); | 249 void GetAndReturnGalleries(); |
| 250 | 250 |
| 251 // Returns galleries to the caller. | 251 // Returns galleries to the caller. |
| 252 void ReturnGalleries(const std::vector<MediaFileSystemInfo>& filesystems); | 252 void ReturnGalleries(const std::vector<MediaFileSystemInfo>& filesystems); |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 class MediaGalleriesGetMetadataFunction : public ChromeAsyncExtensionFunction { | 255 class MediaGalleriesGetMetadataFunction : public ChromeAsyncExtensionFunction { |
| 256 public: | 256 public: |
| 257 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMetadata", | 257 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMetadata", |
| 258 MEDIAGALLERIES_GETMETADATA) | 258 MEDIAGALLERIES_GETMETADATA) |
| 259 | 259 |
| 260 protected: | 260 protected: |
| 261 virtual ~MediaGalleriesGetMetadataFunction(); | 261 virtual ~MediaGalleriesGetMetadataFunction(); |
| 262 virtual bool RunImpl() OVERRIDE; | 262 virtual bool RunAsync() OVERRIDE; |
| 263 | 263 |
| 264 private: | 264 private: |
| 265 // Bottom half for RunImpl, invoked after the preferences is initialized. | 265 // Bottom half for RunAsync, invoked after the preferences is initialized. |
| 266 void OnPreferencesInit(bool mime_type_only, const std::string& blob_uuid); | 266 void OnPreferencesInit(bool mime_type_only, const std::string& blob_uuid); |
| 267 | 267 |
| 268 void SniffMimeType(bool mime_type_only, | 268 void SniffMimeType(bool mime_type_only, |
| 269 const std::string& blob_uuid, | 269 const std::string& blob_uuid, |
| 270 scoped_ptr<std::string> blob_header, | 270 scoped_ptr<std::string> blob_header, |
| 271 int64 total_blob_length); | 271 int64 total_blob_length); |
| 272 | 272 |
| 273 void OnSafeMediaMetadataParserDone( | 273 void OnSafeMediaMetadataParserDone( |
| 274 bool parse_success, base::DictionaryValue* metadata_dictionary); | 274 bool parse_success, base::DictionaryValue* metadata_dictionary); |
| 275 }; | 275 }; |
| 276 | 276 |
| 277 } // namespace extensions | 277 } // namespace extensions |
| 278 | 278 |
| 279 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ | 279 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ |
| OLD | NEW |