1 // Copyright (c) 2012 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.
5 #include "base/command_line.h"
6 #include "content/common/child_thread.h"
7 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
8 #include "content/common/socket_stream_dispatcher.h"
9 #include "content/common/webkitplatformsupport_impl.h"
10 #include "content/public/common/content_client.h"
11 #include "content/public/common/content_switches.h"
12 #include "googleurl/src/gurl.h"
13 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
18 WebKitPlatformSupportImpl::OffscreenContextFactory
* g_context_factory
= NULL
;
21 WebKitPlatformSupportImpl::WebKitPlatformSupportImpl() {
24 WebKitPlatformSupportImpl::~WebKitPlatformSupportImpl() {
27 string16
WebKitPlatformSupportImpl::GetLocalizedString(int message_id
) {
28 return content::GetContentClient()->GetLocalizedString(message_id
);
31 base::StringPiece
WebKitPlatformSupportImpl::GetDataResource(
33 ui::ScaleFactor scale_factor
) {
34 return content::GetContentClient()->GetDataResource(resource_id
,
38 void WebKitPlatformSupportImpl::GetPlugins(
39 bool refresh
, std::vector
<webkit::WebPluginInfo
>* plugins
) {
40 // This should not be called except in the renderer.
41 // RendererWebKitPlatformSupportImpl overrides this.
45 webkit_glue::ResourceLoaderBridge
*
46 WebKitPlatformSupportImpl::CreateResourceLoader(
47 const webkit_glue::ResourceLoaderBridge::RequestInfo
& request_info
) {
48 return ChildThread::current()->CreateBridge(request_info
);
51 webkit_glue::WebSocketStreamHandleBridge
*
52 WebKitPlatformSupportImpl::CreateWebSocketBridge(
53 WebKit::WebSocketStreamHandle
* handle
,
54 webkit_glue::WebSocketStreamHandleDelegate
* delegate
) {
55 SocketStreamDispatcher
* dispatcher
=
56 ChildThread::current()->socket_stream_dispatcher();
57 return dispatcher
->CreateBridge(handle
, delegate
);
60 WebKit::WebGraphicsContext3D
*
61 WebKitPlatformSupportImpl::createOffscreenGraphicsContext3D(
62 const WebGraphicsContext3D::Attributes
& attributes
) {
63 if (g_context_factory
)
64 return g_context_factory();
65 // The WebGraphicsContext3DInProcessImpl code path is used for
66 // layout tests (though not through this code) as well as for
67 // debugging and bringing up new ports.
68 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL
)) {
69 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
72 return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
73 GetGpuChannelHostFactory(), attributes
,
74 GURL(attributes
.topDocumentURL
));
79 void WebKitPlatformSupportImpl::SetOffscreenContextFactoryForTest(
80 OffscreenContextFactory factory
) {
81 g_context_factory
= factory
;
84 GpuChannelHostFactory
* WebKitPlatformSupportImpl::GetGpuChannelHostFactory() {
89 } // namespace content