| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 bool WidevineCdmComponentInstaller::Install( | 211 bool WidevineCdmComponentInstaller::Install( |
| 212 const base::DictionaryValue& manifest, | 212 const base::DictionaryValue& manifest, |
| 213 const base::FilePath& unpack_path) { | 213 const base::FilePath& unpack_path) { |
| 214 base::Version version; | 214 base::Version version; |
| 215 if (!CheckWidevineCdmManifest(manifest, &version)) | 215 if (!CheckWidevineCdmManifest(manifest, &version)) |
| 216 return false; | 216 return false; |
| 217 if (current_version_.CompareTo(version) > 0) | 217 if (current_version_.CompareTo(version) > 0) |
| 218 return false; | 218 return false; |
| 219 | 219 |
| 220 if (!file_util::PathExists(unpack_path.Append(kWidevineCdmFileName))) | 220 if (!file_util::PathExists(unpack_path.AppendASCII(kWidevineCdmFileName))) |
| 221 return false; | 221 return false; |
| 222 | 222 |
| 223 base::FilePath adapter_source_path; | 223 base::FilePath adapter_source_path; |
| 224 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path); | 224 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path); |
| 225 if (!file_util::PathExists(adapter_source_path)) | 225 if (!file_util::PathExists(adapter_source_path)) |
| 226 return false; | 226 return false; |
| 227 | 227 |
| 228 // Passed the basic tests. Time to install it. | 228 // Passed the basic tests. Time to install it. |
| 229 base::FilePath install_path = | 229 base::FilePath install_path = |
| 230 GetWidevineCdmBaseDirectory().AppendASCII(version.GetString()); | 230 GetWidevineCdmBaseDirectory().AppendASCII(version.GetString()); |
| 231 if (file_util::PathExists(install_path)) | 231 if (file_util::PathExists(install_path)) |
| 232 return false; | 232 return false; |
| 233 if (!file_util::Move(unpack_path, install_path)) | 233 if (!file_util::Move(unpack_path, install_path)) |
| 234 return false; | 234 return false; |
| 235 | 235 |
| 236 base::FilePath adapter_install_path = | 236 base::FilePath adapter_install_path = |
| 237 install_path.Append(kWidevineCdmAdapterFileName); | 237 install_path.AppendASCII(kWidevineCdmAdapterFileName); |
| 238 if (!file_util::CopyFile(adapter_source_path, adapter_install_path)) | 238 if (!file_util::CopyFile(adapter_source_path, adapter_install_path)) |
| 239 return false; | 239 return false; |
| 240 | 240 |
| 241 // Installation is done. Now register the Widevine CDM with chrome. | 241 // Installation is done. Now register the Widevine CDM with chrome. |
| 242 current_version_ = version; | 242 current_version_ = version; |
| 243 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 243 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 244 &RegisterWidevineCdmWithChrome, adapter_install_path, version)); | 244 &RegisterWidevineCdmWithChrome, adapter_install_path, version)); |
| 245 return true; | 245 return true; |
| 246 } | 246 } |
| 247 | 247 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 264 base::FilePath path = GetWidevineCdmBaseDirectory(); | 264 base::FilePath path = GetWidevineCdmBaseDirectory(); |
| 265 if (!file_util::PathExists(path) && !file_util::CreateDirectory(path)) { | 265 if (!file_util::PathExists(path) && !file_util::CreateDirectory(path)) { |
| 266 NOTREACHED() << "Could not create Widevine CDM directory."; | 266 NOTREACHED() << "Could not create Widevine CDM directory."; |
| 267 return; | 267 return; |
| 268 } | 268 } |
| 269 | 269 |
| 270 base::Version version(kNullVersion); | 270 base::Version version(kNullVersion); |
| 271 std::vector<base::FilePath> older_dirs; | 271 std::vector<base::FilePath> older_dirs; |
| 272 if (GetWidevineCdmDirectory(&path, &version, &older_dirs)) { | 272 if (GetWidevineCdmDirectory(&path, &version, &older_dirs)) { |
| 273 if (file_util::PathExists(path.Append(kWidevineCdmAdapterFileName)) && | 273 if (file_util::PathExists(path.AppendASCII(kWidevineCdmAdapterFileName)) && |
| 274 file_util::PathExists(path.Append(kWidevineCdmFileName))) { | 274 file_util::PathExists(path.AppendASCII(kWidevineCdmFileName))) { |
| 275 BrowserThread::PostTask( | 275 BrowserThread::PostTask( |
| 276 BrowserThread::UI, FROM_HERE, | 276 BrowserThread::UI, FROM_HERE, |
| 277 base::Bind(&RegisterWidevineCdmWithChrome, path, version)); | 277 base::Bind(&RegisterWidevineCdmWithChrome, path, version)); |
| 278 } else { | 278 } else { |
| 279 file_util::Delete(path, true); | 279 file_util::Delete(path, true); |
| 280 version = base::Version(kNullVersion); | 280 version = base::Version(kNullVersion); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 BrowserThread::PostTask( | 284 BrowserThread::PostTask( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 295 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 295 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 296 | 296 |
| 297 } // namespace | 297 } // namespace |
| 298 | 298 |
| 299 void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { | 299 void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { |
| 300 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 300 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 301 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 301 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 302 base::Bind(&StartWidevineCdmUpdateRegistration, cus)); | 302 base::Bind(&StartWidevineCdmUpdateRegistration, cus)); |
| 303 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 303 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 304 } | 304 } |
| OLD | NEW |