| Index: content/browser/webui/web_ui_impl.cc
|
| diff --git a/content/browser/webui/web_ui_impl.cc b/content/browser/webui/web_ui_impl.cc
|
| index c4c5b63306701f475c23d9a1c463bd1c2d60a6f2..41fc037852c786645705881beed7ad9ca6d0e0fa 100644
|
| --- a/content/browser/webui/web_ui_impl.cc
|
| +++ b/content/browser/webui/web_ui_impl.cc
|
| @@ -144,6 +144,16 @@ void WebUIImpl::SetController(WebUIController* controller) {
|
| controller_.reset(controller);
|
| }
|
|
|
| +bool WebUIImpl::CanCallJavascript() {
|
| + RenderFrameHost* target_frame = TargetFrame();
|
| + return target_frame &&
|
| + (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
|
| + target_frame->GetProcess()->GetID()) ||
|
| + // It's possible to load about:blank in a Web UI renderer.
|
| + // See http://crbug.com/42547
|
| + target_frame->GetLastCommittedURL().spec() == url::kAboutBlankURL);
|
| +}
|
| +
|
| void WebUIImpl::CallJavascriptFunction(const std::string& function_name) {
|
| DCHECK(base::IsStringASCII(function_name));
|
| base::string16 javascript = base::ASCIIToUTF16(function_name + "();");
|
| @@ -233,19 +243,12 @@ void WebUIImpl::AddMessageHandler(WebUIMessageHandler* handler) {
|
| }
|
|
|
| void WebUIImpl::ExecuteJavascript(const base::string16& javascript) {
|
| - RenderFrameHost* target_frame = TargetFrame();
|
| - if (target_frame) {
|
| - if (!(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
|
| - target_frame->GetProcess()->GetID()) ||
|
| - // It's possible to load about:blank in a Web UI renderer.
|
| - // See http://crbug.com/42547
|
| - target_frame->GetLastCommittedURL().spec() == url::kAboutBlankURL)) {
|
| - // Silently ignore the request. Would be nice to clean-up WebUI so we
|
| - // could turn this into a CHECK(). http://crbug.com/516690.
|
| - return;
|
| - }
|
| - target_frame->ExecuteJavaScript(javascript);
|
| - }
|
| + // Silently ignore the request. Would be nice to clean-up WebUI so we
|
| + // could turn this into a CHECK(). http://crbug.com/516690.
|
| + if (!CanCallJavascript())
|
| + return;
|
| +
|
| + TargetFrame()->ExecuteJavaScript(javascript);
|
| }
|
|
|
| RenderFrameHost* WebUIImpl::TargetFrame() {
|
|
|