Chromium Code Reviews| 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 ab3b67ac4529a57e6708f2c6ea1ef9543128f90a..53c7b49f986437bfa2e494c4d3335582dee9dc13 100644 |
| --- a/chrome/browser/android/vr_shell/vr_shell.cc |
| +++ b/chrome/browser/android/vr_shell/vr_shell.cc |
| @@ -63,6 +63,20 @@ void SetIsInVR(content::WebContents* contents, bool is_in_vr) { |
| } // namespace |
| +class UiWebContentsObserver : public content::WebContentsObserver { |
|
cjgrant
2017/03/07 20:34:47
This class could live in a separate file, but give
mthiesse
2017/03/07 20:49:24
VrShell is already an observer of the UI web conte
cjgrant
2017/03/07 21:08:46
Done. Wow, need to check eyes.
|
| + public: |
| + explicit UiWebContentsObserver(content::WebContents* web_contents) |
| + : WebContentsObserver(web_contents) {} |
| + |
| + private: |
| + void RenderViewHostChanged(content::RenderViewHost* old_host, |
| + content::RenderViewHost* new_host) override { |
| + new_host->GetWidget()->GetView()->SetIsInVR(true); |
| + } |
| + |
| + DISALLOW_COPY_AND_ASSIGN(UiWebContentsObserver); |
| +}; |
| + |
| VrShell::VrShell(JNIEnv* env, |
| jobject obj, |
| ui::WindowAndroid* content_window, |
| @@ -138,6 +152,8 @@ void VrShell::SwapContents( |
| content_input_manager_ = base::MakeUnique<VrInputManager>(main_contents_); |
| vr_web_contents_observer_ = base::MakeUnique<VrWebContentsObserver>( |
| main_contents_, html_interface_.get(), this); |
| + ui_web_contents_observer_ = |
| + base::MakeUnique<UiWebContentsObserver>(ui_contents_); |
| // TODO(billorr): Make VrMetricsHelper tab-aware and able to track multiple |
| // tabs. crbug.com/684661 |
| metrics_helper_ = base::MakeUnique<VrMetricsHelper>(main_contents_); |