Commit 0744c458 authored by jrummell@chromium.org's avatar jrummell@chromium.org

Moving creation of WebContentDecryptionModule from Platform to public/web.

This is done in order to get the origin and WebFrame needed to create the
CDM. This is now similar to how WebMediaPlayer is created. This change adds
a Page supplement for MediaKeys to enable this.

BUG=250049, 353324
TEST=EME content tests pass (plus disabled ECK browser tests now pass)

Review URL: https://codereview.chromium.org/195053004

git-svn-id: svn://svn.chromium.org/blink/trunk@169797 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8ad8103c
......@@ -28,10 +28,13 @@
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ContextLifecycleObserver.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "core/events/ThreadLocalEventNames.h"
#include "core/html/HTMLMediaElement.h"
#include "modules/encryptedmedia/MediaKeyMessageEvent.h"
#include "modules/encryptedmedia/MediaKeysClient.h"
#include "modules/encryptedmedia/MediaKeysController.h"
#include "platform/ContentType.h"
#include "platform/Logging.h"
#include "platform/MIMETypeRegistry.h"
......@@ -70,7 +73,9 @@ PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(ExecutionContext* context, c
// 3. Let cdm be the content decryption module corresponding to keySystem.
// 4. Load cdm if necessary.
OwnPtr<blink::WebContentDecryptionModule> cdm = adoptPtr(blink::Platform::current()->createContentDecryptionModule(keySystem));
Document* document = toDocument(context);
MediaKeysController* controller = MediaKeysController::from(document->page());
OwnPtr<blink::WebContentDecryptionModule> cdm = controller->createContentDecryptionModule(context, keySystem);
if (!cdm) {
exceptionState.throwDOMException(NotSupportedError, "A content decryption module could not be loaded for the '" + keySystem + "' key system.");
return nullptr;
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MediaKeysClient_h
#define MediaKeysClient_h
#include "wtf/PassOwnPtr.h"
#include "wtf/text/WTFString.h"
namespace blink {
class WebContentDecryptionModule;
}
namespace WebCore {
class ExecutionContext;
class Page;
class MediaKeysClient {
public:
virtual PassOwnPtr<blink::WebContentDecryptionModule> createContentDecryptionModule(ExecutionContext*, const String& keySystem) = 0;
protected:
virtual ~MediaKeysClient() { }
};
void provideMediaKeysTo(Page&, MediaKeysClient*);
} // namespace WebCore
#endif // MediaKeysClient_h
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "modules/encryptedmedia/MediaKeysController.h"
#include "modules/encryptedmedia/MediaKeysClient.h"
#include "public/platform/WebContentDecryptionModule.h"
namespace WebCore {
const char* MediaKeysController::supplementName()
{
return "MediaKeysController";
}
MediaKeysController::MediaKeysController(MediaKeysClient* client)
: m_client(client)
{
}
MediaKeysController::~MediaKeysController()
{
}
PassOwnPtr<blink::WebContentDecryptionModule> MediaKeysController::createContentDecryptionModule(ExecutionContext* context, const String& keySystem)
{
return m_client->createContentDecryptionModule(context, keySystem);
}
void MediaKeysController::provideMediaKeysTo(Page& page, MediaKeysClient* client)
{
MediaKeysController::provideTo(page, supplementName(), adoptPtr(new MediaKeysController(client)));
}
} // namespace WebCore
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MediaKeysController_h
#define MediaKeysController_h
#include "core/page/Page.h"
#include "wtf/PassOwnPtr.h"
namespace blink {
class WebContentDecryptionModule;
}
namespace WebCore {
class ExecutionContext;
class MediaKeysClient;
class MediaKeysController FINAL : public Supplement<Page> {
public:
virtual ~MediaKeysController();
PassOwnPtr<blink::WebContentDecryptionModule> createContentDecryptionModule(ExecutionContext*, const String& keySystem);
static void provideMediaKeysTo(Page&, MediaKeysClient*);
static MediaKeysController* from(Page* page) { return static_cast<MediaKeysController*>(Supplement<Page>::from(page, supplementName())); }
private:
explicit MediaKeysController(MediaKeysClient*);
static const char* supplementName();
MediaKeysClient* m_client;
};
} // namespace WebCore
#endif // MediaKeysController_h
......@@ -296,6 +296,9 @@
'encryptedmedia/MediaKeyNeededEvent.h',
'encryptedmedia/MediaKeys.cpp',
'encryptedmedia/MediaKeys.h',
'encryptedmedia/MediaKeysClient.h',
'encryptedmedia/MediaKeysController.cpp',
'encryptedmedia/MediaKeysController.h',
'encryptedmedia/MediaKeySession.cpp',
'encryptedmedia/MediaKeySession.h',
'filesystem/DOMFilePath.cpp',
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "MediaKeysClientImpl.h"
#include "WebFrameClient.h"
#include "WebFrameImpl.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "public/platform/WebContentDecryptionModule.h"
using namespace WebCore;
namespace blink {
MediaKeysClientImpl::MediaKeysClientImpl()
{
}
PassOwnPtr<WebContentDecryptionModule> MediaKeysClientImpl::createContentDecryptionModule(WebCore::ExecutionContext* executionContext, const String& keySystem)
{
Document* document = toDocument(executionContext);
WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
WebSecurityOrigin securityOrigin(executionContext->securityOrigin());
return adoptPtr(webFrame->client()->createContentDecryptionModule(webFrame, securityOrigin, keySystem));
}
} // namespace blink
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MediaKeysClientImpl_h
#define MediaKeysClientImpl_h
#include "modules/encryptedmedia/MediaKeysClient.h"
#include "wtf/PassOwnPtr.h"
namespace blink {
class WebContentDecryptionModule;
class WebViewImpl;
class MediaKeysClientImpl FINAL : public WebCore::MediaKeysClient {
public:
MediaKeysClientImpl();
// WebCore::MediaKeysClient implementation.
virtual PassOwnPtr<WebContentDecryptionModule> createContentDecryptionModule(WebCore::ExecutionContext*, const String& keySystem) OVERRIDE;
};
} // namespace blink
#endif // MediaKeysClientImpl_h
......@@ -118,6 +118,7 @@
#include "core/rendering/TextAutosizer.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "modules/device_orientation/DeviceOrientationInspectorAgent.h"
#include "modules/encryptedmedia/MediaKeysController.h"
#include "modules/geolocation/GeolocationController.h"
#include "modules/indexeddb/InspectorIndexedDBAgent.h"
#include "modules/notifications/NotificationController.h"
......@@ -388,6 +389,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
m_page = adoptPtr(new Page(pageClients));
provideUserMediaTo(*m_page, &m_userMediaClientImpl);
MediaKeysController::provideMediaKeysTo(*m_page, &m_mediaKeysClientImpl);
provideMIDITo(*m_page, m_midiClientProxy.get());
#if ENABLE(INPUT_SPEECH)
provideSpeechInputTo(*m_page, m_speechInputClient.get());
......
......@@ -37,6 +37,7 @@
#include "DragClientImpl.h"
#include "EditorClientImpl.h"
#include "InspectorClientImpl.h"
#include "MediaKeysClientImpl.h"
#include "NotificationPresenterImpl.h"
#include "PageOverlayList.h"
#include "PageScaleConstraintsSet.h"
......@@ -748,6 +749,7 @@ private:
OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
UserMediaClientImpl m_userMediaClientImpl;
MediaKeysClientImpl m_mediaKeysClientImpl;
OwnPtr<MIDIClientProxy> m_midiClientProxy;
OwnPtr<NavigatorContentUtilsClientImpl> m_navigatorContentUtilsClient;
OwnPtr<WebActiveGestureAnimation> m_gestureAnimation;
......
......@@ -53,6 +53,8 @@
'LinkHighlight.h',
'LocalFileSystemClient.cpp',
'LocalFileSystemClient.h',
'MediaKeysClientImpl.cpp',
'MediaKeysClientImpl.h',
'MIDIClientProxy.cpp',
'MIDIClientProxy.h',
'NotificationPresenterImpl.cpp',
......
......@@ -53,6 +53,7 @@ namespace blink {
class WebApplicationCacheHost;
class WebApplicationCacheHostClient;
class WebCachedURLRequest;
class WebContentDecryptionModule;
class WebCookieJar;
class WebDataSource;
class WebDOMEvent;
......@@ -89,6 +90,9 @@ public:
// May return null.
virtual WebMediaPlayer* createMediaPlayer(WebLocalFrame*, const WebURL&, WebMediaPlayerClient*) { return 0; }
// May return null.
virtual WebContentDecryptionModule* createContentDecryptionModule(WebLocalFrame*, const WebSecurityOrigin&, const WebString& keySystem) { return 0; }
// May return null.
virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*, WebApplicationCacheHostClient*) { return 0; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment