| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "webkit/glue/webkitplatformsupport_impl.h" | 5 #include "webkit/glue/webkitplatformsupport_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 25 #include "base/synchronization/lock.h" | 25 #include "base/synchronization/lock.h" |
| 26 #include "base/sys_info.h" | 26 #include "base/sys_info.h" |
| 27 #include "base/time.h" | 27 #include "base/time.h" |
| 28 #include "grit/webkit_chromium_resources.h" | 28 #include "grit/webkit_chromium_resources.h" |
| 29 #include "grit/webkit_resources.h" | 29 #include "grit/webkit_resources.h" |
| 30 #include "grit/webkit_strings.h" | 30 #include "grit/webkit_strings.h" |
| 31 #include "net/base/data_url.h" | 31 #include "net/base/data_url.h" |
| 32 #include "net/base/mime_util.h" | 32 #include "net/base/mime_util.h" |
| 33 #include "net/base/net_errors.h" | 33 #include "net/base/net_errors.h" |
| 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
| 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 34 #include "third_party/WebKit/public/platform/WebCookie.h" | 37 #include "third_party/WebKit/public/platform/WebCookie.h" |
| 35 #include "third_party/WebKit/public/platform/WebData.h" | 38 #include "third_party/WebKit/public/platform/WebData.h" |
| 36 #include "third_party/WebKit/public/platform/WebDiscardableMemory.h" | 39 #include "third_party/WebKit/public/platform/WebDiscardableMemory.h" |
| 37 #include "third_party/WebKit/public/platform/WebGestureCurve.h" | 40 #include "third_party/WebKit/public/platform/WebGestureCurve.h" |
| 38 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 41 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
| 39 #include "third_party/WebKit/public/platform/WebString.h" | 42 #include "third_party/WebKit/public/platform/WebString.h" |
| 40 #include "third_party/WebKit/public/platform/WebURL.h" | 43 #include "third_party/WebKit/public/platform/WebURL.h" |
| 41 #include "third_party/WebKit/public/platform/WebVector.h" | 44 #include "third_party/WebKit/public/platform/WebVector.h" |
| 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | |
| 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
| 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | |
| 45 #include "ui/base/layout.h" | 45 #include "ui/base/layout.h" |
| 46 #include "webkit/base/file_path_string_conversions.h" | 46 #include "webkit/base/file_path_string_conversions.h" |
| 47 #include "webkit/common/user_agent/user_agent.h" | 47 #include "webkit/common/user_agent/user_agent.h" |
| 48 #include "webkit/glue/fling_curve_configuration.h" | |
| 49 #include "webkit/glue/touch_fling_gesture_curve.h" | 48 #include "webkit/glue/touch_fling_gesture_curve.h" |
| 50 #include "webkit/glue/web_discardable_memory_impl.h" | 49 #include "webkit/glue/web_discardable_memory_impl.h" |
| 51 #include "webkit/glue/webkit_glue.h" | 50 #include "webkit/glue/webkit_glue.h" |
| 52 #include "webkit/glue/websocketstreamhandle_impl.h" | 51 #include "webkit/glue/websocketstreamhandle_impl.h" |
| 53 #include "webkit/glue/webthread_impl.h" | 52 #include "webkit/glue/webthread_impl.h" |
| 54 #include "webkit/glue/weburlloader_impl.h" | 53 #include "webkit/glue/weburlloader_impl.h" |
| 55 #include "webkit/glue/worker_task_runner.h" | 54 #include "webkit/glue/worker_task_runner.h" |
| 56 #include "webkit/plugins/npapi/plugin_instance.h" | 55 #include "webkit/plugins/npapi/plugin_instance.h" |
| 57 #include "webkit/plugins/webplugininfo.h" | 56 #include "webkit/plugins/webplugininfo.h" |
| 58 #include "webkit/renderer/media/audio_decoder.h" | 57 #include "webkit/renderer/media/audio_decoder.h" |
| 59 | 58 |
| 60 #if defined(OS_ANDROID) | |
| 61 #include "webkit/glue/fling_animator_impl_android.h" | |
| 62 #endif | |
| 63 | |
| 64 using WebKit::WebAudioBus; | 59 using WebKit::WebAudioBus; |
| 65 using WebKit::WebCookie; | 60 using WebKit::WebCookie; |
| 66 using WebKit::WebData; | 61 using WebKit::WebData; |
| 67 using WebKit::WebFallbackThemeEngine; | 62 using WebKit::WebFallbackThemeEngine; |
| 68 using WebKit::WebLocalizedString; | 63 using WebKit::WebLocalizedString; |
| 69 using WebKit::WebPluginListBuilder; | 64 using WebKit::WebPluginListBuilder; |
| 70 using WebKit::WebString; | 65 using WebKit::WebString; |
| 71 using WebKit::WebSocketStreamHandle; | 66 using WebKit::WebSocketStreamHandle; |
| 72 using WebKit::WebThemeEngine; | 67 using WebKit::WebThemeEngine; |
| 73 using WebKit::WebURL; | 68 using WebKit::WebURL; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 } | 361 } |
| 367 return -1; | 362 return -1; |
| 368 } | 363 } |
| 369 | 364 |
| 370 WebKitPlatformSupportImpl::WebKitPlatformSupportImpl() | 365 WebKitPlatformSupportImpl::WebKitPlatformSupportImpl() |
| 371 : main_loop_(base::MessageLoop::current()), | 366 : main_loop_(base::MessageLoop::current()), |
| 372 shared_timer_func_(NULL), | 367 shared_timer_func_(NULL), |
| 373 shared_timer_fire_time_(0.0), | 368 shared_timer_fire_time_(0.0), |
| 374 shared_timer_fire_time_was_set_while_suspended_(false), | 369 shared_timer_fire_time_was_set_while_suspended_(false), |
| 375 shared_timer_suspended_(0), | 370 shared_timer_suspended_(0), |
| 376 current_thread_slot_(&DestroyCurrentThread), | 371 current_thread_slot_(&DestroyCurrentThread) {} |
| 377 fling_curve_configuration_(new FlingCurveConfiguration) {} | |
| 378 | 372 |
| 379 WebKitPlatformSupportImpl::~WebKitPlatformSupportImpl() { | 373 WebKitPlatformSupportImpl::~WebKitPlatformSupportImpl() { |
| 380 } | 374 } |
| 381 | 375 |
| 382 void WebKitPlatformSupportImpl::SetFlingCurveParameters( | |
| 383 const std::vector<float>& new_touchpad, | |
| 384 const std::vector<float>& new_touchscreen) { | |
| 385 fling_curve_configuration_->SetCurveParameters(new_touchpad, new_touchscreen); | |
| 386 } | |
| 387 | |
| 388 WebThemeEngine* WebKitPlatformSupportImpl::themeEngine() { | 376 WebThemeEngine* WebKitPlatformSupportImpl::themeEngine() { |
| 389 return &native_theme_engine_; | 377 return &native_theme_engine_; |
| 390 } | 378 } |
| 391 | 379 |
| 392 WebFallbackThemeEngine* WebKitPlatformSupportImpl::fallbackThemeEngine() { | 380 WebFallbackThemeEngine* WebKitPlatformSupportImpl::fallbackThemeEngine() { |
| 393 return &fallback_theme_engine_; | 381 return &fallback_theme_engine_; |
| 394 } | 382 } |
| 395 | 383 |
| 396 WebURLLoader* WebKitPlatformSupportImpl::createURLLoader() { | 384 WebURLLoader* WebKitPlatformSupportImpl::createURLLoader() { |
| 397 return new WebURLLoaderImpl(this); | 385 return new WebURLLoaderImpl(this); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 967 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); |
| 980 worker_task_runner->OnWorkerRunLoopStarted(runLoop); | 968 worker_task_runner->OnWorkerRunLoopStarted(runLoop); |
| 981 } | 969 } |
| 982 | 970 |
| 983 void WebKitPlatformSupportImpl::didStopWorkerRunLoop( | 971 void WebKitPlatformSupportImpl::didStopWorkerRunLoop( |
| 984 const WebKit::WebWorkerRunLoop& runLoop) { | 972 const WebKit::WebWorkerRunLoop& runLoop) { |
| 985 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 973 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); |
| 986 worker_task_runner->OnWorkerRunLoopStopped(runLoop); | 974 worker_task_runner->OnWorkerRunLoopStopped(runLoop); |
| 987 } | 975 } |
| 988 | 976 |
| 989 WebKit::WebGestureCurve* WebKitPlatformSupportImpl::createFlingAnimationCurve( | |
| 990 int device_source, | |
| 991 const WebKit::WebFloatPoint& velocity, | |
| 992 const WebKit::WebSize& cumulative_scroll) { | |
| 993 | |
| 994 #if defined(OS_ANDROID) | |
| 995 return FlingAnimatorImpl::CreateAndroidGestureCurve(velocity, | |
| 996 cumulative_scroll); | |
| 997 #endif | |
| 998 | |
| 999 if (device_source == WebKit::WebGestureEvent::Touchscreen) | |
| 1000 return fling_curve_configuration_->CreateForTouchScreen(velocity, | |
| 1001 cumulative_scroll); | |
| 1002 | |
| 1003 return fling_curve_configuration_->CreateForTouchPad(velocity, | |
| 1004 cumulative_scroll); | |
| 1005 } | |
| 1006 | |
| 1007 WebKit::WebDiscardableMemory* | 977 WebKit::WebDiscardableMemory* |
| 1008 WebKitPlatformSupportImpl::allocateAndLockDiscardableMemory(size_t bytes) { | 978 WebKitPlatformSupportImpl::allocateAndLockDiscardableMemory(size_t bytes) { |
| 1009 if (!base::DiscardableMemory::Supported()) | 979 if (!base::DiscardableMemory::Supported()) |
| 1010 return NULL; | 980 return NULL; |
| 1011 scoped_ptr<WebDiscardableMemoryImpl> discardable( | 981 scoped_ptr<WebDiscardableMemoryImpl> discardable( |
| 1012 new WebDiscardableMemoryImpl()); | 982 new WebDiscardableMemoryImpl()); |
| 1013 if (discardable->InitializeAndLock(bytes)) | 983 if (discardable->InitializeAndLock(bytes)) |
| 1014 return discardable.release(); | 984 return discardable.release(); |
| 1015 return NULL; | 985 return NULL; |
| 1016 } | 986 } |
| 1017 | 987 |
| 1018 #if defined(OS_ANDROID) | 988 #if defined(OS_ANDROID) |
| 1019 webkit_media::WebAudioMediaCodecRunner | 989 webkit_media::WebAudioMediaCodecRunner |
| 1020 WebKitPlatformSupportImpl::GetWebAudioMediaCodecRunner() { | 990 WebKitPlatformSupportImpl::GetWebAudioMediaCodecRunner() { |
| 1021 return base::Bind(&NullRunWebAudioMediaCodec); | 991 return base::Bind(&NullRunWebAudioMediaCodec); |
| 1022 } | 992 } |
| 1023 #endif | 993 #endif |
| 1024 | 994 |
| 1025 } // namespace webkit_glue | 995 } // namespace webkit_glue |
| OLD | NEW |