OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 COMPONENTS_CDM_BROWSER_MEDIA_DRM_STORAGE_IMPL_H_ |
| 6 #define COMPONENTS_CDM_BROWSER_MEDIA_DRM_STORAGE_IMPL_H_ |
| 7 |
| 8 #include "content/public/browser/render_frame_host.h" |
| 9 #include "content/public/browser/web_contents_observer.h" |
| 10 #include "media/mojo/interfaces/media_drm_storage.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" |
| 12 #include "url/origin.h" |
| 13 |
| 14 class PrefRegistrySimple; |
| 15 class PrefService; |
| 16 |
| 17 namespace content { |
| 18 class RenderFrameHost; |
| 19 } |
| 20 |
| 21 namespace cdm { |
| 22 |
| 23 // Implements media::mojom::MediaDrmStorage using PrefService. |
| 24 // This file is located under components/ so that it can be shared by multiple |
| 25 // content embedders (e.g. chrome and chromecast). |
| 26 class MediaDrmStorageImpl final : public media::mojom::MediaDrmStorage, |
| 27 public content::WebContentsObserver { |
| 28 public: |
| 29 static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
| 30 |
| 31 MediaDrmStorageImpl(content::RenderFrameHost* render_frame_host, |
| 32 PrefService* pref_service, |
| 33 const url::Origin& origin, |
| 34 media::mojom::MediaDrmStorageRequest request); |
| 35 ~MediaDrmStorageImpl() final; |
| 36 |
| 37 // media::mojom::MediaDrmStorage implementation. |
| 38 void Initialize(const url::Origin& origin) final; |
| 39 void OnProvisioned(const OnProvisionedCallback& callback) final; |
| 40 void SavePersistentSession( |
| 41 const std::string& session_id, |
| 42 media::mojom::SessionDataPtr session_data, |
| 43 const SavePersistentSessionCallback& callback) final; |
| 44 void LoadPersistentSession( |
| 45 const std::string& session_id, |
| 46 const LoadPersistentSessionCallback& callback) final; |
| 47 void RemovePersistentSession( |
| 48 const std::string& session_id, |
| 49 const RemovePersistentSessionCallback& callback) final; |
| 50 |
| 51 // content::WebContentsObserver implementation. |
| 52 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) final; |
| 53 void DidFinishNavigation(content::NavigationHandle* navigation_handle) final; |
| 54 |
| 55 private: |
| 56 // Stops observing WebContents and delete |this|. |
| 57 void Close(); |
| 58 |
| 59 content::RenderFrameHost* const render_frame_host_ = nullptr; |
| 60 PrefService* const pref_service_ = nullptr; |
| 61 const url::Origin origin_; |
| 62 bool initialized_ = false; |
| 63 |
| 64 mojo::Binding<media::mojom::MediaDrmStorage> binding_; |
| 65 }; |
| 66 |
| 67 } // namespace cdm |
| 68 |
| 69 #endif // COMPONENTS_CDM_BROWSER_MEDIA_DRM_STORAGE_IMPL_H_ |
OLD | NEW |