| OLD | NEW |
| 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/webapk/chrome_webapk_host.h" | 5 #include "chrome/browser/android/webapk/chrome_webapk_host.h" |
| 6 | 6 |
| 7 #include "chrome/browser/android/chrome_feature_list.h" | 7 #include "chrome/browser/android/chrome_feature_list.h" |
| 8 #include "components/variations/variations_associated_data.h" | 8 #include "components/variations/variations_associated_data.h" |
| 9 #include "jni/ChromeWebApkHost_jni.h" | 9 #include "jni/ChromeWebApkHost_jni.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 // Variations flag to enable installing WebAPKs using Google Play. | |
| 14 const char* kPlayInstall = "play_install"; | |
| 15 | |
| 16 // Variations flag to enable launching Chrome renderer in WebAPK process. | 13 // Variations flag to enable launching Chrome renderer in WebAPK process. |
| 17 const char* kLaunchRendererInWebApkProcess = | 14 const char* kLaunchRendererInWebApkProcess = |
| 18 "launch_renderer_in_webapk_process"; | 15 "launch_renderer_in_webapk_process"; |
| 19 | 16 |
| 20 } // anonymous namespace | 17 } // anonymous namespace |
| 21 | 18 |
| 22 // static | 19 // static |
| 23 bool ChromeWebApkHost::Register(JNIEnv* env) { | 20 bool ChromeWebApkHost::Register(JNIEnv* env) { |
| 24 return RegisterNativesImpl(env); | 21 return RegisterNativesImpl(env); |
| 25 } | 22 } |
| 26 | 23 |
| 27 // static | 24 // static |
| 28 bool ChromeWebApkHost::CanInstallWebApk() { | 25 bool ChromeWebApkHost::CanInstallWebApk() { |
| 29 JNIEnv* env = base::android::AttachCurrentThread(); | 26 JNIEnv* env = base::android::AttachCurrentThread(); |
| 30 return Java_ChromeWebApkHost_canInstallWebApk(env); | 27 return Java_ChromeWebApkHost_canInstallWebApk(env); |
| 31 } | 28 } |
| 32 | 29 |
| 33 // static | 30 // static |
| 34 GooglePlayInstallState ChromeWebApkHost::GetGooglePlayInstallState() { | 31 GooglePlayInstallState ChromeWebApkHost::GetGooglePlayInstallState() { |
| 35 JNIEnv* env = base::android::AttachCurrentThread(); | 32 JNIEnv* env = base::android::AttachCurrentThread(); |
| 36 return static_cast<GooglePlayInstallState>( | 33 return static_cast<GooglePlayInstallState>( |
| 37 Java_ChromeWebApkHost_getGooglePlayInstallState(env)); | 34 Java_ChromeWebApkHost_getGooglePlayInstallState(env)); |
| 38 } | 35 } |
| 39 | 36 |
| 40 // static | 37 // static |
| 41 jboolean CanUseGooglePlayToInstallWebApk( | |
| 42 JNIEnv* env, | |
| 43 const base::android::JavaParamRef<jclass>& clazz) { | |
| 44 return variations::GetVariationParamValueByFeature( | |
| 45 chrome::android::kImprovedA2HS, kPlayInstall) == "true"; | |
| 46 } | |
| 47 | |
| 48 // static | |
| 49 jboolean CanLaunchRendererInWebApkProcess( | 38 jboolean CanLaunchRendererInWebApkProcess( |
| 50 JNIEnv* env, | 39 JNIEnv* env, |
| 51 const base::android::JavaParamRef<jclass>& clazz) { | 40 const base::android::JavaParamRef<jclass>& clazz) { |
| 52 return variations::GetVariationParamValueByFeature( | 41 return variations::GetVariationParamValueByFeature( |
| 53 chrome::android::kImprovedA2HS, kLaunchRendererInWebApkProcess) == | 42 chrome::android::kImprovedA2HS, kLaunchRendererInWebApkProcess) == |
| 54 "true"; | 43 "true"; |
| 55 } | 44 } |
| 56 | 45 |
| 57 // static | 46 // static |
| 58 jboolean CanInstallFromUnknownSources( | 47 jboolean CanInstallFromUnknownSources( |
| 59 JNIEnv* env, | 48 JNIEnv* env, |
| 60 const base::android::JavaParamRef<jclass>& clazz) { | 49 const base::android::JavaParamRef<jclass>& clazz) { |
| 61 return base::FeatureList::GetInstance()->IsFeatureOverriddenFromCommandLine( | 50 return base::FeatureList::GetInstance()->IsFeatureOverriddenFromCommandLine( |
| 62 chrome::android::kImprovedA2HS.name, | 51 chrome::android::kImprovedA2HS.name, |
| 63 base::FeatureList::OVERRIDE_ENABLE_FEATURE); | 52 base::FeatureList::OVERRIDE_ENABLE_FEATURE); |
| 64 } | 53 } |
| OLD | NEW |