| 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 "ppapi/shared_impl/ppb_instance_shared.h" | 5 #include "ppapi/shared_impl/ppb_instance_shared.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "ppapi/c/pp_errors.h" | 11 #include "ppapi/c/pp_errors.h" |
| 12 #include "ppapi/c/ppb_input_event.h" | 12 #include "ppapi/c/ppb_input_event.h" |
| 13 #include "ppapi/shared_impl/ppapi_globals.h" | 13 #include "ppapi/shared_impl/ppapi_globals.h" |
| 14 #include "ppapi/shared_impl/ppb_image_data_shared.h" | 14 #include "ppapi/shared_impl/ppb_image_data_shared.h" |
| 15 #include "ppapi/shared_impl/var.h" | 15 #include "ppapi/shared_impl/var.h" |
| 16 #include "ppapi/thunk/enter.h" | 16 #include "ppapi/thunk/enter.h" |
| 17 #include "ppapi/thunk/ppb_image_data_api.h" | 17 #include "ppapi/thunk/ppb_image_data_api.h" |
| 18 | 18 |
| 19 namespace ppapi { | 19 namespace ppapi { |
| 20 | 20 |
| 21 // static | 21 // static |
| 22 const int PPB_Instance_Shared::kExtraCharsForTextInput = 100; | 22 const int PPB_Instance_Shared::kExtraCharsForTextInput = 100; |
| 23 | 23 |
| 24 PPB_Instance_Shared::~PPB_Instance_Shared() { | 24 PPB_Instance_Shared::~PPB_Instance_Shared() {} |
| 25 } | |
| 26 | 25 |
| 27 void PPB_Instance_Shared::Log(PP_Instance instance, | 26 void PPB_Instance_Shared::Log(PP_Instance instance, |
| 28 PP_LogLevel level, | 27 PP_LogLevel level, |
| 29 PP_Var value) { | 28 PP_Var value) { |
| 30 LogWithSource(instance, level, PP_MakeUndefined(), value); | 29 LogWithSource(instance, level, PP_MakeUndefined(), value); |
| 31 } | 30 } |
| 32 | 31 |
| 33 void PPB_Instance_Shared::LogWithSource(PP_Instance instance, | 32 void PPB_Instance_Shared::LogWithSource(PP_Instance instance, |
| 34 PP_LogLevel level, | 33 PP_LogLevel level, |
| 35 PP_Var source, | 34 PP_Var source, |
| 36 PP_Var value) { | 35 PP_Var value) { |
| 37 // The source defaults to empty if it's not a string. The PpapiGlobals | 36 // The source defaults to empty if it's not a string. The PpapiGlobals |
| 38 // implementation will convert the empty string to the module name if | 37 // implementation will convert the empty string to the module name if |
| 39 // possible. | 38 // possible. |
| 40 std::string source_str; | 39 std::string source_str; |
| 41 if (source.type == PP_VARTYPE_STRING) | 40 if (source.type == PP_VARTYPE_STRING) |
| 42 source_str = Var::PPVarToLogString(source); | 41 source_str = Var::PPVarToLogString(source); |
| 43 std::string value_str = Var::PPVarToLogString(value); | 42 std::string value_str = Var::PPVarToLogString(value); |
| 44 PpapiGlobals::Get()->LogWithSource(instance, level, source_str, value_str); | 43 PpapiGlobals::Get()->LogWithSource(instance, level, source_str, value_str); |
| 45 } | 44 } |
| 46 | 45 |
| 47 int32_t PPB_Instance_Shared::ValidateRequestInputEvents( | 46 int32_t PPB_Instance_Shared::ValidateRequestInputEvents( |
| 48 bool is_filtering, | 47 bool is_filtering, |
| 49 uint32_t event_classes) { | 48 uint32_t event_classes) { |
| 50 // See if any bits are set we don't know about. | 49 // See if any bits are set we don't know about. |
| 51 if (event_classes & | 50 if (event_classes & ~static_cast<uint32_t>(PP_INPUTEVENT_CLASS_MOUSE | |
| 52 ~static_cast<uint32_t>(PP_INPUTEVENT_CLASS_MOUSE | | 51 PP_INPUTEVENT_CLASS_KEYBOARD | |
| 53 PP_INPUTEVENT_CLASS_KEYBOARD | | 52 PP_INPUTEVENT_CLASS_WHEEL | |
| 54 PP_INPUTEVENT_CLASS_WHEEL | | 53 PP_INPUTEVENT_CLASS_TOUCH | |
| 55 PP_INPUTEVENT_CLASS_TOUCH | | 54 PP_INPUTEVENT_CLASS_IME)) |
| 56 PP_INPUTEVENT_CLASS_IME)) | |
| 57 return PP_ERROR_NOTSUPPORTED; | 55 return PP_ERROR_NOTSUPPORTED; |
| 58 | 56 |
| 59 // Everything else is valid. | 57 // Everything else is valid. |
| 60 return PP_OK; | 58 return PP_OK; |
| 61 } | 59 } |
| 62 | 60 |
| 63 bool PPB_Instance_Shared::ValidateSetCursorParams(PP_MouseCursor_Type type, | 61 bool PPB_Instance_Shared::ValidateSetCursorParams(PP_MouseCursor_Type type, |
| 64 PP_Resource image, | 62 PP_Resource image, |
| 65 const PP_Point* hot_spot) { | 63 const PP_Point* hot_spot) { |
| 66 if (static_cast<int>(type) < static_cast<int>(PP_MOUSECURSOR_TYPE_CUSTOM) || | 64 if (static_cast<int>(type) < static_cast<int>(PP_MOUSECURSOR_TYPE_CUSTOM) || |
| (...skipping 20 matching lines...) Expand all Loading... |
| 87 if (!PP_ToBool(enter.object()->Describe(&desc))) | 85 if (!PP_ToBool(enter.object()->Describe(&desc))) |
| 88 return false; | 86 return false; |
| 89 if (desc.size.width > 32 || desc.size.height > 32) | 87 if (desc.size.width > 32 || desc.size.height > 32) |
| 90 return false; | 88 return false; |
| 91 | 89 |
| 92 // Validate image format. | 90 // Validate image format. |
| 93 if (desc.format != PPB_ImageData_Shared::GetNativeImageDataFormat()) | 91 if (desc.format != PPB_ImageData_Shared::GetNativeImageDataFormat()) |
| 94 return false; | 92 return false; |
| 95 | 93 |
| 96 // Validate the hot spot location. | 94 // Validate the hot spot location. |
| 97 if (hot_spot->x < 0 || hot_spot->x >= desc.size.width || | 95 if (hot_spot->x < 0 || hot_spot->x >= desc.size.width || hot_spot->y < 0 || |
| 98 hot_spot->y < 0 || hot_spot->y >= desc.size.height) | 96 hot_spot->y >= desc.size.height) |
| 99 return false; | 97 return false; |
| 100 return true; | 98 return true; |
| 101 } | 99 } |
| 102 | 100 |
| 103 } // namespace ppapi | 101 } // namespace ppapi |
| OLD | NEW |