Index: chrome/browser/android/vr_shell/vr_shell.cc |
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc |
index edcbb68f0fe05e2c0f75e96229e281b9e33a5b32..6fe614e7092290851334de23d846d14e6d92582a 100644 |
--- a/chrome/browser/android/vr_shell/vr_shell.cc |
+++ b/chrome/browser/android/vr_shell/vr_shell.cc |
@@ -9,7 +9,9 @@ |
#include <string> |
#include <utility> |
+#include "base/android/jni_array.h" |
#include "base/android/jni_string.h" |
+#include "base/json/json_writer.h" |
#include "base/memory/ptr_util.h" |
#include "base/metrics/histogram_macros.h" |
#include "base/threading/platform_thread.h" |
@@ -397,6 +399,19 @@ void VrShell::SetHistoryButtonsEnabled(JNIEnv* env, |
html_interface_->SetHistoryButtonsEnabled(can_go_back, can_go_forward); |
} |
+void VrShell::RequestUiElementInfo(JNIEnv* env, |
+ const JavaParamRef<jobject>& obj, |
+ jintArray element_ids, |
+ jint callback_id) { |
+ std::vector<int> element_ids_vector; |
+ base::android::JavaIntArrayToIntVector(env, element_ids, &element_ids_vector); |
+ PostToGlThreadWhenReady( |
+ base::Bind(&VrShellGl::CreateUiElementInfos, gl_thread_->GetVrShellGl(), |
+ element_ids_vector, callback_id, |
+ base::Bind(&VrShell::OnUiElementInfoCreated, |
+ weak_ptr_factory_.GetWeakPtr()))); |
+} |
+ |
void VrShell::UiSurfaceChanged(jobject surface) { |
ui_compositor_->SurfaceChanged(surface); |
} |
@@ -539,6 +554,17 @@ void VrShell::DoUiAction(const UiAction action, |
} |
} |
+void VrShell::OnUiElementInfoCreated( |
+ int callback_id, |
+ std::unique_ptr<base::DictionaryValue> info) { |
+ std::string json_reply; |
+ base::JSONWriter::Write(*info, &json_reply); |
bsheedy
2017/03/24 18:47:54
Converting to a JSON string in native then back to
tiborg
2017/03/27 15:14:33
I'm not aware of a better solution either. I think
|
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ Java_VrShellImpl_replyToUiElementInfoRequest( |
+ env, j_vr_shell_.obj(), |
+ base::android::ConvertUTF8ToJavaString(env, json_reply), callback_id); |
+} |
+ |
void VrShell::RenderViewHostChanged(content::RenderViewHost* old_host, |
content::RenderViewHost* new_host) { |
content::RenderWidgetHostView* view = new_host->GetWidget()->GetView(); |