| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 // here. V8ValueConverterImpl shouldn't actually care about the | 1477 // here. V8ValueConverterImpl shouldn't actually care about the |
| 1478 // context scope, and it switches to v8::Object's creation context | 1478 // context scope, and it switches to v8::Object's creation context |
| 1479 // when encountered. (from extensions/renderer/script_injection.cc) | 1479 // when encountered. (from extensions/renderer/script_injection.cc) |
| 1480 v8::Local<v8::Context> context = | 1480 v8::Local<v8::Context> context = |
| 1481 render_frame_impl_.get()->frame_->mainWorldScriptContext(); | 1481 render_frame_impl_.get()->frame_->mainWorldScriptContext(); |
| 1482 v8::Context::Scope context_scope(context); | 1482 v8::Context::Scope context_scope(context); |
| 1483 V8ValueConverterImpl converter; | 1483 V8ValueConverterImpl converter; |
| 1484 converter.SetDateAllowed(true); | 1484 converter.SetDateAllowed(true); |
| 1485 converter.SetRegExpAllowed(true); | 1485 converter.SetRegExpAllowed(true); |
| 1486 for (const auto& value : result) { | 1486 for (const auto& value : result) { |
| 1487 base::Value* result_value = converter.FromV8Value(value, context); | 1487 scoped_ptr<base::Value> result_value( |
| 1488 list.Append(result_value ? result_value | 1488 converter.FromV8Value(value, context)); |
| 1489 list.Append(result_value ? result_value.Pass() |
| 1489 : base::Value::CreateNullValue()); | 1490 : base::Value::CreateNullValue()); |
| 1490 } | 1491 } |
| 1491 } else { | 1492 } else { |
| 1492 list.Set(0, base::Value::CreateNullValue()); | 1493 list.Set(0, base::Value::CreateNullValue()); |
| 1493 } | 1494 } |
| 1494 render_frame_impl_.get()->Send( | 1495 render_frame_impl_.get()->Send( |
| 1495 new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id_, list)); | 1496 new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id_, list)); |
| 1496 } | 1497 } |
| 1497 | 1498 |
| 1498 delete this; | 1499 delete this; |
| 1499 } | 1500 } |
| 1500 | 1501 |
| 1501 void RenderFrameImpl::HandleJavascriptExecutionResult( | 1502 void RenderFrameImpl::HandleJavascriptExecutionResult( |
| 1502 const base::string16& jscript, | 1503 const base::string16& jscript, |
| 1503 int id, | 1504 int id, |
| 1504 bool notify_result, | 1505 bool notify_result, |
| 1505 v8::Local<v8::Value> result) { | 1506 v8::Local<v8::Value> result) { |
| 1506 if (notify_result) { | 1507 if (notify_result) { |
| 1507 base::ListValue list; | 1508 base::ListValue list; |
| 1508 if (!result.IsEmpty()) { | 1509 if (!result.IsEmpty()) { |
| 1509 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); | 1510 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); |
| 1510 v8::Context::Scope context_scope(context); | 1511 v8::Context::Scope context_scope(context); |
| 1511 V8ValueConverterImpl converter; | 1512 V8ValueConverterImpl converter; |
| 1512 converter.SetDateAllowed(true); | 1513 converter.SetDateAllowed(true); |
| 1513 converter.SetRegExpAllowed(true); | 1514 converter.SetRegExpAllowed(true); |
| 1514 base::Value* result_value = converter.FromV8Value(result, context); | 1515 scoped_ptr<base::Value> result_value( |
| 1515 list.Set(0, result_value ? result_value : base::Value::CreateNullValue()); | 1516 converter.FromV8Value(result, context)); |
| 1517 list.Set(0, result_value ? result_value.Pass() |
| 1518 : base::Value::CreateNullValue()); |
| 1516 } else { | 1519 } else { |
| 1517 list.Set(0, base::Value::CreateNullValue()); | 1520 list.Set(0, base::Value::CreateNullValue()); |
| 1518 } | 1521 } |
| 1519 Send(new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id, list)); | 1522 Send(new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id, list)); |
| 1520 } | 1523 } |
| 1521 } | 1524 } |
| 1522 | 1525 |
| 1523 void RenderFrameImpl::OnVisualStateRequest(uint64 id) { | 1526 void RenderFrameImpl::OnVisualStateRequest(uint64 id) { |
| 1524 GetRenderWidget()->QueueMessage( | 1527 GetRenderWidget()->QueueMessage( |
| 1525 new FrameHostMsg_VisualStateResponse(routing_id_, id), | 1528 new FrameHostMsg_VisualStateResponse(routing_id_, id), |
| (...skipping 3441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4967 #elif defined(ENABLE_BROWSER_CDMS) | 4970 #elif defined(ENABLE_BROWSER_CDMS) |
| 4968 cdm_manager_, | 4971 cdm_manager_, |
| 4969 #endif | 4972 #endif |
| 4970 this); | 4973 this); |
| 4971 } | 4974 } |
| 4972 | 4975 |
| 4973 return cdm_factory_; | 4976 return cdm_factory_; |
| 4974 } | 4977 } |
| 4975 | 4978 |
| 4976 } // namespace content | 4979 } // namespace content |
| OLD | NEW |