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 #include "content/browser/media/cdm/browser_cdm_manager.h" | 5 #include "content/browser/media/cdm/browser_cdm_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 default: | 358 default: |
359 NOTREACHED(); | 359 NOTREACHED(); |
360 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, | 360 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, |
361 "Invalid init data type."); | 361 "Invalid init data type."); |
362 return; | 362 return; |
363 } | 363 } |
364 | 364 |
365 #if defined(OS_ANDROID) | 365 #if defined(OS_ANDROID) |
366 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 366 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
367 switches::kDisableInfobarForProtectedMediaIdentifier)) { | 367 switches::kDisableInfobarForProtectedMediaIdentifier)) { |
368 GenerateRequestIfPermitted(render_frame_id, cdm_id, eme_init_data_type, | 368 GenerateRequestIfPermitted( |
369 init_data, promise.Pass(), true); | 369 render_frame_id, cdm_id, eme_init_data_type, |
| 370 init_data, promise.Pass(), PERMISSION_STATUS_GRANTED); |
370 return; | 371 return; |
371 } | 372 } |
372 #endif | 373 #endif |
373 | 374 |
374 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id); | 375 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id); |
375 if (!cdm) { | 376 if (!cdm) { |
376 DLOG(WARNING) << "No CDM found for: " << render_frame_id << ", " << cdm_id; | 377 DLOG(WARNING) << "No CDM found for: " << render_frame_id << ", " << cdm_id; |
377 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); | 378 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); |
378 return; | 379 return; |
379 } | 380 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 render_frame_id, cdm_id, init_data_type, init_data, | 526 render_frame_id, cdm_id, init_data_type, init_data, |
526 base::Passed(&promise))); | 527 base::Passed(&promise))); |
527 } | 528 } |
528 | 529 |
529 void BrowserCdmManager::GenerateRequestIfPermitted( | 530 void BrowserCdmManager::GenerateRequestIfPermitted( |
530 int render_frame_id, | 531 int render_frame_id, |
531 int cdm_id, | 532 int cdm_id, |
532 media::EmeInitDataType init_data_type, | 533 media::EmeInitDataType init_data_type, |
533 const std::vector<uint8>& init_data, | 534 const std::vector<uint8>& init_data, |
534 scoped_ptr<media::NewSessionCdmPromise> promise, | 535 scoped_ptr<media::NewSessionCdmPromise> promise, |
535 bool permitted) { | 536 PermissionStatus permission) { |
536 cdm_cancel_permission_map_.erase(GetId(render_frame_id, cdm_id)); | 537 cdm_cancel_permission_map_.erase(GetId(render_frame_id, cdm_id)); |
537 if (!permitted) { | 538 if (permission != PERMISSION_STATUS_GRANTED) { |
538 promise->reject(MediaKeys::NOT_SUPPORTED_ERROR, 0, "Permission denied."); | 539 promise->reject(MediaKeys::NOT_SUPPORTED_ERROR, 0, "Permission denied."); |
539 return; | 540 return; |
540 } | 541 } |
541 | 542 |
542 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id); | 543 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id); |
543 if (!cdm) { | 544 if (!cdm) { |
544 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); | 545 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); |
545 return; | 546 return; |
546 } | 547 } |
547 | 548 |
(...skipping 15 matching lines...) Expand all Loading... |
563 } | 564 } |
564 | 565 |
565 // Only the temporary session type is supported in browser CDM path. | 566 // Only the temporary session type is supported in browser CDM path. |
566 // TODO(xhwang): Add SessionType support if needed. | 567 // TODO(xhwang): Add SessionType support if needed. |
567 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, | 568 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, |
568 init_data_type_string, &init_data[0], | 569 init_data_type_string, &init_data[0], |
569 init_data.size(), promise.Pass()); | 570 init_data.size(), promise.Pass()); |
570 } | 571 } |
571 | 572 |
572 } // namespace content | 573 } // namespace content |
OLD | NEW |