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 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1467 } | 1467 } |
1468 | 1468 |
1469 void RenderFrameImpl::OnJavaScriptExecuteRequest( | 1469 void RenderFrameImpl::OnJavaScriptExecuteRequest( |
1470 const base::string16& jscript, | 1470 const base::string16& jscript, |
1471 int id, | 1471 int id, |
1472 bool notify_result) { | 1472 bool notify_result) { |
1473 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequest", | 1473 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequest", |
1474 TRACE_EVENT_SCOPE_THREAD); | 1474 TRACE_EVENT_SCOPE_THREAD); |
1475 | 1475 |
1476 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 1476 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
1477 v8::Handle<v8::Value> result = | 1477 v8::Local<v8::Value> result = |
1478 frame_->executeScriptAndReturnValue(WebScriptSource(jscript)); | 1478 frame_->executeScriptAndReturnValue(WebScriptSource(jscript)); |
1479 | 1479 |
1480 HandleJavascriptExecutionResult(jscript, id, notify_result, result); | 1480 HandleJavascriptExecutionResult(jscript, id, notify_result, result); |
1481 } | 1481 } |
1482 | 1482 |
1483 void RenderFrameImpl::OnJavaScriptExecuteRequestForTests( | 1483 void RenderFrameImpl::OnJavaScriptExecuteRequestForTests( |
1484 const base::string16& jscript, | 1484 const base::string16& jscript, |
1485 int id, | 1485 int id, |
1486 bool notify_result) { | 1486 bool notify_result) { |
1487 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequestForTests", | 1487 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequestForTests", |
1488 TRACE_EVENT_SCOPE_THREAD); | 1488 TRACE_EVENT_SCOPE_THREAD); |
1489 | 1489 |
1490 // A bunch of tests expect to run code in the context of a user gesture, which | 1490 // A bunch of tests expect to run code in the context of a user gesture, which |
1491 // can grant additional privileges (e.g. the ability to create popups). | 1491 // can grant additional privileges (e.g. the ability to create popups). |
1492 blink::WebScopedUserGesture gesture; | 1492 blink::WebScopedUserGesture gesture; |
1493 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 1493 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
1494 v8::Handle<v8::Value> result = | 1494 v8::Local<v8::Value> result = |
1495 frame_->executeScriptAndReturnValue(WebScriptSource(jscript)); | 1495 frame_->executeScriptAndReturnValue(WebScriptSource(jscript)); |
1496 | 1496 |
1497 HandleJavascriptExecutionResult(jscript, id, notify_result, result); | 1497 HandleJavascriptExecutionResult(jscript, id, notify_result, result); |
1498 } | 1498 } |
1499 | 1499 |
1500 void RenderFrameImpl::HandleJavascriptExecutionResult( | 1500 void RenderFrameImpl::HandleJavascriptExecutionResult( |
1501 const base::string16& jscript, | 1501 const base::string16& jscript, |
1502 int id, | 1502 int id, |
1503 bool notify_result, | 1503 bool notify_result, |
1504 v8::Handle<v8::Value> result) { | 1504 v8::Local<v8::Value> result) { |
1505 if (notify_result) { | 1505 if (notify_result) { |
1506 base::ListValue list; | 1506 base::ListValue list; |
1507 if (!result.IsEmpty()) { | 1507 if (!result.IsEmpty()) { |
1508 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); | 1508 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); |
1509 v8::Context::Scope context_scope(context); | 1509 v8::Context::Scope context_scope(context); |
1510 V8ValueConverterImpl converter; | 1510 V8ValueConverterImpl converter; |
1511 converter.SetDateAllowed(true); | 1511 converter.SetDateAllowed(true); |
1512 converter.SetRegExpAllowed(true); | 1512 converter.SetRegExpAllowed(true); |
1513 base::Value* result_value = converter.FromV8Value(result, context); | 1513 base::Value* result_value = converter.FromV8Value(result, context); |
1514 list.Set(0, result_value ? result_value : base::Value::CreateNullValue()); | 1514 list.Set(0, result_value ? result_value : base::Value::CreateNullValue()); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 | 1652 |
1653 WebSerializedScriptValue serialized_script_value; | 1653 WebSerializedScriptValue serialized_script_value; |
1654 if (params.is_data_raw_string) { | 1654 if (params.is_data_raw_string) { |
1655 v8::HandleScope handle_scope(blink::mainThreadIsolate()); | 1655 v8::HandleScope handle_scope(blink::mainThreadIsolate()); |
1656 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); | 1656 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); |
1657 v8::Context::Scope context_scope(context); | 1657 v8::Context::Scope context_scope(context); |
1658 V8ValueConverterImpl converter; | 1658 V8ValueConverterImpl converter; |
1659 converter.SetDateAllowed(true); | 1659 converter.SetDateAllowed(true); |
1660 converter.SetRegExpAllowed(true); | 1660 converter.SetRegExpAllowed(true); |
1661 scoped_ptr<base::Value> value(new base::StringValue(params.data)); | 1661 scoped_ptr<base::Value> value(new base::StringValue(params.data)); |
1662 v8::Handle<v8::Value> result_value = converter.ToV8Value(value.get(), | 1662 v8::Local<v8::Value> result_value = converter.ToV8Value(value.get(), |
1663 context); | 1663 context); |
1664 serialized_script_value = WebSerializedScriptValue::serialize(result_value); | 1664 serialized_script_value = WebSerializedScriptValue::serialize(result_value); |
1665 } else { | 1665 } else { |
1666 serialized_script_value = WebSerializedScriptValue::fromString(params.data); | 1666 serialized_script_value = WebSerializedScriptValue::fromString(params.data); |
1667 } | 1667 } |
1668 | 1668 |
1669 // Create an event with the message. The next-to-last parameter to | 1669 // Create an event with the message. The next-to-last parameter to |
1670 // initMessageEvent is the last event ID, which is not used with postMessage. | 1670 // initMessageEvent is the last event ID, which is not used with postMessage. |
1671 WebDOMEvent event = frame_->document().createEvent("MessageEvent"); | 1671 WebDOMEvent event = frame_->document().createEvent("MessageEvent"); |
1672 WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>(); | 1672 WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>(); |
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3453 DCHECK(!frame_ || frame_ == frame); | 3453 DCHECK(!frame_ || frame_ == frame); |
3454 #if defined(ENABLE_PLUGINS) | 3454 #if defined(ENABLE_PLUGINS) |
3455 if (frame != render_view_->webview()->mainFrame()) | 3455 if (frame != render_view_->webview()->mainFrame()) |
3456 return; | 3456 return; |
3457 PluginChannelHost::Broadcast( | 3457 PluginChannelHost::Broadcast( |
3458 new PluginHostMsg_DidAbortLoading(render_view_->GetRoutingID())); | 3458 new PluginHostMsg_DidAbortLoading(render_view_->GetRoutingID())); |
3459 #endif | 3459 #endif |
3460 } | 3460 } |
3461 | 3461 |
3462 void RenderFrameImpl::didCreateScriptContext(blink::WebLocalFrame* frame, | 3462 void RenderFrameImpl::didCreateScriptContext(blink::WebLocalFrame* frame, |
3463 v8::Handle<v8::Context> context, | 3463 v8::Local<v8::Context> context, |
3464 int extension_group, | 3464 int extension_group, |
3465 int world_id) { | 3465 int world_id) { |
3466 DCHECK(!frame_ || frame_ == frame); | 3466 DCHECK(!frame_ || frame_ == frame); |
3467 | 3467 |
3468 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 3468 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
3469 DidCreateScriptContext(context, extension_group, world_id)); | 3469 DidCreateScriptContext(context, extension_group, world_id)); |
3470 } | 3470 } |
3471 | 3471 |
3472 void RenderFrameImpl::willReleaseScriptContext(blink::WebLocalFrame* frame, | 3472 void RenderFrameImpl::willReleaseScriptContext(blink::WebLocalFrame* frame, |
3473 v8::Handle<v8::Context> context, | 3473 v8::Local<v8::Context> context, |
3474 int world_id) { | 3474 int world_id) { |
3475 DCHECK(!frame_ || frame_ == frame); | 3475 DCHECK(!frame_ || frame_ == frame); |
3476 | 3476 |
3477 FOR_EACH_OBSERVER(RenderFrameObserver, | 3477 FOR_EACH_OBSERVER(RenderFrameObserver, |
3478 observers_, | 3478 observers_, |
3479 WillReleaseScriptContext(context, world_id)); | 3479 WillReleaseScriptContext(context, world_id)); |
3480 } | 3480 } |
3481 | 3481 |
3482 void RenderFrameImpl::didFirstVisuallyNonEmptyLayout( | 3482 void RenderFrameImpl::didFirstVisuallyNonEmptyLayout( |
3483 blink::WebLocalFrame* frame) { | 3483 blink::WebLocalFrame* frame) { |
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4853 #elif defined(ENABLE_BROWSER_CDMS) | 4853 #elif defined(ENABLE_BROWSER_CDMS) |
4854 cdm_manager_, | 4854 cdm_manager_, |
4855 #endif | 4855 #endif |
4856 this); | 4856 this); |
4857 } | 4857 } |
4858 | 4858 |
4859 return cdm_factory_; | 4859 return cdm_factory_; |
4860 } | 4860 } |
4861 | 4861 |
4862 } // namespace content | 4862 } // namespace content |
OLD | NEW |