OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_PLATFORM_SUPPORT_IMPL_H_ | 5 #ifndef WEBKIT_PLATFORM_SUPPORT_IMPL_H_ |
6 #define WEBKIT_PLATFORM_SUPPORT_IMPL_H_ | 6 #define WEBKIT_PLATFORM_SUPPORT_IMPL_H_ |
7 | 7 |
8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
9 #include "base/threading/thread_local_storage.h" | 9 #include "base/threading/thread_local_storage.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport
.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport
.h" |
| 12 #include "webkit/glue/resource_loader_bridge.h" |
12 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
13 #include "webkit/glue/webthemeengine_impl_win.h" | 14 #include "webkit/glue/webthemeengine_impl_win.h" |
14 #elif defined(OS_MACOSX) | 15 #elif defined(OS_MACOSX) |
15 #include "webkit/glue/webthemeengine_impl_mac.h" | 16 #include "webkit/glue/webthemeengine_impl_mac.h" |
16 #elif defined(OS_POSIX) | 17 #elif defined(OS_POSIX) |
17 #include "webkit/glue/webthemeengine_impl_linux.h" | 18 #include "webkit/glue/webthemeengine_impl_linux.h" |
18 #endif | 19 #endif |
19 | 20 |
20 | 21 |
21 class MessageLoop; | 22 class MessageLoop; |
22 | 23 |
| 24 namespace webkit { |
| 25 struct WebPluginInfo; |
| 26 } |
| 27 |
| 28 namespace WebKit { |
| 29 class WebSocketStreamHandle; |
| 30 } |
| 31 |
23 namespace webkit_glue { | 32 namespace webkit_glue { |
24 | 33 |
| 34 class WebSocketStreamHandleDelegate; |
| 35 class WebSocketStreamHandleBridge; |
| 36 |
25 class WebKitPlatformSupportImpl : public WebKit::WebKitPlatformSupport { | 37 class WebKitPlatformSupportImpl : public WebKit::WebKitPlatformSupport { |
26 public: | 38 public: |
27 WebKitPlatformSupportImpl(); | 39 WebKitPlatformSupportImpl(); |
28 virtual ~WebKitPlatformSupportImpl(); | 40 virtual ~WebKitPlatformSupportImpl(); |
29 | 41 |
30 // WebKitPlatformSupport methods (partial implementation): | 42 // WebKitPlatformSupport methods (partial implementation): |
31 virtual WebKit::WebThemeEngine* themeEngine(); | 43 virtual WebKit::WebThemeEngine* themeEngine(); |
32 | 44 |
33 virtual base::PlatformFile databaseOpenFile( | 45 virtual base::PlatformFile databaseOpenFile( |
34 const WebKit::WebString& vfs_file_name, int desired_flags); | 46 const WebKit::WebString& vfs_file_name, int desired_flags); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 virtual double monotonicallyIncreasingTime(); | 87 virtual double monotonicallyIncreasingTime(); |
76 virtual void cryptographicallyRandomValues( | 88 virtual void cryptographicallyRandomValues( |
77 unsigned char* buffer, size_t length); | 89 unsigned char* buffer, size_t length); |
78 virtual void setSharedTimerFiredFunction(void (*func)()); | 90 virtual void setSharedTimerFiredFunction(void (*func)()); |
79 virtual void setSharedTimerFireInterval(double interval_seconds); | 91 virtual void setSharedTimerFireInterval(double interval_seconds); |
80 virtual void stopSharedTimer(); | 92 virtual void stopSharedTimer(); |
81 virtual void callOnMainThread(void (*func)(void*), void* context); | 93 virtual void callOnMainThread(void (*func)(void*), void* context); |
82 virtual WebKit::WebThread* createThread(const char* name); | 94 virtual WebKit::WebThread* createThread(const char* name); |
83 virtual WebKit::WebThread* currentThread(); | 95 virtual WebKit::WebThread* currentThread(); |
84 | 96 |
| 97 |
| 98 // Embedder functions. The following are not implemented by the glue layer and |
| 99 // need to be specialized by the embedder. |
| 100 |
| 101 // Gets a localized string given a message id. Returns an empty string if the |
| 102 // message id is not found. |
| 103 virtual string16 GetLocalizedString(int message_id) = 0; |
| 104 |
| 105 // Returns the raw data for a resource. This resource must have been |
| 106 // specified as BINDATA in the relevant .rc file. |
| 107 virtual base::StringPiece GetDataResource(int resource_id) = 0; |
| 108 |
| 109 // Returns the list of plugins. |
| 110 virtual void GetPlugins(bool refresh, |
| 111 std::vector<webkit::WebPluginInfo>* plugins) = 0; |
| 112 // Creates a ResourceLoaderBridge. |
| 113 virtual ResourceLoaderBridge* CreateResourceLoader( |
| 114 const ResourceLoaderBridge::RequestInfo& request_info) = 0; |
| 115 // Creates a WebSocketStreamHandleBridge. |
| 116 virtual WebSocketStreamHandleBridge* CreateWebSocketBridge( |
| 117 WebKit::WebSocketStreamHandle* handle, |
| 118 WebSocketStreamHandleDelegate* delegate) = 0; |
| 119 |
85 void SuspendSharedTimer(); | 120 void SuspendSharedTimer(); |
86 void ResumeSharedTimer(); | 121 void ResumeSharedTimer(); |
87 | 122 |
88 private: | 123 private: |
89 void DoTimeout() { | 124 void DoTimeout() { |
90 if (shared_timer_func_ && !shared_timer_suspended_) | 125 if (shared_timer_func_ && !shared_timer_suspended_) |
91 shared_timer_func_(); | 126 shared_timer_func_(); |
92 } | 127 } |
93 static void DestroyCurrentThread(void*); | 128 static void DestroyCurrentThread(void*); |
94 | 129 |
95 MessageLoop* main_loop_; | 130 MessageLoop* main_loop_; |
96 base::OneShotTimer<WebKitPlatformSupportImpl> shared_timer_; | 131 base::OneShotTimer<WebKitPlatformSupportImpl> shared_timer_; |
97 void (*shared_timer_func_)(); | 132 void (*shared_timer_func_)(); |
98 double shared_timer_fire_time_; | 133 double shared_timer_fire_time_; |
99 int shared_timer_suspended_; // counter | 134 int shared_timer_suspended_; // counter |
100 WebThemeEngineImpl theme_engine_; | 135 WebThemeEngineImpl theme_engine_; |
101 base::ThreadLocalStorage::Slot current_thread_slot_; | 136 base::ThreadLocalStorage::Slot current_thread_slot_; |
102 }; | 137 }; |
103 | 138 |
104 } // namespace webkit_glue | 139 } // namespace webkit_glue |
105 | 140 |
106 #endif // WEBKIT_PLATFORM_SUPPORT_IMPL_H_ | 141 #endif // WEBKIT_PLATFORM_SUPPORT_IMPL_H_ |
OLD | NEW |