1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_ANDROID_VR_VRCORE_INSTALL_HELPER_H_ 6 #define CHROME_BROWSER_ANDROID_VR_VRCORE_INSTALL_HELPER_H_ 7 8 #include "base/android/jni_android.h" 9 #include "base/android/scoped_java_ref.h" 10 #include "base/callback.h" 11 #include "base/threading/thread_checker.h" 12 #include "chrome/browser/vr/vr_export.h" 13 #include "content/public/browser/xr_install_helper.h" 14 15 namespace vr { 16 17 class VrModuleProvider; 18 19 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.vr 20 enum class VrSupportLevel : int { 21 kVrDisabled = 0, 22 kVrNeedsUpdate = 1, // VR Support is available, but needs update. 23 kVrCardboard = 2, 24 kVrDaydream = 3, // Supports both Cardboard and Daydream viewer. 25 }; 26 27 // Helper class for Installing VrCore. Note that this must not be created unless 28 // the VR DFM has been confirmed to be installed previously. 29 class VR_EXPORT VrCoreInstallHelper : public content::XrInstallHelper { 30 public: 31 explicit VrCoreInstallHelper(const VrModuleProvider& vr_module_provider); 32 ~VrCoreInstallHelper() override; 33 34 static bool VrSupportNeedsUpdate(); 35 36 VrCoreInstallHelper(const VrCoreInstallHelper&) = delete; 37 VrCoreInstallHelper& operator=(const VrCoreInstallHelper&) = delete; 38 39 void EnsureInstalled( 40 int render_process_id, 41 int render_frame_id, 42 base::OnceCallback<void(bool)> install_callback) override; 43 44 // Called from Java end. 45 void OnInstallResult(JNIEnv* env, bool success); 46 47 private: 48 void RunInstallFinishedCallback(bool succeeded); 49 50 base::OnceCallback<void(bool)> install_finished_callback_; 51 base::android::ScopedJavaGlobalRef<jobject> java_install_utils_; 52 }; 53 54 } // namespace vr 55 56 #endif // CHROME_BROWSER_ANDROID_VR_VRCORE_INSTALL_HELPER_H_ 57