| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_ | |
| 6 #define MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/message_loop/message_loop.h" | |
| 10 #include "base/threading/thread_local_storage.h" | |
| 11 #include "base/timer/timer.h" | |
| 12 #include "cc/blink/web_compositor_support_impl.h" | |
| 13 #include "components/webcrypto/webcrypto_impl.h" | |
| 14 #include "mojo/services/html_viewer/blink_resource_map.h" | |
| 15 #include "mojo/services/html_viewer/mock_web_blob_registry_impl.h" | |
| 16 #include "mojo/services/html_viewer/web_mime_registry_impl.h" | |
| 17 #include "mojo/services/html_viewer/web_notification_manager_impl.h" | |
| 18 #include "mojo/services/html_viewer/web_scheduler_impl.h" | |
| 19 #include "mojo/services/html_viewer/web_theme_engine_impl.h" | |
| 20 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | |
| 21 #include "third_party/WebKit/public/platform/Platform.h" | |
| 22 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h" | |
| 23 | |
| 24 namespace mojo { | |
| 25 class ApplicationImpl; | |
| 26 } | |
| 27 | |
| 28 namespace html_viewer { | |
| 29 | |
| 30 class WebClipboardImpl; | |
| 31 class WebCookieJarImpl; | |
| 32 | |
| 33 class BlinkPlatformImpl : public blink::Platform { | |
| 34 public: | |
| 35 // |app| may be null in tests. | |
| 36 explicit BlinkPlatformImpl(mojo::ApplicationImpl* app); | |
| 37 virtual ~BlinkPlatformImpl(); | |
| 38 | |
| 39 // blink::Platform methods: | |
| 40 virtual blink::WebCookieJar* cookieJar(); | |
| 41 virtual blink::WebClipboard* clipboard(); | |
| 42 virtual blink::WebMimeRegistry* mimeRegistry(); | |
| 43 virtual blink::WebThemeEngine* themeEngine(); | |
| 44 virtual blink::WebScheduler* scheduler(); | |
| 45 virtual blink::WebString defaultLocale(); | |
| 46 virtual blink::WebBlobRegistry* blobRegistry(); | |
| 47 virtual double currentTime(); | |
| 48 virtual double monotonicallyIncreasingTime(); | |
| 49 virtual void cryptographicallyRandomValues(unsigned char* buffer, | |
| 50 size_t length); | |
| 51 virtual void setSharedTimerFiredFunction(void (*func)()); | |
| 52 virtual void setSharedTimerFireInterval(double interval_seconds); | |
| 53 virtual void stopSharedTimer(); | |
| 54 virtual void callOnMainThread(void (*func)(void*), void* context); | |
| 55 virtual bool isThreadedCompositingEnabled(); | |
| 56 virtual blink::WebCompositorSupport* compositorSupport(); | |
| 57 void createMessageChannel(blink::WebMessagePortChannel** channel1, | |
| 58 blink::WebMessagePortChannel** channel2) override; | |
| 59 virtual blink::WebURLLoader* createURLLoader(); | |
| 60 virtual blink::WebSocketHandle* createWebSocketHandle(); | |
| 61 virtual blink::WebString userAgent(); | |
| 62 virtual blink::WebData parseDataURL( | |
| 63 const blink::WebURL& url, blink::WebString& mime_type, | |
| 64 blink::WebString& charset); | |
| 65 virtual bool isReservedIPAddress(const blink::WebString& host) const; | |
| 66 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const; | |
| 67 virtual blink::WebThread* createThread(const char* name); | |
| 68 virtual blink::WebThread* currentThread(); | |
| 69 virtual void yieldCurrentThread(); | |
| 70 virtual blink::WebWaitableEvent* createWaitableEvent(); | |
| 71 virtual blink::WebWaitableEvent* waitMultipleEvents( | |
| 72 const blink::WebVector<blink::WebWaitableEvent*>& events); | |
| 73 virtual blink::WebScrollbarBehavior* scrollbarBehavior(); | |
| 74 virtual const unsigned char* getTraceCategoryEnabledFlag( | |
| 75 const char* category_name); | |
| 76 virtual blink::WebData loadResource(const char* name); | |
| 77 virtual blink::WebGestureCurve* createFlingAnimationCurve( | |
| 78 blink::WebGestureDevice device_source, | |
| 79 const blink::WebFloatPoint& velocity, | |
| 80 const blink::WebSize& cumulative_scroll); | |
| 81 virtual blink::WebCrypto* crypto(); | |
| 82 virtual blink::WebNotificationManager* notificationManager(); | |
| 83 | |
| 84 private: | |
| 85 void SuspendSharedTimer(); | |
| 86 void ResumeSharedTimer(); | |
| 87 | |
| 88 void DoTimeout() { | |
| 89 if (shared_timer_func_ && !shared_timer_suspended_) | |
| 90 shared_timer_func_(); | |
| 91 } | |
| 92 | |
| 93 static void DestroyCurrentThread(void*); | |
| 94 | |
| 95 base::MessageLoop* main_loop_; | |
| 96 base::OneShotTimer<BlinkPlatformImpl> shared_timer_; | |
| 97 void (*shared_timer_func_)(); | |
| 98 double shared_timer_fire_time_; | |
| 99 bool shared_timer_fire_time_was_set_while_suspended_; | |
| 100 int shared_timer_suspended_; // counter | |
| 101 base::ThreadLocalStorage::Slot current_thread_slot_; | |
| 102 cc_blink::WebCompositorSupportImpl compositor_support_; | |
| 103 WebThemeEngineImpl theme_engine_; | |
| 104 WebMimeRegistryImpl mime_registry_; | |
| 105 WebSchedulerImpl scheduler_; | |
| 106 webcrypto::WebCryptoImpl web_crypto_; | |
| 107 WebNotificationManagerImpl web_notification_manager_; | |
| 108 blink::WebScrollbarBehavior scrollbar_behavior_; | |
| 109 BlinkResourceMap blink_resource_map_; | |
| 110 mojo::NetworkServicePtr network_service_; | |
| 111 MockWebBlobRegistryImpl blob_registry_; | |
| 112 scoped_ptr<WebCookieJarImpl> cookie_jar_; | |
| 113 scoped_ptr<WebClipboardImpl> clipboard_; | |
| 114 | |
| 115 DISALLOW_COPY_AND_ASSIGN(BlinkPlatformImpl); | |
| 116 }; | |
| 117 | |
| 118 } // namespace html_viewer | |
| 119 | |
| 120 #endif // MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_ | |
| OLD | NEW |