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

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

Issue 464393002: Restructuring WebContents functions from ContentViewCore to WebContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed C++ variable naming issues. Created 6 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 879a883eae7c80dfb5d8a6298b283f5985938d2e..47ece9986157a055c19fb832fc8b3fc97caf9c69 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -9,7 +9,6 @@
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
#include "base/command_line.h"
-#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/strings/utf_string_conversions.h"
@@ -67,7 +66,6 @@ using base::android::ConvertJavaStringToUTF16;
using base::android::ConvertJavaStringToUTF8;
using base::android::ConvertUTF16ToJavaString;
using base::android::ConvertUTF8ToJavaString;
-using base::android::ScopedJavaGlobalRef;
using base::android::ScopedJavaLocalRef;
using blink::WebGestureEvent;
using blink::WebInputEvent;
@@ -1309,53 +1307,6 @@ long ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) {
return rwhva->GetNativeImeAdapter();
}
-namespace {
-void JavaScriptResultCallback(const ScopedJavaGlobalRef<jobject>& callback,
- const base::Value* result) {
- JNIEnv* env = base::android::AttachCurrentThread();
- std::string json;
- base::JSONWriter::Write(result, &json);
- ScopedJavaLocalRef<jstring> j_json = ConvertUTF8ToJavaString(env, json);
- Java_ContentViewCore_onEvaluateJavaScriptResult(env,
- j_json.obj(),
- callback.obj());
-}
-} // namespace
-
-void ContentViewCoreImpl::EvaluateJavaScript(JNIEnv* env,
- jobject obj,
- jstring script,
- jobject callback,
- jboolean start_renderer) {
- RenderViewHost* rvh = web_contents_->GetRenderViewHost();
- DCHECK(rvh);
-
- if (start_renderer && !rvh->IsRenderViewLive()) {
- if (!web_contents_->CreateRenderViewForInitialEmptyDocument()) {
- LOG(ERROR) << "Failed to create RenderView in EvaluateJavaScript";
- return;
- }
- }
-
- if (!callback) {
- // No callback requested.
- web_contents_->GetMainFrame()->ExecuteJavaScript(
- ConvertJavaStringToUTF16(env, script));
- return;
- }
-
- // Secure the Java callback in a scoped object and give ownership of it to the
- // base::Callback.
- ScopedJavaGlobalRef<jobject> j_callback;
- j_callback.Reset(env, callback);
- content::RenderFrameHost::JavaScriptResultCallback c_callback =
- base::Bind(&JavaScriptResultCallback, j_callback);
-
- web_contents_->GetMainFrame()->ExecuteJavaScript(
- ConvertJavaStringToUTF16(env, script),
- c_callback);
-}
-
// TODO(sgurun) add support for posting a frame whose name is known (only
// main frame is supported at this time, see crbug.com/389721)
// TODO(sgurun) add support for passing message ports
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/web_contents/web_contents_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698