| 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 "content/renderer/dom_automation_controller.h" | 5 #include "content/renderer/dom_automation_controller.h" |
| 6 | 6 |
| 7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "content/child/v8_value_converter_impl.h" | 9 #include "content/child/v8_value_converter_impl.h" |
| 10 #include "content/common/child_process_messages.h" | 10 #include "content/common/child_process_messages.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Warning: note that JSON officially requires the root-level object to be | 95 // Warning: note that JSON officially requires the root-level object to be |
| 96 // an object (e.g. {foo:3}) or an array, while here we're serializing | 96 // an object (e.g. {foo:3}) or an array, while here we're serializing |
| 97 // strings, bools, etc. to "JSON". This only works because (a) the JSON | 97 // strings, bools, etc. to "JSON". This only works because (a) the JSON |
| 98 // writer is lenient, and (b) on the receiving side we wrap the JSON string | 98 // writer is lenient, and (b) on the receiving side we wrap the JSON string |
| 99 // in square brackets, converting it to an array, then parsing it and | 99 // in square brackets, converting it to an array, then parsing it and |
| 100 // grabbing the 0th element to get the value out. | 100 // grabbing the 0th element to get the value out. |
| 101 if (!args.PeekNext().IsEmpty() && | 101 if (!args.PeekNext().IsEmpty() && |
| 102 (args.PeekNext()->IsString() || args.PeekNext()->IsBoolean() || | 102 (args.PeekNext()->IsString() || args.PeekNext()->IsBoolean() || |
| 103 args.PeekNext()->IsNumber())) { | 103 args.PeekNext()->IsNumber())) { |
| 104 V8ValueConverterImpl conv; | 104 V8ValueConverterImpl conv; |
| 105 value.reset( | 105 value = |
| 106 conv.FromV8Value(args.PeekNext(), args.isolate()->GetCurrentContext())); | 106 conv.FromV8Value(args.PeekNext(), args.isolate()->GetCurrentContext()); |
| 107 } else { | 107 } else { |
| 108 return false; | 108 return false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 if (!serializer.Serialize(*value)) | 111 if (!serializer.Serialize(*value)) |
| 112 return false; | 112 return false; |
| 113 | 113 |
| 114 bool succeeded = Send(new FrameHostMsg_DomOperationResponse( | 114 bool succeeded = Send(new FrameHostMsg_DomOperationResponse( |
| 115 routing_id(), json)); | 115 routing_id(), json)); |
| 116 | 116 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 138 return Send( | 138 return Send( |
| 139 new FrameHostMsg_DomOperationResponse(routing_id(), str)); | 139 new FrameHostMsg_DomOperationResponse(routing_id(), str)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool DomAutomationController::SetAutomationId(int automation_id) { | 142 bool DomAutomationController::SetAutomationId(int automation_id) { |
| 143 automation_id_ = automation_id; | 143 automation_id_ = automation_id; |
| 144 return true; | 144 return true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace content | 147 } // namespace content |
| OLD | NEW |