Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 23018005: Start renderer in ContentViewCoreImpl::EvaluateJavaScript. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698