OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h" | 5 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 bool WidevineCdmComponentInstaller::Install( | 215 bool WidevineCdmComponentInstaller::Install( |
216 const base::DictionaryValue& manifest, | 216 const base::DictionaryValue& manifest, |
217 const base::FilePath& unpack_path) { | 217 const base::FilePath& unpack_path) { |
218 base::Version version; | 218 base::Version version; |
219 if (!CheckWidevineCdmManifest(manifest, &version)) | 219 if (!CheckWidevineCdmManifest(manifest, &version)) |
220 return false; | 220 return false; |
221 if (current_version_.CompareTo(version) > 0) | 221 if (current_version_.CompareTo(version) > 0) |
222 return false; | 222 return false; |
223 | 223 |
224 if (!file_util::PathExists(unpack_path.AppendASCII(kWidevineCdmFileName))) | 224 if (!base::PathExists(unpack_path.AppendASCII(kWidevineCdmFileName))) |
225 return false; | 225 return false; |
226 | 226 |
227 base::FilePath adapter_source_path; | 227 base::FilePath adapter_source_path; |
228 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path); | 228 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path); |
229 if (!file_util::PathExists(adapter_source_path)) | 229 if (!base::PathExists(adapter_source_path)) |
230 return false; | 230 return false; |
231 | 231 |
232 // Passed the basic tests. Time to install it. | 232 // Passed the basic tests. Time to install it. |
233 base::FilePath install_path = | 233 base::FilePath install_path = |
234 GetWidevineCdmBaseDirectory().AppendASCII(version.GetString()); | 234 GetWidevineCdmBaseDirectory().AppendASCII(version.GetString()); |
235 if (file_util::PathExists(install_path)) | 235 if (base::PathExists(install_path)) |
236 return false; | 236 return false; |
237 if (!base::Move(unpack_path, install_path)) | 237 if (!base::Move(unpack_path, install_path)) |
238 return false; | 238 return false; |
239 | 239 |
240 base::FilePath adapter_install_path = | 240 base::FilePath adapter_install_path = |
241 install_path.AppendASCII(kWidevineCdmAdapterFileName); | 241 install_path.AppendASCII(kWidevineCdmAdapterFileName); |
242 if (!base::CopyFile(adapter_source_path, adapter_install_path)) | 242 if (!base::CopyFile(adapter_source_path, adapter_install_path)) |
243 return false; | 243 return false; |
244 | 244 |
245 // Installation is done. Now register the Widevine CDM with chrome. | 245 // Installation is done. Now register the Widevine CDM with chrome. |
(...skipping 28 matching lines...) Expand all Loading... |
274 widevine_cdm.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); | 274 widevine_cdm.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); |
275 if (cus->RegisterComponent(widevine_cdm) != ComponentUpdateService::kOk) { | 275 if (cus->RegisterComponent(widevine_cdm) != ComponentUpdateService::kOk) { |
276 NOTREACHED() << "Widevine CDM component registration failed."; | 276 NOTREACHED() << "Widevine CDM component registration failed."; |
277 return; | 277 return; |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 void StartWidevineCdmUpdateRegistration(ComponentUpdateService* cus) { | 281 void StartWidevineCdmUpdateRegistration(ComponentUpdateService* cus) { |
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
283 base::FilePath base_dir = GetWidevineCdmBaseDirectory(); | 283 base::FilePath base_dir = GetWidevineCdmBaseDirectory(); |
284 if (!file_util::PathExists(base_dir) && | 284 if (!base::PathExists(base_dir) && |
285 !file_util::CreateDirectory(base_dir)) { | 285 !file_util::CreateDirectory(base_dir)) { |
286 NOTREACHED() << "Could not create Widevine CDM directory."; | 286 NOTREACHED() << "Could not create Widevine CDM directory."; |
287 return; | 287 return; |
288 } | 288 } |
289 | 289 |
290 base::FilePath latest_dir; | 290 base::FilePath latest_dir; |
291 base::Version version(kNullVersion); | 291 base::Version version(kNullVersion); |
292 std::vector<base::FilePath> older_dirs; | 292 std::vector<base::FilePath> older_dirs; |
293 | 293 |
294 if (GetWidevineCdmDirectory(&latest_dir, &version, &older_dirs)) { | 294 if (GetWidevineCdmDirectory(&latest_dir, &version, &older_dirs)) { |
295 base::FilePath adapter_path = | 295 base::FilePath adapter_path = |
296 latest_dir.AppendASCII(kWidevineCdmAdapterFileName); | 296 latest_dir.AppendASCII(kWidevineCdmAdapterFileName); |
297 base::FilePath cdm_path = latest_dir.AppendASCII(kWidevineCdmFileName); | 297 base::FilePath cdm_path = latest_dir.AppendASCII(kWidevineCdmFileName); |
298 | 298 |
299 if (file_util::PathExists(adapter_path) && | 299 if (base::PathExists(adapter_path) && |
300 file_util::PathExists(cdm_path)) { | 300 base::PathExists(cdm_path)) { |
301 BrowserThread::PostTask( | 301 BrowserThread::PostTask( |
302 BrowserThread::UI, FROM_HERE, | 302 BrowserThread::UI, FROM_HERE, |
303 base::Bind(&RegisterWidevineCdmWithChrome, adapter_path, version)); | 303 base::Bind(&RegisterWidevineCdmWithChrome, adapter_path, version)); |
304 } else { | 304 } else { |
305 base::Delete(latest_dir, true); | 305 base::Delete(latest_dir, true); |
306 version = base::Version(kNullVersion); | 306 version = base::Version(kNullVersion); |
307 } | 307 } |
308 } | 308 } |
309 | 309 |
310 BrowserThread::PostTask( | 310 BrowserThread::PostTask( |
(...skipping 10 matching lines...) Expand all Loading... |
321 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 321 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
322 | 322 |
323 } // namespace | 323 } // namespace |
324 | 324 |
325 void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { | 325 void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { |
326 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 326 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
327 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 327 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
328 base::Bind(&StartWidevineCdmUpdateRegistration, cus)); | 328 base::Bind(&StartWidevineCdmUpdateRegistration, cus)); |
329 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 329 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
330 } | 330 } |
OLD | NEW |