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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_
6 #define COMPONENTS_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/threading/thread_local_storage.h"
10 #include "base/timer/timer.h"
11 #include "cc/blink/web_compositor_support_impl.h"
12 #include "components/html_viewer/blink_resource_map.h"
13 #include "components/html_viewer/mock_web_blob_registry_impl.h"
14 #include "components/html_viewer/web_mime_registry_impl.h"
15 #include "components/html_viewer/web_notification_manager_impl.h"
16 #include "components/html_viewer/web_theme_engine_impl.h"
17 #include "components/webcrypto/webcrypto_impl.h"
18 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
19 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
20 #include "third_party/WebKit/public/platform/Platform.h"
21 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h"
24 class RendererScheduler
;
25 class WebThreadImplForRendererScheduler
;
29 class ApplicationImpl
;
32 namespace html_viewer
{
34 class WebClipboardImpl
;
35 class WebCookieJarImpl
;
37 class BlinkPlatformImpl
: public blink::Platform
{
39 // |app| may be null in tests.
40 BlinkPlatformImpl(mojo::ApplicationImpl
* app
,
41 scheduler::RendererScheduler
* renderer_scheduler
);
42 virtual ~BlinkPlatformImpl();
44 // blink::Platform methods:
45 virtual blink::WebCookieJar
* cookieJar();
46 virtual blink::WebClipboard
* clipboard();
47 virtual blink::WebMimeRegistry
* mimeRegistry();
48 virtual blink::WebThemeEngine
* themeEngine();
49 virtual blink::WebString
defaultLocale();
50 virtual blink::WebBlobRegistry
* blobRegistry();
51 virtual double currentTime();
52 virtual double monotonicallyIncreasingTime();
53 virtual void cryptographicallyRandomValues(unsigned char* buffer
,
55 virtual bool isThreadedCompositingEnabled();
56 virtual blink::WebCompositorSupport
* compositorSupport();
57 uint32_t getUniqueIdForProcess() override
;
58 void createMessageChannel(blink::WebMessagePortChannel
** channel1
,
59 blink::WebMessagePortChannel
** channel2
) override
;
60 virtual blink::WebURLLoader
* createURLLoader();
61 virtual blink::WebSocketHandle
* createWebSocketHandle();
62 virtual blink::WebString
userAgent();
63 virtual blink::WebData
parseDataURL(
64 const blink::WebURL
& url
, blink::WebString
& mime_type
,
65 blink::WebString
& charset
);
66 virtual bool isReservedIPAddress(const blink::WebString
& host
) const;
67 virtual blink::WebURLError
cancelledError(const blink::WebURL
& url
) const;
68 virtual blink::WebThread
* createThread(const char* name
);
69 virtual blink::WebThread
* currentThread();
70 virtual void yieldCurrentThread();
71 virtual blink::WebWaitableEvent
* createWaitableEvent();
72 virtual blink::WebWaitableEvent
* waitMultipleEvents(
73 const blink::WebVector
<blink::WebWaitableEvent
*>& events
);
74 virtual blink::WebScrollbarBehavior
* scrollbarBehavior();
75 virtual const unsigned char* getTraceCategoryEnabledFlag(
76 const char* category_name
);
77 virtual blink::WebData
loadResource(const char* name
);
78 virtual blink::WebGestureCurve
* createFlingAnimationCurve(
79 blink::WebGestureDevice device_source
,
80 const blink::WebFloatPoint
& velocity
,
81 const blink::WebSize
& cumulative_scroll
);
82 virtual blink::WebCrypto
* crypto();
83 virtual blink::WebNotificationManager
* notificationManager();
86 void UpdateWebThreadTLS(blink::WebThread
* thread
);
88 static void DestroyCurrentThread(void*);
90 scoped_refptr
<base::SingleThreadTaskRunner
> main_thread_task_runner_
;
91 scoped_ptr
<scheduler::WebThreadImplForRendererScheduler
> main_thread_
;
92 base::ThreadLocalStorage::Slot current_thread_slot_
;
93 cc_blink::WebCompositorSupportImpl compositor_support_
;
94 WebThemeEngineImpl theme_engine_
;
95 WebMimeRegistryImpl mime_registry_
;
96 webcrypto::WebCryptoImpl web_crypto_
;
97 WebNotificationManagerImpl web_notification_manager_
;
98 blink::WebScrollbarBehavior scrollbar_behavior_
;
99 BlinkResourceMap blink_resource_map_
;
100 mojo::NetworkServicePtr network_service_
;
101 mojo::URLLoaderFactoryPtr url_loader_factory_
;
102 MockWebBlobRegistryImpl blob_registry_
;
103 scoped_ptr
<WebCookieJarImpl
> cookie_jar_
;
104 scoped_ptr
<WebClipboardImpl
> clipboard_
;
106 DISALLOW_COPY_AND_ASSIGN(BlinkPlatformImpl
);
109 } // namespace html_viewer
111 #endif // COMPONENTS_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_