Chromium Code Reviews| Index: content/browser/android/content_view_core_impl.cc |
| diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc |
| index 80fe628dd022781a85a0bd56fe22b32d2d270490..e72de5f1aaa24a94af00d2854a454d6d163affa6 100644 |
| --- a/content/browser/android/content_view_core_impl.cc |
| +++ b/content/browser/android/content_view_core_impl.cc |
| @@ -1472,14 +1472,23 @@ void JavaScriptResultCallback(const ScopedJavaGlobalRef<jobject>& callback, |
| void ContentViewCoreImpl::EvaluateJavaScript(JNIEnv* env, |
| jobject obj, |
| jstring script, |
| - jobject callback) { |
| - RenderViewHost* host = web_contents_->GetRenderViewHost(); |
| - DCHECK(host); |
| + jobject callback, |
| + jboolean start_renderer) { |
| + RenderViewHost* rvh = |
| + static_cast<RenderViewHost*>(web_contents_->GetRenderViewHost()); |
| + DCHECK(rvh); |
| + |
| + if (start_renderer && !rvh->IsRenderViewLive()) { |
| + if (!web_contents_->CreateRenderViewWithoutNavigationEntry(rvh)) { |
|
Charlie Reis
2013/08/20 22:03:49
Maybe navigate it to about:blank first instead?
michaelbai
2013/08/21 23:32:17
Already tried, the Java context can not be transfe
|
| + LOG(ERROR) << "Falied to create RenderView in EvaluateJavaScript"; |
|
Charlie Reis
2013/08/20 22:03:49
nit: Failed
michaelbai
2013/08/21 23:32:17
Done.
|
| + return; |
| + } |
| + } |
| if (!callback) { |
| // No callback requested. |
| - host->ExecuteJavascriptInWebFrame(string16(), // frame_xpath |
| - ConvertJavaStringToUTF16(env, script)); |
| + rvh->ExecuteJavascriptInWebFrame(string16(), // frame_xpath |
| + ConvertJavaStringToUTF16(env, script)); |
| return; |
| } |
| @@ -1490,7 +1499,7 @@ void ContentViewCoreImpl::EvaluateJavaScript(JNIEnv* env, |
| content::RenderViewHost::JavascriptResultCallback c_callback = |
| base::Bind(&JavaScriptResultCallback, j_callback); |
| - host->ExecuteJavascriptInWebFrameCallbackResult( |
| + rvh->ExecuteJavascriptInWebFrameCallbackResult( |
| string16(), // frame_xpath |
| ConvertJavaStringToUTF16(env, script), |
| c_callback); |