| 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 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 // here. V8ValueConverterImpl shouldn't actually care about the | 1471 // here. V8ValueConverterImpl shouldn't actually care about the |
| 1472 // context scope, and it switches to v8::Object's creation context | 1472 // context scope, and it switches to v8::Object's creation context |
| 1473 // when encountered. (from extensions/renderer/script_injection.cc) | 1473 // when encountered. (from extensions/renderer/script_injection.cc) |
| 1474 v8::Local<v8::Context> context = | 1474 v8::Local<v8::Context> context = |
| 1475 render_frame_impl_.get()->frame_->mainWorldScriptContext(); | 1475 render_frame_impl_.get()->frame_->mainWorldScriptContext(); |
| 1476 v8::Context::Scope context_scope(context); | 1476 v8::Context::Scope context_scope(context); |
| 1477 V8ValueConverterImpl converter; | 1477 V8ValueConverterImpl converter; |
| 1478 converter.SetDateAllowed(true); | 1478 converter.SetDateAllowed(true); |
| 1479 converter.SetRegExpAllowed(true); | 1479 converter.SetRegExpAllowed(true); |
| 1480 for (const auto& value : result) { | 1480 for (const auto& value : result) { |
| 1481 base::Value* result_value = converter.FromV8Value(value, context); | 1481 scoped_ptr<base::Value> result_value( |
| 1482 list.Append(result_value ? result_value | 1482 converter.FromV8Value(value, context)); |
| 1483 list.Append(result_value ? result_value.Pass() |
| 1483 : base::Value::CreateNullValue()); | 1484 : base::Value::CreateNullValue()); |
| 1484 } | 1485 } |
| 1485 } else { | 1486 } else { |
| 1486 list.Set(0, base::Value::CreateNullValue()); | 1487 list.Set(0, base::Value::CreateNullValue()); |
| 1487 } | 1488 } |
| 1488 render_frame_impl_.get()->Send( | 1489 render_frame_impl_.get()->Send( |
| 1489 new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id_, list)); | 1490 new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id_, list)); |
| 1490 } | 1491 } |
| 1491 | 1492 |
| 1492 delete this; | 1493 delete this; |
| 1493 } | 1494 } |
| 1494 | 1495 |
| 1495 void RenderFrameImpl::HandleJavascriptExecutionResult( | 1496 void RenderFrameImpl::HandleJavascriptExecutionResult( |
| 1496 const base::string16& jscript, | 1497 const base::string16& jscript, |
| 1497 int id, | 1498 int id, |
| 1498 bool notify_result, | 1499 bool notify_result, |
| 1499 v8::Local<v8::Value> result) { | 1500 v8::Local<v8::Value> result) { |
| 1500 if (notify_result) { | 1501 if (notify_result) { |
| 1501 base::ListValue list; | 1502 base::ListValue list; |
| 1502 if (!result.IsEmpty()) { | 1503 if (!result.IsEmpty()) { |
| 1503 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); | 1504 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); |
| 1504 v8::Context::Scope context_scope(context); | 1505 v8::Context::Scope context_scope(context); |
| 1505 V8ValueConverterImpl converter; | 1506 V8ValueConverterImpl converter; |
| 1506 converter.SetDateAllowed(true); | 1507 converter.SetDateAllowed(true); |
| 1507 converter.SetRegExpAllowed(true); | 1508 converter.SetRegExpAllowed(true); |
| 1508 base::Value* result_value = converter.FromV8Value(result, context); | 1509 scoped_ptr<base::Value> result_value( |
| 1509 list.Set(0, result_value ? result_value : base::Value::CreateNullValue()); | 1510 converter.FromV8Value(result, context)); |
| 1511 list.Set(0, result_value ? result_value.Pass() |
| 1512 : base::Value::CreateNullValue()); |
| 1510 } else { | 1513 } else { |
| 1511 list.Set(0, base::Value::CreateNullValue()); | 1514 list.Set(0, base::Value::CreateNullValue()); |
| 1512 } | 1515 } |
| 1513 Send(new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id, list)); | 1516 Send(new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id, list)); |
| 1514 } | 1517 } |
| 1515 } | 1518 } |
| 1516 | 1519 |
| 1517 void RenderFrameImpl::OnVisualStateRequest(uint64 id) { | 1520 void RenderFrameImpl::OnVisualStateRequest(uint64 id) { |
| 1518 GetRenderWidget()->QueueMessage( | 1521 GetRenderWidget()->QueueMessage( |
| 1519 new FrameHostMsg_VisualStateResponse(routing_id_, id), | 1522 new FrameHostMsg_VisualStateResponse(routing_id_, id), |
| (...skipping 3417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4937 #elif defined(ENABLE_BROWSER_CDMS) | 4940 #elif defined(ENABLE_BROWSER_CDMS) |
| 4938 cdm_manager_, | 4941 cdm_manager_, |
| 4939 #endif | 4942 #endif |
| 4940 this); | 4943 this); |
| 4941 } | 4944 } |
| 4942 | 4945 |
| 4943 return cdm_factory_; | 4946 return cdm_factory_; |
| 4944 } | 4947 } |
| 4945 | 4948 |
| 4946 } // namespace content | 4949 } // namespace content |
| OLD | NEW |