OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
| 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" |
| 9 #include "media/base/decrypt_config.h" |
| 10 #include "third_party/WebKit/public/platform/WebString.h" |
| 11 #include "third_party/WebKit/public/platform/WebURL.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 class WebContentDecryptionModuleSessionImpl |
| 16 : public WebKit::WebContentDecryptionModuleSession { |
| 17 public: |
| 18 explicit WebContentDecryptionModuleSessionImpl( |
| 19 WebKit::WebContentDecryptionModuleSession::Client* client); |
| 20 virtual ~WebContentDecryptionModuleSessionImpl(); |
| 21 |
| 22 // WebKit::WebContentDecryptionModuleSession implementation. |
| 23 virtual WebKit::WebString sessionId() const { return session_id_; } |
| 24 virtual void generateKeyRequest(const WebKit::WebString& mime_type, |
| 25 const uint8* init_data, |
| 26 size_t init_data_length); |
| 27 virtual void update(const uint8* key, size_t key_length); |
| 28 virtual void close(); |
| 29 |
| 30 private: |
| 31 WebKit::WebContentDecryptionModuleSession::Client* client_; |
| 32 WebKit::WebString session_id_; |
| 33 |
| 34 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl); |
| 35 }; |
| 36 |
| 37 WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl( |
| 38 WebKit::WebContentDecryptionModuleSession::Client* client) |
| 39 : client_(client) { |
| 40 // TODO(ddorwin): Populate session_id_ from the real implementation. |
| 41 } |
| 42 |
| 43 WebContentDecryptionModuleSessionImpl:: |
| 44 ~WebContentDecryptionModuleSessionImpl() { |
| 45 } |
| 46 |
| 47 void WebContentDecryptionModuleSessionImpl::generateKeyRequest( |
| 48 const WebKit::WebString& mime_type, |
| 49 const uint8* init_data, size_t init_data_length) { |
| 50 // TODO(ddorwin): Call a real implementation and remove stub event triggers. |
| 51 NOTIMPLEMENTED(); |
| 52 client_->keyMessage(NULL, 0, WebKit::WebURL()); |
| 53 } |
| 54 |
| 55 void WebContentDecryptionModuleSessionImpl::update(const uint8* key, |
| 56 size_t key_length) { |
| 57 DCHECK(key); |
| 58 |
| 59 // TODO(ddorwin): Call a real implementation and remove stub event triggers. |
| 60 NOTIMPLEMENTED(); |
| 61 // TODO(ddorwin): Remove when we have a real implementation that passes tests. |
| 62 if (key_length != |
| 63 static_cast<size_t>(media::DecryptConfig::kDecryptionKeySize)) { |
| 64 client_->keyError( |
| 65 WebKit::WebContentDecryptionModuleSession::Client:: |
| 66 MediaKeyErrorCodeUnknown, |
| 67 0); |
| 68 return; |
| 69 } |
| 70 client_->keyAdded(); |
| 71 } |
| 72 |
| 73 void WebContentDecryptionModuleSessionImpl::close() { |
| 74 // TODO(ddorwin): Call a real implementation. |
| 75 NOTIMPLEMENTED(); |
| 76 } |
| 77 |
| 78 //------------------------------------------------------------------------------ |
| 79 |
| 80 WebContentDecryptionModuleImpl* |
| 81 WebContentDecryptionModuleImpl::Create(const string16& key_system) { |
| 82 // TODO(ddorwin): Verify we can create the internal objects & load CDM first. |
| 83 return new WebContentDecryptionModuleImpl(key_system); |
| 84 } |
| 85 |
| 86 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( |
| 87 const string16& key_system) { |
| 88 } |
| 89 |
| 90 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { |
| 91 } |
| 92 |
| 93 WebKit::WebContentDecryptionModuleSession* |
| 94 WebContentDecryptionModuleImpl::createSession( |
| 95 WebKit::WebContentDecryptionModuleSession::Client* client) { |
| 96 return new WebContentDecryptionModuleSessionImpl(client); |
| 97 } |
| 98 |
| 99 } // namespace content |
OLD | NEW |