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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 ScopedJavaLocalRef<jstring> j_json = ConvertUTF8ToJavaString(env, json); 1465 ScopedJavaLocalRef<jstring> j_json = ConvertUTF8ToJavaString(env, json);
1466 Java_ContentViewCore_onEvaluateJavaScriptResult(env, 1466 Java_ContentViewCore_onEvaluateJavaScriptResult(env,
1467 j_json.obj(), 1467 j_json.obj(),
1468 callback.obj()); 1468 callback.obj());
1469 } 1469 }
1470 } // namespace 1470 } // namespace
1471 1471
1472 void ContentViewCoreImpl::EvaluateJavaScript(JNIEnv* env, 1472 void ContentViewCoreImpl::EvaluateJavaScript(JNIEnv* env,
1473 jobject obj, 1473 jobject obj,
1474 jstring script, 1474 jstring script,
1475 jobject callback) { 1475 jobject callback,
1476 RenderViewHost* host = web_contents_->GetRenderViewHost(); 1476 jboolean start_renderer) {
1477 DCHECK(host); 1477 RenderViewHost* rvh =
1478 static_cast<RenderViewHost*>(web_contents_->GetRenderViewHost());
1479 DCHECK(rvh);
1480
1481 WebContentsImpl* web_contents_impl =
1482 static_cast<WebContentsImpl*>(web_contents_);
joth 2013/08/20 05:00:44 just use web_contents_ -- it's already of type We
michaelbai 2013/08/20 19:15:20 Done.
1483 if (start_renderer && !rvh->IsRenderViewLive()) {
1484 if (!web_contents_impl->CreateRenderView(rvh, MSG_ROUTING_NONE, -1)) {
joth 2013/08/20 05:00:44 this looks kind of complex, and the change in WebC
michaelbai 2013/08/20 19:15:20 Tried, it didn't work, it seemed that a swapped ou
1485 LOG(ERROR) <<
1486 "Falied to create RenderView in EvaluateJavaScript";
1487 return;
1488 }
1489 }
1478 1490
1479 if (!callback) { 1491 if (!callback) {
1480 // No callback requested. 1492 // No callback requested.
1481 host->ExecuteJavascriptInWebFrame(string16(), // frame_xpath 1493 rvh->ExecuteJavascriptInWebFrame(string16(), // frame_xpath
1482 ConvertJavaStringToUTF16(env, script)); 1494 ConvertJavaStringToUTF16(env, script));
1483 return; 1495 return;
1484 } 1496 }
1485 1497
1486 // Secure the Java callback in a scoped object and give ownership of it to the 1498 // Secure the Java callback in a scoped object and give ownership of it to the
1487 // base::Callback. 1499 // base::Callback.
1488 ScopedJavaGlobalRef<jobject> j_callback; 1500 ScopedJavaGlobalRef<jobject> j_callback;
1489 j_callback.Reset(env, callback); 1501 j_callback.Reset(env, callback);
1490 content::RenderViewHost::JavascriptResultCallback c_callback = 1502 content::RenderViewHost::JavascriptResultCallback c_callback =
1491 base::Bind(&JavaScriptResultCallback, j_callback); 1503 base::Bind(&JavaScriptResultCallback, j_callback);
1492 1504
1493 host->ExecuteJavascriptInWebFrameCallbackResult( 1505 rvh->ExecuteJavascriptInWebFrameCallbackResult(
1494 string16(), // frame_xpath 1506 string16(), // frame_xpath
1495 ConvertJavaStringToUTF16(env, script), 1507 ConvertJavaStringToUTF16(env, script),
1496 c_callback); 1508 c_callback);
1497 } 1509 }
1498 1510
1499 bool ContentViewCoreImpl::GetUseDesktopUserAgent( 1511 bool ContentViewCoreImpl::GetUseDesktopUserAgent(
1500 JNIEnv* env, jobject obj) { 1512 JNIEnv* env, jobject obj) {
1501 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); 1513 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry();
1502 return entry && entry->GetIsOverridingUserAgent(); 1514 return entry && entry->GetIsOverridingUserAgent();
1503 } 1515 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 reinterpret_cast<ui::ViewAndroid*>(view_android), 1606 reinterpret_cast<ui::ViewAndroid*>(view_android),
1595 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1607 reinterpret_cast<ui::WindowAndroid*>(window_android));
1596 return reinterpret_cast<jint>(view); 1608 return reinterpret_cast<jint>(view);
1597 } 1609 }
1598 1610
1599 bool RegisterContentViewCore(JNIEnv* env) { 1611 bool RegisterContentViewCore(JNIEnv* env) {
1600 return RegisterNativesImpl(env); 1612 return RegisterNativesImpl(env);
1601 } 1613 }
1602 1614
1603 } // namespace content 1615 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698