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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2461503002: Provide URL-related info to the VR HTML UI. (Closed)
Patch Set: Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/android/vr_shell/vr_shell.h" 5 #include "chrome/browser/android/vr_shell/vr_shell.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "chrome/browser/android/vr_shell/ui_elements.h" 8 #include "chrome/browser/android/vr_shell/ui_elements.h"
9 #include "chrome/browser/android/vr_shell/ui_interface.h" 9 #include "chrome/browser/android/vr_shell/ui_interface.h"
10 #include "chrome/browser/android/vr_shell/ui_scene.h" 10 #include "chrome/browser/android/vr_shell/ui_scene.h"
11 #include "chrome/browser/android/vr_shell/vr_compositor.h" 11 #include "chrome/browser/android/vr_shell/vr_compositor.h"
12 #include "chrome/browser/android/vr_shell/vr_controller.h" 12 #include "chrome/browser/android/vr_shell/vr_controller.h"
13 #include "chrome/browser/android/vr_shell/vr_gesture.h" 13 #include "chrome/browser/android/vr_shell/vr_gesture.h"
14 #include "chrome/browser/android/vr_shell/vr_gl_util.h" 14 #include "chrome/browser/android/vr_shell/vr_gl_util.h"
15 #include "chrome/browser/android/vr_shell/vr_input_manager.h" 15 #include "chrome/browser/android/vr_shell/vr_input_manager.h"
16 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" 16 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
17 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" 17 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
18 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h"
18 #include "content/public/browser/navigation_controller.h" 19 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/render_widget_host.h" 20 #include "content/public/browser/render_widget_host.h"
20 #include "content/public/browser/render_widget_host_view.h" 21 #include "content/public/browser/render_widget_host_view.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/referrer.h" 23 #include "content/public/common/referrer.h"
23 #include "content/public/common/screen_info.h" 24 #include "content/public/common/screen_info.h"
24 #include "jni/VrShellImpl_jni.h" 25 #include "jni/VrShellImpl_jni.h"
25 #include "third_party/WebKit/public/web/WebInputEvent.h" 26 #include "third_party/WebKit/public/web/WebInputEvent.h"
26 #include "ui/android/view_android.h" 27 #include "ui/android/view_android.h"
27 #include "ui/android/window_android.h" 28 #include "ui/android/window_android.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 : main_contents_(main_contents), 119 : main_contents_(main_contents),
119 ui_contents_(ui_contents), 120 ui_contents_(ui_contents),
120 weak_ptr_factory_(this) { 121 weak_ptr_factory_(this) {
121 DCHECK(g_instance == nullptr); 122 DCHECK(g_instance == nullptr);
122 g_instance = this; 123 g_instance = this;
123 j_vr_shell_.Reset(env, obj); 124 j_vr_shell_.Reset(env, obj);
124 scene_.reset(new UiScene); 125 scene_.reset(new UiScene);
125 html_interface_.reset(new UiInterface); 126 html_interface_.reset(new UiInterface);
126 content_compositor_.reset(new VrCompositor(content_window, false)); 127 content_compositor_.reset(new VrCompositor(content_window, false));
127 ui_compositor_.reset(new VrCompositor(ui_window, true)); 128 ui_compositor_.reset(new VrCompositor(ui_window, true));
129 vr_web_contents_observer_.reset(
130 new VrWebContentsObserver(main_contents, html_interface_.get()));
128 131
129 LoadUIContent(); 132 LoadUIContent();
130 133
131 gvr::Mat4f identity; 134 gvr::Mat4f identity;
132 SetIdentityM(identity); 135 SetIdentityM(identity);
133 webvr_head_pose_.resize(kPoseRingBufferSize, identity); 136 webvr_head_pose_.resize(kPoseRingBufferSize, identity);
134 } 137 }
135 138
136 void VrShell::UpdateCompositorLayers(JNIEnv* env, 139 void VrShell::UpdateCompositorLayers(JNIEnv* env,
137 const JavaParamRef<jobject>& obj) { 140 const JavaParamRef<jobject>& obj) {
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 void VrShell::OnDomContentsLoaded() { 674 void VrShell::OnDomContentsLoaded() {
672 // TODO(mthiesse): Setting the background to transparent after the DOM content 675 // TODO(mthiesse): Setting the background to transparent after the DOM content
673 // has loaded is a hack to work around the background not updating when we set 676 // has loaded is a hack to work around the background not updating when we set
674 // it to transparent unless we perform a very specific sequence of events. 677 // it to transparent unless we perform a very specific sequence of events.
675 // First the page background must load as not transparent, then we set the 678 // First the page background must load as not transparent, then we set the
676 // background of the renderer to transparent, then we update the page 679 // background of the renderer to transparent, then we update the page
677 // background to be transparent. This is probably a bug in blink that we 680 // background to be transparent. This is probably a bug in blink that we
678 // should fix. 681 // should fix.
679 ui_contents_->GetRenderWidgetHostView()->SetBackgroundColor( 682 ui_contents_->GetRenderWidgetHostView()->SetBackgroundColor(
680 SK_ColorTRANSPARENT); 683 SK_ColorTRANSPARENT);
684 html_interface_->SetURL(main_contents_->GetVisibleURL());
685 html_interface_->SetLoading(main_contents_->IsLoading());
681 html_interface_->OnDomContentsLoaded(); 686 html_interface_->OnDomContentsLoaded();
682 } 687 }
683 688
684 void VrShell::SetWebVrMode(JNIEnv* env, 689 void VrShell::SetWebVrMode(JNIEnv* env,
685 const base::android::JavaParamRef<jobject>& obj, 690 const base::android::JavaParamRef<jobject>& obj,
686 bool enabled) { 691 bool enabled) {
687 webvr_mode_ = enabled; 692 webvr_mode_ = enabled;
688 if (enabled) { 693 if (enabled) {
689 html_interface_->SetMode(UiInterface::Mode::WEB_VR); 694 html_interface_->SetMode(UiInterface::Mode::WEB_VR);
690 } else { 695 } else {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 controller.GoForward(); 782 controller.GoForward();
778 break; 783 break;
779 case RELOAD: 784 case RELOAD:
780 controller.Reload(false); 785 controller.Reload(false);
781 break; 786 break;
782 #if defined(ENABLE_VR_SHELL_UI_DEV) 787 #if defined(ENABLE_VR_SHELL_UI_DEV)
783 case RELOAD_UI: 788 case RELOAD_UI:
784 ui_contents_->GetController().Reload(false); 789 ui_contents_->GetController().Reload(false);
785 html_interface_.reset(new UiInterface); 790 html_interface_.reset(new UiInterface);
786 html_interface_->SetMode(UiInterface::Mode::STANDARD); 791 html_interface_->SetMode(UiInterface::Mode::STANDARD);
792 vr_web_contents_observer_->SetUiInterface(html_interface_.get());
787 break; 793 break;
788 #endif 794 #endif
789 case ZOOM_OUT: // Not handled yet. 795 case ZOOM_OUT: // Not handled yet.
790 case ZOOM_IN: // Not handled yet. 796 case ZOOM_IN: // Not handled yet.
791 break; 797 break;
792 default: 798 default:
793 NOTREACHED(); 799 NOTREACHED();
794 } 800 }
795 } 801 }
796 802
797 // ---------------------------------------------------------------------------- 803 // ----------------------------------------------------------------------------
798 // Native JNI methods 804 // Native JNI methods
799 // ---------------------------------------------------------------------------- 805 // ----------------------------------------------------------------------------
800 806
801 jlong Init(JNIEnv* env, 807 jlong Init(JNIEnv* env,
802 const JavaParamRef<jobject>& obj, 808 const JavaParamRef<jobject>& obj,
803 const JavaParamRef<jobject>& content_web_contents, 809 const JavaParamRef<jobject>& content_web_contents,
804 jlong content_window_android, 810 jlong content_window_android,
805 const JavaParamRef<jobject>& ui_web_contents, 811 const JavaParamRef<jobject>& ui_web_contents,
806 jlong ui_window_android) { 812 jlong ui_window_android) {
807 return reinterpret_cast<intptr_t>(new VrShell( 813 return reinterpret_cast<intptr_t>(new VrShell(
808 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), 814 env, obj, content::WebContents::FromJavaWebContents(content_web_contents),
809 reinterpret_cast<ui::WindowAndroid*>(content_window_android), 815 reinterpret_cast<ui::WindowAndroid*>(content_window_android),
810 content::WebContents::FromJavaWebContents(ui_web_contents), 816 content::WebContents::FromJavaWebContents(ui_web_contents),
811 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); 817 reinterpret_cast<ui::WindowAndroid*>(ui_window_android)));
812 } 818 }
813 819
814 } // namespace vr_shell 820 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698