| Index: webkit/plugins/ppapi/ppb_websocket_impl.cc
|
| diff --git a/webkit/plugins/ppapi/ppb_websocket_impl.cc b/webkit/plugins/ppapi/ppb_websocket_impl.cc
|
| index 9157b67c92f896a90d622c407f718452cbc658de..5851be38556286aee9554db8aa60fc7b9fb14bc7 100644
|
| --- a/webkit/plugins/ppapi/ppb_websocket_impl.cc
|
| +++ b/webkit/plugins/ppapi/ppb_websocket_impl.cc
|
| @@ -223,12 +223,17 @@ int32_t PPB_WebSocket_Impl::Close(uint16_t code,
|
| return PP_ERROR_NOACCESS;
|
| }
|
|
|
| - // Validate |reason|.
|
| - // TODO(toyoshim): Returns PP_ERROR_BADARGUMENT if |reason| contains any
|
| - // surrogates.
|
| - scoped_refptr<StringVar> reason_string = StringVar::FromPPVar(reason);
|
| - if (!reason_string || reason_string->value().size() > kMaxReasonSizeInBytes)
|
| - return PP_ERROR_BADARGUMENT;
|
| + scoped_refptr<StringVar> reason_string;
|
| + WebString web_reason;
|
| + // |reason| must be ignored if it is PP_VARTYPE_UNDEFINED.
|
| + if (reason.type != PP_VARTYPE_UNDEFINED) {
|
| + // Validate |reason|.
|
| + reason_string = StringVar::FromPPVar(reason);
|
| + if (!reason_string ||
|
| + reason_string->value().size() > kMaxReasonSizeInBytes)
|
| + return PP_ERROR_BADARGUMENT;
|
| + web_reason = WebString::fromUTF8(reason_string->value());
|
| + }
|
|
|
| // Check state.
|
| if (state_ == PP_WEBSOCKETREADYSTATE_CLOSING ||
|
| @@ -265,7 +270,6 @@ int32_t PPB_WebSocket_Impl::Close(uint16_t code,
|
|
|
| // Close connection.
|
| state_ = PP_WEBSOCKETREADYSTATE_CLOSING;
|
| - WebString web_reason = WebString::fromUTF8(reason_string->value());
|
| websocket_->close(code, web_reason);
|
|
|
| return PP_OK_COMPLETIONPENDING;
|
|
|