1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_APPS_PLATFORM_APPS_API_MEDIA_GALLERIES_BLOB_DATA_SOURCE_FACTORY_H_ 6 #define CHROME_BROWSER_APPS_PLATFORM_APPS_API_MEDIA_GALLERIES_BLOB_DATA_SOURCE_FACTORY_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "base/macros.h" 12 #include "chrome/services/media_gallery_util/public/cpp/safe_media_metadata_parser.h" 13 #include "chrome/services/media_gallery_util/public/mojom/media_parser.mojom.h" 14 #include "mojo/public/cpp/bindings/pending_receiver.h" 15 16 namespace content { 17 class BrowserContext; 18 } // namespace content 19 20 namespace chrome_apps { 21 namespace api { 22 23 // Factory to provide media data source for extension media gallery API. 24 // Internally it will read media data from a blob in browser process. 25 class BlobDataSourceFactory 26 : public SafeMediaMetadataParser::MediaDataSourceFactory { 27 public: 28 BlobDataSourceFactory(content::BrowserContext* browser_context, 29 const std::string& blob_uuid); 30 ~BlobDataSourceFactory() override; 31 32 private: 33 // SafeMediaMetadataParser::MediaDataSourceFactory implementation. 34 std::unique_ptr<chrome::mojom::MediaDataSource> CreateMediaDataSource( 35 mojo::PendingReceiver<chrome::mojom::MediaDataSource> receiver, 36 MediaDataCallback media_data_callback) override; 37 38 content::BrowserContext* browser_context_; 39 std::string blob_uuid_; 40 MediaDataCallback callback_; 41 42 DISALLOW_COPY_AND_ASSIGN(BlobDataSourceFactory); 43 }; 44 45 } // namespace api 46 } // namespace chrome_apps 47 48 #endif // CHROME_BROWSER_APPS_PLATFORM_APPS_API_MEDIA_GALLERIES_BLOB_DATA_SOURCE_FACTORY_H_ 49