1 // Copyright (c) 2010 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 WEBKIT_CLIENT_IMPL_H_ 6 #define WEBKIT_CLIENT_IMPL_H_ 7 8 #include "base/platform_file.h" 9 #include "base/timer.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" 11 #if defined(OS_WIN) 12 #include "webkit/glue/webthemeengine_impl_win.h" 13 #elif defined(OS_LINUX) 14 #include "webkit/glue/webthemeengine_impl_linux.h" 15 #elif defined(OS_MACOSX) 16 #include "webkit/glue/webthemeengine_impl_mac.h" 17 #endif 18 19 20 class MessageLoop; 21 22 namespace webkit_glue { 23 24 class WebKitClientImpl : public WebKit::WebKitClient { 25 public: 26 WebKitClientImpl(); 27 virtual ~WebKitClientImpl(); 28 29 // WebKitClient methods (partial implementation): 30 virtual WebKit::WebThemeEngine* themeEngine(); 31 32 virtual base::PlatformFile databaseOpenFile( 33 const WebKit::WebString& vfs_file_name, int desired_flags); 34 virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name, 35 bool sync_dir); 36 virtual long databaseGetFileAttributes( 37 const WebKit::WebString& vfs_file_name); 38 virtual long long databaseGetFileSize(const WebKit::WebString& vfs_file_name); 39 virtual WebKit::WebString signedPublicKeyAndChallengeString( 40 unsigned key_size_index, const WebKit::WebString& challenge, 41 const WebKit::WebURL& url); 42 virtual size_t memoryUsageMB(); 43 virtual size_t actualMemoryUsageMB(); 44 virtual WebKit::WebURLLoader* createURLLoader(); 45 virtual WebKit::WebSocketStreamHandle* createSocketStreamHandle(); 46 virtual WebKit::WebString userAgent(const WebKit::WebURL& url); 47 virtual void getPluginList(bool refresh, WebKit::WebPluginListBuilder*); 48 virtual void decrementStatsCounter(const char* name); 49 virtual void incrementStatsCounter(const char* name); 50 virtual void histogramCustomCounts( 51 const char* name, int sample, int min, int max, int bucket_count); 52 virtual void histogramEnumeration( 53 const char* name, int sample, int boundary_value); 54 virtual void traceEventBegin(const char* name, void* id, const char* extra); 55 virtual void traceEventEnd(const char* name, void* id, const char* extra); 56 virtual WebKit::WebData loadResource(const char* name); 57 virtual bool loadAudioResource( 58 WebKit::WebAudioBus* destination_bus, const char* audio_file_data, 59 size_t data_size, double sample_rate); 60 virtual WebKit::WebString queryLocalizedString( 61 WebKit::WebLocalizedString::Name name); 62 virtual WebKit::WebString queryLocalizedString( 63 WebKit::WebLocalizedString::Name name, int numeric_value); 64 virtual WebKit::WebString queryLocalizedString( 65 WebKit::WebLocalizedString::Name name, const WebKit::WebString& value); 66 virtual WebKit::WebString queryLocalizedString( 67 WebKit::WebLocalizedString::Name name, 68 const WebKit::WebString& value1, const WebKit::WebString& value2); 69 virtual void suddenTerminationChanged(bool enabled) { } 70 virtual double currentTime(); 71 virtual void cryptographicallyRandomValues( 72 unsigned char* buffer, size_t length); 73 virtual void setSharedTimerFiredFunction(void (*func)()); 74 virtual void setSharedTimerFireTime(double fireTime); 75 virtual void stopSharedTimer(); 76 virtual void callOnMainThread(void (*func)(void*), void* context); 77 78 void SuspendSharedTimer(); 79 void ResumeSharedTimer(); 80 81 // Hack for http://crbug.com/71735. 82 // TODO(jamesr): move this back to the private section once 83 // http://crbug.com/72007 is fixed. 84 void DoTimeout() { 85 if (shared_timer_func_ && !shared_timer_suspended_) 86 shared_timer_func_(); 87 } 88 89 private: 90 MessageLoop* main_loop_; 91 base::OneShotTimer<WebKitClientImpl> shared_timer_; 92 void (*shared_timer_func_)(); 93 double shared_timer_fire_time_; 94 int shared_timer_suspended_; // counter 95 96 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX) 97 WebThemeEngineImpl theme_engine_; 98 #endif 99 }; 100 101 } // namespace webkit_glue 102 103 #endif // WEBKIT_CLIENT_IMPL_H_ 104