OLD | NEW |
1 // Copyright 2008 Google Inc. | 1 // Copyright 2008 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 NPError OSCALL NP_Shutdown(void) { | 65 NPError OSCALL NP_Shutdown(void) { |
66 return NPERR_NO_ERROR; | 66 return NPERR_NO_ERROR; |
67 } | 67 } |
68 | 68 |
69 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, | 69 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, |
70 int16_t argc, char *argn[], char *argv[], | 70 int16_t argc, char *argn[], char *argv[], |
71 NPSavedData *saved) { | 71 NPSavedData *saved) { |
72 glue::InitializeGlue(instance); | 72 glue::InitializeGlue(instance); |
73 NPObject *object = glue::CreateStaticNPObject(instance); | 73 NPObject *object = glue::CreateStaticNPObject(instance); |
74 instance->pdata = object; | 74 instance->pdata = object; |
| 75 |
| 76 #if defined(OS_MACOSX) |
| 77 // On the Mac, starting from Google Chrome 22, we need to negotiate |
| 78 // CoreGraphics and Cocoa even though we don't use it. |
| 79 // See: http://code.google.com/p/chromium/issues/detail?id=134761 |
| 80 // Code ported from http://gwt-code-reviews.appspot.com/1844803/ |
| 81 |
| 82 // Select the right drawing model if necessary |
| 83 NPBool supports_core_graphics = false; |
| 84 if (NPN_GetValue(instance, NPNVsupportsCoreGraphicsBool, |
| 85 &supports_core_graphics) == NPERR_NO_ERROR && |
| 86 supports_core_graphics) { |
| 87 NPN_SetValue(instance, NPPVpluginDrawingModel, |
| 88 reinterpret_cast<void*>(NPDrawingModelCoreGraphics)); |
| 89 } |
| 90 // Select the Cocoa event model |
| 91 NPBool supports_cocoa_events = false; |
| 92 if (NPN_GetValue(instance, NPNVsupportsCocoaBool, |
| 93 &supports_cocoa_events) == NPERR_NO_ERROR && |
| 94 supports_cocoa_events) { |
| 95 NPN_SetValue(instance, NPPVpluginEventModel, |
| 96 reinterpret_cast<void*>(NPEventModelCocoa)); |
| 97 } |
| 98 #endif |
75 return NPERR_NO_ERROR; | 99 return NPERR_NO_ERROR; |
76 } | 100 } |
77 | 101 |
78 NPError NPP_Destroy(NPP instance, NPSavedData **save) { | 102 NPError NPP_Destroy(NPP instance, NPSavedData **save) { |
79 NPObject *object = static_cast<NPObject*>(instance->pdata); | 103 NPObject *object = static_cast<NPObject*>(instance->pdata); |
80 if (object) { | 104 if (object) { |
81 NPN_ReleaseObject(object); | 105 NPN_ReleaseObject(object); |
82 instance->pdata = NULL; | 106 instance->pdata = NULL; |
83 } | 107 } |
84 return NPERR_NO_ERROR; | 108 return NPERR_NO_ERROR; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 return 0; | 161 return 0; |
138 } | 162 } |
139 | 163 |
140 void NPP_Print(NPP instance, NPPrint *platformPrint) { | 164 void NPP_Print(NPP instance, NPPrint *platformPrint) { |
141 } | 165 } |
142 | 166 |
143 void NPP_URLNotify(NPP instance, const char *url, NPReason reason, | 167 void NPP_URLNotify(NPP instance, const char *url, NPReason reason, |
144 void *notifyData) { | 168 void *notifyData) { |
145 } | 169 } |
146 } // extern "C" | 170 } // extern "C" |
OLD | NEW |