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/plugins/ppapi/ppb_flash_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/message_loop.h" | |
11 #include "base/time.h" | 10 #include "base/time.h" |
12 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
13 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
14 #include "ppapi/c/dev/ppb_font_dev.h" | 13 #include "ppapi/c/dev/ppb_font_dev.h" |
15 #include "ppapi/c/private/ppb_flash.h" | 14 #include "ppapi/c/private/ppb_flash.h" |
16 #include "ppapi/shared_impl/file_path.h" | 15 #include "ppapi/shared_impl/file_path.h" |
17 #include "ppapi/shared_impl/file_type_conversion.h" | 16 #include "ppapi/shared_impl/file_type_conversion.h" |
18 #include "ppapi/shared_impl/time_conversion.h" | 17 #include "ppapi/shared_impl/time_conversion.h" |
19 #include "ppapi/shared_impl/var.h" | 18 #include "ppapi/shared_impl/var.h" |
20 #include "ppapi/thunk/enter.h" | 19 #include "ppapi/thunk/enter.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 182 |
184 int32_t PPB_Flash_Impl::Navigate(PP_Instance instance, | 183 int32_t PPB_Flash_Impl::Navigate(PP_Instance instance, |
185 const ::ppapi::URLRequestInfoData& data, | 184 const ::ppapi::URLRequestInfoData& data, |
186 const char* target, | 185 const char* target, |
187 PP_Bool from_user_action) { | 186 PP_Bool from_user_action) { |
188 if (!target) | 187 if (!target) |
189 return PP_ERROR_BADARGUMENT; | 188 return PP_ERROR_BADARGUMENT; |
190 return instance_->Navigate(data, target, PP_ToBool(from_user_action)); | 189 return instance_->Navigate(data, target, PP_ToBool(from_user_action)); |
191 } | 190 } |
192 | 191 |
193 void PPB_Flash_Impl::RunMessageLoop(PP_Instance instance) { | |
194 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | |
195 MessageLoop::current()->Run(); | |
196 } | |
197 | |
198 void PPB_Flash_Impl::QuitMessageLoop(PP_Instance instance) { | |
199 MessageLoop::current()->QuitNow(); | |
200 } | |
201 | |
202 double PPB_Flash_Impl::GetLocalTimeZoneOffset(PP_Instance instance, | 192 double PPB_Flash_Impl::GetLocalTimeZoneOffset(PP_Instance instance, |
203 PP_Time t) { | 193 PP_Time t) { |
204 // Evil hack. The time code handles exact "0" values as special, and produces | 194 // Evil hack. The time code handles exact "0" values as special, and produces |
205 // a "null" Time object. This will represent some date hundreds of years ago | 195 // a "null" Time object. This will represent some date hundreds of years ago |
206 // and will give us funny results at 1970 (there are some tests where this | 196 // and will give us funny results at 1970 (there are some tests where this |
207 // comes up, but it shouldn't happen in real life). To work around this | 197 // comes up, but it shouldn't happen in real life). To work around this |
208 // special handling, we just need to give it some nonzero value. | 198 // special handling, we just need to give it some nonzero value. |
209 if (t == 0.0) | 199 if (t == 0.0) |
210 t = 0.0000000001; | 200 t = 0.0000000001; |
211 | 201 |
212 // We can't do the conversion here because on Linux, the localtime calls | 202 // We can't do the conversion here because on Linux, the localtime calls |
213 // require filesystem access prohibited by the sandbox. | 203 // require filesystem access prohibited by the sandbox. |
214 return instance_->delegate()->GetLocalTimeZoneOffset(PPTimeToTime(t)); | 204 return instance_->delegate()->GetLocalTimeZoneOffset(PPTimeToTime(t)); |
215 } | 205 } |
216 | 206 |
217 PP_Bool PPB_Flash_Impl::IsRectTopmost(PP_Instance instance, | 207 PP_Bool PPB_Flash_Impl::IsRectTopmost(PP_Instance instance, |
218 const PP_Rect* rect) { | 208 const PP_Rect* rect) { |
219 return PP_FromBool(instance_->IsRectTopmost( | 209 return PP_FromBool(instance_->IsRectTopmost( |
220 gfx::Rect(rect->point.x, rect->point.y, | 210 gfx::Rect(rect->point.x, rect->point.y, |
221 rect->size.width, rect->size.height))); | 211 rect->size.width, rect->size.height))); |
222 } | 212 } |
223 | 213 |
224 void PPB_Flash_Impl::UpdateActivity(PP_Instance pp_instance) { | 214 void PPB_Flash_Impl::UpdateActivity(PP_Instance pp_instance) { |
225 // Not supported in-process. | 215 // Not supported in-process. |
226 } | 216 } |
227 | 217 |
228 PP_Var PPB_Flash_Impl::GetDeviceID(PP_Instance pp_instance) { | |
229 std::string id = instance_->delegate()->GetDeviceID(); | |
230 return StringVar::StringToPPVar(id); | |
231 } | |
232 | |
233 int32_t PPB_Flash_Impl::GetSettingInt(PP_Instance instance, | |
234 PP_FlashSetting setting) { | |
235 // No current settings are supported in-process. | |
236 return -1; | |
237 } | |
238 | |
239 PP_Var PPB_Flash_Impl::GetSetting(PP_Instance instance, | 218 PP_Var PPB_Flash_Impl::GetSetting(PP_Instance instance, |
240 PP_FlashSetting setting) { | 219 PP_FlashSetting setting) { |
241 switch(setting) { | 220 switch(setting) { |
242 case PP_FLASHSETTING_LSORESTRICTIONS: { | 221 case PP_FLASHSETTING_LSORESTRICTIONS: { |
243 return PP_MakeInt32( | 222 return PP_MakeInt32( |
244 instance_->delegate()->GetLocalDataRestrictions( | 223 instance_->delegate()->GetLocalDataRestrictions( |
245 instance_->container()->element().document().url(), | 224 instance_->container()->element().document().url(), |
246 instance_->plugin_url())); | 225 instance_->plugin_url())); |
247 } | 226 } |
248 default: | 227 default: |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 return PP_TRUE; | 467 return PP_TRUE; |
489 } | 468 } |
490 | 469 |
491 PP_Bool PPB_Flash_Impl::FlashGetScreenSize(PP_Instance instance, | 470 PP_Bool PPB_Flash_Impl::FlashGetScreenSize(PP_Instance instance, |
492 PP_Size* size) { | 471 PP_Size* size) { |
493 return instance_->GetScreenSize(instance, size); | 472 return instance_->GetScreenSize(instance, size); |
494 } | 473 } |
495 | 474 |
496 } // namespace ppapi | 475 } // namespace ppapi |
497 } // namespace webkit | 476 } // namespace webkit |
OLD | NEW |