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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 #import <QuartzCore/QuartzCore.h> | 6 #import <QuartzCore/QuartzCore.h> |
7 | 7 |
8 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 8 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <unistd.h> | 11 #include <unistd.h> |
12 #include <set> | 12 #include <set> |
13 | 13 |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/mac/mac_util.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
17 #include "base/metrics/stats_counters.h" | 18 #include "base/metrics/stats_counters.h" |
18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "base/sys_info.h" | |
21 #include "base/sys_string_conversions.h" | 21 #include "base/sys_string_conversions.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
23 #include "webkit/glue/webkit_glue.h" | 23 #include "webkit/glue/webkit_glue.h" |
24 #include "webkit/plugins/npapi/plugin_instance.h" | 24 #include "webkit/plugins/npapi/plugin_instance.h" |
25 #include "webkit/plugins/npapi/plugin_lib.h" | 25 #include "webkit/plugins/npapi/plugin_lib.h" |
26 #include "webkit/plugins/npapi/plugin_list.h" | 26 #include "webkit/plugins/npapi/plugin_list.h" |
27 #include "webkit/plugins/npapi/plugin_stream_url.h" | 27 #include "webkit/plugins/npapi/plugin_stream_url.h" |
28 #include "webkit/plugins/npapi/plugin_web_event_converter_mac.h" | 28 #include "webkit/plugins/npapi/plugin_web_event_converter_mac.h" |
29 #include "webkit/plugins/npapi/webplugin.h" | 29 #include "webkit/plugins/npapi/webplugin.h" |
30 #include "webkit/plugins/npapi/webplugin_accelerated_surface_mac.h" | 30 #include "webkit/plugins/npapi/webplugin_accelerated_surface_mac.h" |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 redraw_timer_->Start( | 1000 redraw_timer_->Start( |
1001 base::TimeDelta::FromMilliseconds(kCoreAnimationRedrawPeriodMs), | 1001 base::TimeDelta::FromMilliseconds(kCoreAnimationRedrawPeriodMs), |
1002 this, &WebPluginDelegateImpl::DrawLayerInSurface); | 1002 this, &WebPluginDelegateImpl::DrawLayerInSurface); |
1003 } else if (!plugin_visible) { | 1003 } else if (!plugin_visible) { |
1004 redraw_timer_->Stop(); | 1004 redraw_timer_->Stop(); |
1005 } | 1005 } |
1006 } | 1006 } |
1007 } | 1007 } |
1008 | 1008 |
1009 void WebPluginDelegateImpl::StartIme() { | 1009 void WebPluginDelegateImpl::StartIme() { |
| 1010 // Currently the plugin IME implementation only works on 10.6. |
1010 if (instance()->event_model() != NPEventModelCocoa || | 1011 if (instance()->event_model() != NPEventModelCocoa || |
1011 !IsImeSupported()) { | 1012 base::mac::IsOSLeopardOrEarlier()) { |
1012 return; | 1013 return; |
1013 } | 1014 } |
1014 if (ime_enabled_) | 1015 if (ime_enabled_) |
1015 return; | 1016 return; |
1016 ime_enabled_ = true; | 1017 ime_enabled_ = true; |
1017 plugin_->StartIme(); | 1018 plugin_->StartIme(); |
1018 } | 1019 } |
1019 | 1020 |
1020 bool WebPluginDelegateImpl::IsImeSupported() { | |
1021 // Currently the plugin IME implementation only works on 10.6. | |
1022 static BOOL sImeSupported = NO; | |
1023 static BOOL sHaveCheckedSupport = NO; | |
1024 if (!sHaveCheckedSupport) { | |
1025 int32 major, minor, bugfix; | |
1026 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); | |
1027 sImeSupported = major > 10 || (major == 10 && minor > 5); | |
1028 sHaveCheckedSupport = YES; | |
1029 } | |
1030 return sImeSupported; | |
1031 } | |
1032 | |
1033 #pragma mark - | 1021 #pragma mark - |
1034 #pragma mark Core Animation Support | 1022 #pragma mark Core Animation Support |
1035 | 1023 |
1036 void WebPluginDelegateImpl::DrawLayerInSurface() { | 1024 void WebPluginDelegateImpl::DrawLayerInSurface() { |
1037 // If we haven't plumbed up the surface yet, don't try to draw. | 1025 // If we haven't plumbed up the surface yet, don't try to draw. |
1038 if (!windowed_handle() || !renderer_) | 1026 if (!windowed_handle() || !renderer_) |
1039 return; | 1027 return; |
1040 | 1028 |
1041 [renderer_ beginFrameAtTime:CACurrentMediaTime() timeStamp:NULL]; | 1029 [renderer_ beginFrameAtTime:CACurrentMediaTime() timeStamp:NULL]; |
1042 if (CGRectIsEmpty([renderer_ updateBounds])) { | 1030 if (CGRectIsEmpty([renderer_ updateBounds])) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 qd_manager_->SetFastPathEnabled(enabled); | 1178 qd_manager_->SetFastPathEnabled(enabled); |
1191 qd_port_.port = qd_manager_->port(); | 1179 qd_port_.port = qd_manager_->port(); |
1192 WindowlessSetWindow(); | 1180 WindowlessSetWindow(); |
1193 // Send a paint event so that the new buffer gets updated immediately. | 1181 // Send a paint event so that the new buffer gets updated immediately. |
1194 WindowlessPaint(buffer_context_, clip_rect_); | 1182 WindowlessPaint(buffer_context_, clip_rect_); |
1195 } | 1183 } |
1196 #endif // !NP_NO_QUICKDRAW | 1184 #endif // !NP_NO_QUICKDRAW |
1197 | 1185 |
1198 } // namespace npapi | 1186 } // namespace npapi |
1199 } // namespace webkit | 1187 } // namespace webkit |
OLD | NEW |