| 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 "ppapi/cpp/private/flash.h" | 5 #include "ppapi/cpp/private/flash.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_bool.h" | 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/cpp/dev/font_dev.h" | 9 #include "ppapi/cpp/dev/font_dev.h" |
| 10 #include "ppapi/cpp/image_data.h" | 10 #include "ppapi/cpp/image_data.h" |
| 11 #include "ppapi/cpp/instance.h" | 11 #include "ppapi/cpp/instance.h" |
| 12 #include "ppapi/cpp/module.h" | 12 #include "ppapi/cpp/module.h" |
| 13 #include "ppapi/cpp/module_impl.h" | 13 #include "ppapi/cpp/module_impl.h" |
| 14 #include "ppapi/cpp/point.h" | 14 #include "ppapi/cpp/point.h" |
| 15 #include "ppapi/cpp/rect.h" | 15 #include "ppapi/cpp/rect.h" |
| 16 #include "ppapi/cpp/url_request_info.h" | 16 #include "ppapi/cpp/url_request_info.h" |
| 17 #include "ppapi/cpp/var.h" | 17 #include "ppapi/cpp/var.h" |
| 18 #include "ppapi/c/private/ppb_flash.h" | 18 #include "ppapi/c/private/ppb_flash.h" |
| 19 | 19 |
| 20 namespace pp { | 20 namespace pp { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 template <> const char* interface_name<PPB_Flash>() { | 24 template <> const char* interface_name<PPB_Flash>() { |
| 25 return PPB_FLASH_INTERFACE; | 25 return PPB_FLASH_INTERFACE; |
| 26 } | 26 } |
| 27 | 27 |
| 28 template <> const char* interface_name<PPB_Flash_12_0>() { |
| 29 return PPB_FLASH_INTERFACE_12_0; |
| 30 } |
| 31 |
| 28 template <> const char* interface_name<PPB_Flash_11>() { | 32 template <> const char* interface_name<PPB_Flash_11>() { |
| 29 return PPB_FLASH_INTERFACE_11_0; | 33 return PPB_FLASH_INTERFACE_11_0; |
| 30 } | 34 } |
| 31 | 35 |
| 32 } // namespace | 36 } // namespace |
| 33 | 37 |
| 34 namespace flash { | 38 namespace flash { |
| 35 | 39 |
| 36 // static | 40 // static |
| 37 bool Flash::IsAvailable() { | 41 bool Flash::IsAvailable() { |
| 38 return has_interface<PPB_Flash>() || has_interface<PPB_Flash_11>(); | 42 return has_interface<PPB_Flash>() || |
| 43 has_interface<PPB_Flash_12_0>(); |
| 44 has_interface<PPB_Flash_11>(); |
| 39 } | 45 } |
| 40 | 46 |
| 41 // static | 47 // static |
| 42 void Flash::SetInstanceAlwaysOnTop(Instance* instance, bool on_top) { | 48 void Flash::SetInstanceAlwaysOnTop(Instance* instance, bool on_top) { |
| 43 if (has_interface<PPB_Flash>()) { | 49 if (has_interface<PPB_Flash>()) { |
| 44 get_interface<PPB_Flash>()->SetInstanceAlwaysOnTop(instance->pp_instance(), | 50 get_interface<PPB_Flash>()->SetInstanceAlwaysOnTop(instance->pp_instance(), |
| 45 PP_FromBool(on_top)); | 51 PP_FromBool(on_top)); |
| 52 } else if (has_interface<PPB_Flash_12_0>()) { |
| 53 get_interface<PPB_Flash_12_0>()->SetInstanceAlwaysOnTop( |
| 54 instance->pp_instance(), PP_FromBool(on_top)); |
| 46 } else if (has_interface<PPB_Flash_11>()) { | 55 } else if (has_interface<PPB_Flash_11>()) { |
| 47 get_interface<PPB_Flash_11>()->SetInstanceAlwaysOnTop( | 56 get_interface<PPB_Flash_11>()->SetInstanceAlwaysOnTop( |
| 48 instance->pp_instance(), PP_FromBool(on_top)); | 57 instance->pp_instance(), PP_FromBool(on_top)); |
| 49 } | 58 } |
| 50 } | 59 } |
| 51 | 60 |
| 52 // static | 61 // static |
| 53 bool Flash::DrawGlyphs(Instance* instance, | 62 bool Flash::DrawGlyphs(Instance* instance, |
| 54 ImageData* image, | 63 ImageData* image, |
| 55 const FontDescription_Dev& font_desc, | 64 const FontDescription_Dev& font_desc, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 68 image->pp_resource(), | 77 image->pp_resource(), |
| 69 &font_desc.pp_font_description(), | 78 &font_desc.pp_font_description(), |
| 70 color, | 79 color, |
| 71 &position.pp_point(), | 80 &position.pp_point(), |
| 72 &clip.pp_rect(), | 81 &clip.pp_rect(), |
| 73 transformation, | 82 transformation, |
| 74 PP_FromBool(allow_subpixel_aa), | 83 PP_FromBool(allow_subpixel_aa), |
| 75 glyph_count, | 84 glyph_count, |
| 76 glyph_indices, | 85 glyph_indices, |
| 77 glyph_advances)); | 86 glyph_advances)); |
| 87 } else if (has_interface<PPB_Flash_12_0>()) { |
| 88 rv = PP_ToBool(get_interface<PPB_Flash_12_0>()->DrawGlyphs( |
| 89 instance->pp_instance(), |
| 90 image->pp_resource(), |
| 91 &font_desc.pp_font_description(), |
| 92 color, |
| 93 &position.pp_point(), |
| 94 &clip.pp_rect(), |
| 95 transformation, |
| 96 PP_FromBool(allow_subpixel_aa), |
| 97 glyph_count, |
| 98 glyph_indices, |
| 99 glyph_advances)); |
| 78 } else if (has_interface<PPB_Flash_11>()) { | 100 } else if (has_interface<PPB_Flash_11>()) { |
| 79 rv = PP_ToBool(get_interface<PPB_Flash_11>()->DrawGlyphs( | 101 rv = PP_ToBool(get_interface<PPB_Flash_11>()->DrawGlyphs( |
| 80 instance->pp_instance(), | 102 instance->pp_instance(), |
| 81 image->pp_resource(), | 103 image->pp_resource(), |
| 82 &font_desc.pp_font_description(), | 104 &font_desc.pp_font_description(), |
| 83 color, | 105 color, |
| 84 position.pp_point(), | 106 position.pp_point(), |
| 85 clip.pp_rect(), | 107 clip.pp_rect(), |
| 86 transformation, | 108 transformation, |
| 87 glyph_count, | 109 glyph_count, |
| 88 glyph_indices, | 110 glyph_indices, |
| 89 glyph_advances)); | 111 glyph_advances)); |
| 90 } | 112 } |
| 91 return rv; | 113 return rv; |
| 92 } | 114 } |
| 93 | 115 |
| 94 // static | 116 // static |
| 95 Var Flash::GetProxyForURL(Instance* instance, const std::string& url) { | 117 Var Flash::GetProxyForURL(Instance* instance, const std::string& url) { |
| 96 Var rv; | 118 Var rv; |
| 97 if (has_interface<PPB_Flash>()) { | 119 if (has_interface<PPB_Flash>()) { |
| 98 rv = Var(Var::PassRef(), | 120 rv = Var(Var::PassRef(), |
| 99 get_interface<PPB_Flash>()->GetProxyForURL(instance->pp_instance(), | 121 get_interface<PPB_Flash>()->GetProxyForURL(instance->pp_instance(), |
| 100 url.c_str())); | 122 url.c_str())); |
| 123 } else if (has_interface<PPB_Flash_12_0>()) { |
| 124 rv = Var(Var::PassRef(), |
| 125 get_interface<PPB_Flash_12_0>()->GetProxyForURL( |
| 126 instance->pp_instance(), url.c_str())); |
| 101 } else if (has_interface<PPB_Flash_11>()) { | 127 } else if (has_interface<PPB_Flash_11>()) { |
| 102 rv = Var(Var::PassRef(), | 128 rv = Var(Var::PassRef(), |
| 103 get_interface<PPB_Flash_11>()->GetProxyForURL( | 129 get_interface<PPB_Flash_11>()->GetProxyForURL( |
| 104 instance->pp_instance(), url.c_str())); | 130 instance->pp_instance(), url.c_str())); |
| 105 } | 131 } |
| 106 return rv; | 132 return rv; |
| 107 } | 133 } |
| 108 | 134 |
| 109 // static | 135 // static |
| 110 int32_t Flash::Navigate(const URLRequestInfo& request_info, | 136 int32_t Flash::Navigate(const URLRequestInfo& request_info, |
| 111 const std::string& target, | 137 const std::string& target, |
| 112 bool from_user_action) { | 138 bool from_user_action) { |
| 113 int32_t rv = PP_ERROR_FAILED; | 139 int32_t rv = PP_ERROR_FAILED; |
| 114 if (has_interface<PPB_Flash>()) { | 140 if (has_interface<PPB_Flash>()) { |
| 115 rv = get_interface<PPB_Flash>()->Navigate(request_info.pp_resource(), | 141 rv = get_interface<PPB_Flash>()->Navigate(request_info.pp_resource(), |
| 116 target.c_str(), | 142 target.c_str(), |
| 117 PP_FromBool(from_user_action)); | 143 PP_FromBool(from_user_action)); |
| 144 } else if (has_interface<PPB_Flash_12_0>()) { |
| 145 rv = get_interface<PPB_Flash_12_0>()->Navigate( |
| 146 request_info.pp_resource(), |
| 147 target.c_str(), |
| 148 PP_FromBool(from_user_action)); |
| 118 } else if (has_interface<PPB_Flash_11>()) { | 149 } else if (has_interface<PPB_Flash_11>()) { |
| 119 rv = get_interface<PPB_Flash_11>()->Navigate(request_info.pp_resource(), | 150 rv = get_interface<PPB_Flash_11>()->Navigate(request_info.pp_resource(), |
| 120 target.c_str(), | 151 target.c_str(), |
| 121 from_user_action); | 152 from_user_action); |
| 122 } | 153 } |
| 123 return rv; | 154 return rv; |
| 124 } | 155 } |
| 125 | 156 |
| 126 // static | 157 // static |
| 127 void Flash::RunMessageLoop(Instance* instance) { | 158 void Flash::RunMessageLoop(Instance* instance) { |
| 128 if (has_interface<PPB_Flash>()) | 159 if (has_interface<PPB_Flash>()) |
| 129 get_interface<PPB_Flash>()->RunMessageLoop(instance->pp_instance()); | 160 get_interface<PPB_Flash>()->RunMessageLoop(instance->pp_instance()); |
| 161 else if (has_interface<PPB_Flash_12_0>()) |
| 162 get_interface<PPB_Flash_12_0>()->RunMessageLoop(instance->pp_instance()); |
| 130 else if (has_interface<PPB_Flash_11>()) | 163 else if (has_interface<PPB_Flash_11>()) |
| 131 get_interface<PPB_Flash_11>()->RunMessageLoop(instance->pp_instance()); | 164 get_interface<PPB_Flash_11>()->RunMessageLoop(instance->pp_instance()); |
| 132 } | 165 } |
| 133 | 166 |
| 134 // static | 167 // static |
| 135 void Flash::QuitMessageLoop(Instance* instance) { | 168 void Flash::QuitMessageLoop(Instance* instance) { |
| 136 if (has_interface<PPB_Flash>()) | 169 if (has_interface<PPB_Flash>()) |
| 137 get_interface<PPB_Flash>()->QuitMessageLoop(instance->pp_instance()); | 170 get_interface<PPB_Flash>()->QuitMessageLoop(instance->pp_instance()); |
| 171 else if (has_interface<PPB_Flash_12_0>()) |
| 172 get_interface<PPB_Flash_12_0>()->QuitMessageLoop(instance->pp_instance()); |
| 138 else if (has_interface<PPB_Flash_11>()) | 173 else if (has_interface<PPB_Flash_11>()) |
| 139 get_interface<PPB_Flash_11>()->QuitMessageLoop(instance->pp_instance()); | 174 get_interface<PPB_Flash_11>()->QuitMessageLoop(instance->pp_instance()); |
| 140 } | 175 } |
| 141 | 176 |
| 142 // static | 177 // static |
| 143 double Flash::GetLocalTimeZoneOffset(Instance* instance, PP_Time t) { | 178 double Flash::GetLocalTimeZoneOffset(Instance* instance, PP_Time t) { |
| 144 double rv = 0; | 179 double rv = 0; |
| 145 if (has_interface<PPB_Flash>()) { | 180 if (has_interface<PPB_Flash>()) { |
| 146 rv = get_interface<PPB_Flash>()->GetLocalTimeZoneOffset( | 181 rv = get_interface<PPB_Flash>()->GetLocalTimeZoneOffset( |
| 147 instance->pp_instance(), t); | 182 instance->pp_instance(), t); |
| 183 } else if (has_interface<PPB_Flash_12_0>()) { |
| 184 rv = get_interface<PPB_Flash_12_0>()->GetLocalTimeZoneOffset( |
| 185 instance->pp_instance(), t); |
| 148 } else if (has_interface<PPB_Flash_11>()) { | 186 } else if (has_interface<PPB_Flash_11>()) { |
| 149 rv = get_interface<PPB_Flash_11>()->GetLocalTimeZoneOffset( | 187 rv = get_interface<PPB_Flash_11>()->GetLocalTimeZoneOffset( |
| 150 instance->pp_instance(), t); | 188 instance->pp_instance(), t); |
| 151 } | 189 } |
| 152 return rv; | 190 return rv; |
| 153 } | 191 } |
| 154 | 192 |
| 155 // static | 193 // static |
| 156 Var Flash::GetCommandLineArgs(Module* module) { | 194 Var Flash::GetCommandLineArgs(Module* module) { |
| 157 Var rv; | 195 Var rv; |
| 158 if (has_interface<PPB_Flash>()) { | 196 if (has_interface<PPB_Flash>()) { |
| 159 rv = Var(Var::PassRef(), | 197 rv = Var(Var::PassRef(), |
| 160 get_interface<PPB_Flash>()->GetCommandLineArgs( | 198 get_interface<PPB_Flash>()->GetCommandLineArgs( |
| 161 module->pp_module())); | 199 module->pp_module())); |
| 200 } else if (has_interface<PPB_Flash_12_0>()) { |
| 201 rv = Var(Var::PassRef(), |
| 202 get_interface<PPB_Flash_12_0>()->GetCommandLineArgs( |
| 203 module->pp_module())); |
| 162 } else if (has_interface<PPB_Flash_11>()) { | 204 } else if (has_interface<PPB_Flash_11>()) { |
| 163 rv = Var(Var::PassRef(), | 205 rv = Var(Var::PassRef(), |
| 164 get_interface<PPB_Flash_11>()->GetCommandLineArgs( | 206 get_interface<PPB_Flash_11>()->GetCommandLineArgs( |
| 165 module->pp_module())); | 207 module->pp_module())); |
| 166 } | 208 } |
| 167 return rv; | 209 return rv; |
| 168 } | 210 } |
| 169 | 211 |
| 170 // static | 212 // static |
| 171 void Flash::PreloadFontWin(const void* logfontw) { | 213 void Flash::PreloadFontWin(const void* logfontw) { |
| 172 if (has_interface<PPB_Flash>()) | 214 if (has_interface<PPB_Flash>()) |
| 173 get_interface<PPB_Flash>()->PreloadFontWin(logfontw); | 215 get_interface<PPB_Flash>()->PreloadFontWin(logfontw); |
| 216 else if (has_interface<PPB_Flash_12_0>()) |
| 217 get_interface<PPB_Flash_12_0>()->PreloadFontWin(logfontw); |
| 218 } |
| 219 |
| 220 // static |
| 221 bool Flash::IsRectTopmost(Instance* instance, const Rect& rect) { |
| 222 bool rv = false; |
| 223 if (has_interface<PPB_Flash>()) { |
| 224 rv = PP_ToBool(get_interface<PPB_Flash>()->IsRectTopmost( |
| 225 instance->pp_instance(), &rect.pp_rect())); |
| 226 } |
| 227 return rv; |
| 228 } |
| 229 |
| 230 // static |
| 231 int32_t Flash::InvokePrinting(Instance* instance) { |
| 232 int32_t rv = PP_ERROR_NOTSUPPORTED; |
| 233 if (has_interface<PPB_Flash>()) |
| 234 rv = get_interface<PPB_Flash>()->InvokePrinting(instance->pp_instance()); |
| 235 return rv; |
| 236 } |
| 237 |
| 238 // static |
| 239 void Flash::UpdateActivity(Instance* instance) { |
| 240 if (has_interface<PPB_Flash>()) |
| 241 get_interface<PPB_Flash>()->UpdateActivity(instance->pp_instance()); |
| 174 } | 242 } |
| 175 | 243 |
| 176 } // namespace flash | 244 } // namespace flash |
| 177 } // namespace pp | 245 } // namespace pp |
| OLD | NEW |