| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 6 #define CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 int cdm_id, | 137 int cdm_id, |
| 138 const std::string& key_system, | 138 const std::string& key_system, |
| 139 const GURL& security_origin); | 139 const GURL& security_origin); |
| 140 | 140 |
| 141 // Removes all CDMs associated with |render_frame_id|. | 141 // Removes all CDMs associated with |render_frame_id|. |
| 142 void RemoveAllCdmForFrame(int render_frame_id); | 142 void RemoveAllCdmForFrame(int render_frame_id); |
| 143 | 143 |
| 144 // Removes the CDM with the specified id. | 144 // Removes the CDM with the specified id. |
| 145 void RemoveCdm(uint64 id); | 145 void RemoveCdm(uint64 id); |
| 146 | 146 |
| 147 // Requests permission for the given protected-media session (infobar). | 147 // Checks protected media identifier permission for the given |
| 148 void RequestSessionPermission( | 148 // |render_frame_id|, |security_origin| and |cdm_id|. |
| 149 int render_frame_id, | 149 // |promise| will always be resolved or rejected on the |task_runner_|. |
| 150 const GURL& security_origin, | 150 void CheckPermissionStatus(int render_frame_id, |
| 151 int cdm_id, | 151 const GURL& security_origin, |
| 152 media::EmeInitDataType init_data_type, | 152 int cdm_id, |
| 153 const std::vector<uint8>& init_data, | 153 media::EmeInitDataType init_data_type, |
| 154 scoped_ptr<media::NewSessionCdmPromise> promise); | 154 const std::vector<uint8>& init_data, |
| 155 scoped_ptr<media::NewSessionCdmPromise> promise); |
| 155 | 156 |
| 156 // If |permitted| is false, it does nothing but send | 157 // If |permitted_status| is not "granted", |promise| will be rejected. |
| 157 // |CdmMsg_LegacySessionError| IPC message. | 158 // Otherwise, call CreateSessionAndGenerateRequest() on the CDM. |
| 158 // The primary use case is infobar permission callback, i.e., when infobar | 159 // |promise| will always be resolved or rejected on the |task_runner_|. |
| 159 // can decide user's intention either from interacting with the actual info | 160 void CreateSessionAndGenerateRequest( |
| 160 // bar or from the saved preference. | |
| 161 void GenerateRequestIfPermitted( | |
| 162 int render_frame_id, | 161 int render_frame_id, |
| 163 int cdm_id, | 162 int cdm_id, |
| 164 media::EmeInitDataType init_data_type, | 163 media::EmeInitDataType init_data_type, |
| 165 const std::vector<uint8>& init_data, | 164 const std::vector<uint8>& init_data, |
| 166 scoped_ptr<media::NewSessionCdmPromise> promise, | 165 scoped_ptr<media::NewSessionCdmPromise> promise, |
| 167 PermissionStatus permission); | 166 PermissionStatus permission_status); |
| 168 | 167 |
| 169 const int render_process_id_; | 168 const int render_process_id_; |
| 170 | 169 |
| 171 // TaskRunner to dispatch all CDM messages to. If it's NULL, all messages are | 170 // TaskRunner to dispatch all CDM messages to. If it's NULL, all messages are |
| 172 // dispatched to the browser UI thread. | 171 // dispatched to the browser UI thread. |
| 173 scoped_refptr<base::TaskRunner> task_runner_; | 172 scoped_refptr<base::TaskRunner> task_runner_; |
| 174 | 173 |
| 175 // The key in the following maps is a combination of |render_frame_id| and | 174 // The key in the following maps is a combination of |render_frame_id| and |
| 176 // |cdm_id|. | 175 // |cdm_id|. |
| 177 | 176 |
| 178 // Map of managed BrowserCdms. | 177 // Map of managed BrowserCdms. |
| 179 typedef base::ScopedPtrHashMap<uint64, media::BrowserCdm> CdmMap; | 178 typedef base::ScopedPtrHashMap<uint64, media::BrowserCdm> CdmMap; |
| 180 CdmMap cdm_map_; | 179 CdmMap cdm_map_; |
| 181 | 180 |
| 182 // Map of CDM's security origin. | 181 // Map of CDM's security origin. |
| 183 std::map<uint64, GURL> cdm_security_origin_map_; | 182 std::map<uint64, GURL> cdm_security_origin_map_; |
| 184 | 183 |
| 185 // Map of callbacks to cancel the permission request. | |
| 186 std::map<uint64, base::Closure> cdm_cancel_permission_map_; | |
| 187 | |
| 188 base::WeakPtrFactory<BrowserCdmManager> weak_ptr_factory_; | 184 base::WeakPtrFactory<BrowserCdmManager> weak_ptr_factory_; |
| 189 | 185 |
| 190 DISALLOW_COPY_AND_ASSIGN(BrowserCdmManager); | 186 DISALLOW_COPY_AND_ASSIGN(BrowserCdmManager); |
| 191 }; | 187 }; |
| 192 | 188 |
| 193 } // namespace content | 189 } // namespace content |
| 194 | 190 |
| 195 #endif // CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 191 #endif // CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
| OLD | NEW |