Chromium Code Reviews| 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 #include "webkit/plugins/npapi/plugin_host.h" | 5 #include "webkit/plugins/npapi/plugin_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 16 #include "third_party/npapi/bindings/npruntime.h" | 17 #include "third_party/npapi/bindings/npruntime.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 gfx::GLImplementation implementation = gfx::GetGLImplementation(); | 65 gfx::GLImplementation implementation = gfx::GetGLImplementation(); |
| 65 if (implementation == gfx::kGLImplementationNone) { | 66 if (implementation == gfx::kGLImplementationNone) { |
| 66 // Not initialized yet. | 67 // Not initialized yet. |
| 67 if (!gfx::GLSurface::InitializeOneOff()) { | 68 if (!gfx::GLSurface::InitializeOneOff()) { |
| 68 return false; | 69 return false; |
| 69 } | 70 } |
| 70 implementation = gfx::GetGLImplementation(); | 71 implementation = gfx::GetGLImplementation(); |
| 71 } | 72 } |
| 72 return (implementation == gfx::kGLImplementationDesktopGL); | 73 return (implementation == gfx::kGLImplementationDesktopGL); |
| 73 } | 74 } |
| 75 | |
| 76 static bool UsingCompositedCoreAnimationPlugins() { | |
| 77 // We can't reference the kDisableCompositedCoreAnimationPlugins | |
|
jam
2011/11/29 18:56:21
duplicating the switch seems unfortunate. perhaps
Ken Russell (switch to Gerrit)
2011/11/30 00:23:32
Thanks for the suggestion. Ended up putting it in
| |
| 78 // constant in content/ here. | |
| 79 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 80 "disable-composited-core-animation-plugins"); | |
| 81 } | |
| 74 #endif | 82 #endif |
| 75 | 83 |
| 76 PluginHost::PluginHost() { | 84 PluginHost::PluginHost() { |
| 77 InitializeHostFuncs(); | 85 InitializeHostFuncs(); |
| 78 } | 86 } |
| 79 | 87 |
| 80 PluginHost::~PluginHost() { | 88 PluginHost::~PluginHost() { |
| 81 } | 89 } |
| 82 | 90 |
| 83 PluginHost *PluginHost::Singleton() { | 91 PluginHost *PluginHost::Singleton() { |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 // We only support the Core Animation model on 10.6 and higher | 827 // We only support the Core Animation model on 10.6 and higher |
| 820 // TODO(stuartmorgan): Once existing CA plugins have implemented the | 828 // TODO(stuartmorgan): Once existing CA plugins have implemented the |
| 821 // invalidating version, remove support for this one. | 829 // invalidating version, remove support for this one. |
| 822 NPBool* supports_model = reinterpret_cast<NPBool*>(value); | 830 NPBool* supports_model = reinterpret_cast<NPBool*>(value); |
| 823 *supports_model = webkit::npapi::SupportsSharingAcceleratedSurfaces() ? | 831 *supports_model = webkit::npapi::SupportsSharingAcceleratedSurfaces() ? |
| 824 true : false; | 832 true : false; |
| 825 rv = NPERR_NO_ERROR; | 833 rv = NPERR_NO_ERROR; |
| 826 break; | 834 break; |
| 827 } | 835 } |
| 828 case NPNVsupportsInvalidatingCoreAnimationBool: { | 836 case NPNVsupportsInvalidatingCoreAnimationBool: { |
| 837 // The composited code path for this model only works on 10.6 and higher. | |
| 838 // The old direct-to-screen code path supports 10.5. | |
| 829 NPBool* supports_model = reinterpret_cast<NPBool*>(value); | 839 NPBool* supports_model = reinterpret_cast<NPBool*>(value); |
| 830 *supports_model = true; | 840 bool composited = webkit::npapi::UsingCompositedCoreAnimationPlugins(); |
| 841 *supports_model = composited ? | |
| 842 webkit::npapi::SupportsSharingAcceleratedSurfaces() : true; | |
| 831 rv = NPERR_NO_ERROR; | 843 rv = NPERR_NO_ERROR; |
| 832 break; | 844 break; |
| 833 } | 845 } |
| 834 case NPNVsupportsOpenGLBool: { | 846 case NPNVsupportsOpenGLBool: { |
| 835 // This drawing model was never widely supported, and we don't plan to | 847 // This drawing model was never widely supported, and we don't plan to |
| 836 // support it. | 848 // support it. |
| 837 NPBool* supports_model = reinterpret_cast<NPBool*>(value); | 849 NPBool* supports_model = reinterpret_cast<NPBool*>(value); |
| 838 *supports_model = false; | 850 *supports_model = false; |
| 839 rv = NPERR_NO_ERROR; | 851 rv = NPERR_NO_ERROR; |
| 840 break; | 852 break; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 case NPPVpluginKeepLibraryInMemory: | 906 case NPPVpluginKeepLibraryInMemory: |
| 895 // Tells browser that plugin library should live longer than usual. | 907 // Tells browser that plugin library should live longer than usual. |
| 896 // TODO: implement me | 908 // TODO: implement me |
| 897 DVLOG(1) << "NPN_SetValue(NPPVpluginKeepLibraryInMemory) is not " | 909 DVLOG(1) << "NPN_SetValue(NPPVpluginKeepLibraryInMemory) is not " |
| 898 "implemented."; | 910 "implemented."; |
| 899 return NPERR_GENERIC_ERROR; | 911 return NPERR_GENERIC_ERROR; |
| 900 #if defined(OS_MACOSX) | 912 #if defined(OS_MACOSX) |
| 901 case NPPVpluginDrawingModel: { | 913 case NPPVpluginDrawingModel: { |
| 902 int model = reinterpret_cast<int>(value); | 914 int model = reinterpret_cast<int>(value); |
| 903 if (model == NPDrawingModelCoreGraphics || | 915 if (model == NPDrawingModelCoreGraphics || |
| 904 model == NPDrawingModelInvalidatingCoreAnimation || | 916 (model == NPDrawingModelInvalidatingCoreAnimation && |
| 917 (webkit::npapi::SupportsSharingAcceleratedSurfaces() || | |
| 918 !webkit::npapi::UsingCompositedCoreAnimationPlugins())) || | |
| 905 (model == NPDrawingModelCoreAnimation && | 919 (model == NPDrawingModelCoreAnimation && |
| 906 webkit::npapi::SupportsSharingAcceleratedSurfaces())) { | 920 webkit::npapi::SupportsSharingAcceleratedSurfaces())) { |
| 907 plugin->set_drawing_model(static_cast<NPDrawingModel>(model)); | 921 plugin->set_drawing_model(static_cast<NPDrawingModel>(model)); |
| 908 return NPERR_NO_ERROR; | 922 return NPERR_NO_ERROR; |
| 909 } | 923 } |
| 910 return NPERR_GENERIC_ERROR; | 924 return NPERR_GENERIC_ERROR; |
| 911 } | 925 } |
| 912 case NPPVpluginEventModel: { | 926 case NPPVpluginEventModel: { |
| 913 // we support Carbon and Cocoa event models | 927 // we support Carbon and Cocoa event models |
| 914 int model = reinterpret_cast<int>(value); | 928 int model = reinterpret_cast<int>(value); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1132 } | 1146 } |
| 1133 | 1147 |
| 1134 void NPN_URLRedirectResponse(NPP instance, void* notify_data, NPBool allow) { | 1148 void NPN_URLRedirectResponse(NPP instance, void* notify_data, NPBool allow) { |
| 1135 scoped_refptr<PluginInstance> plugin(FindInstance(instance)); | 1149 scoped_refptr<PluginInstance> plugin(FindInstance(instance)); |
| 1136 if (plugin.get()) { | 1150 if (plugin.get()) { |
| 1137 plugin->URLRedirectResponse(!!allow, notify_data); | 1151 plugin->URLRedirectResponse(!!allow, notify_data); |
| 1138 } | 1152 } |
| 1139 } | 1153 } |
| 1140 | 1154 |
| 1141 } // extern "C" | 1155 } // extern "C" |
| OLD | NEW |