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

Unified Diff: chrome/browser/android/webapk/chrome_webapk_host.cc

Issue 2675803004: Fall back to shortcut A2HS when Phonesky is out of date or unavailable. (Closed)
Patch Set: pkotwicz@'s comments. Created 3 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/webapk/chrome_webapk_host.cc
diff --git a/chrome/browser/android/webapk/chrome_webapk_host.cc b/chrome/browser/android/webapk/chrome_webapk_host.cc
index 1ebfe489246fc3076d391f0c714144da27011ca7..8a73f0486e52a21a5c22e8ad74b6f23376048e9e 100644
--- a/chrome/browser/android/webapk/chrome_webapk_host.cc
+++ b/chrome/browser/android/webapk/chrome_webapk_host.cc
@@ -4,7 +4,10 @@
#include "chrome/browser/android/webapk/chrome_webapk_host.h"
+#include "base/android/jni_android.h"
+#include "base/bind.h"
pkotwicz 2017/02/03 23:05:05 Is this include necessary?
#include "chrome/browser/android/chrome_feature_list.h"
+#include "chrome/browser/android/webapk/webapk_install_service.h"
pkotwicz 2017/02/03 23:05:05 Is this include necessary?
#include "components/variations/variations_associated_data.h"
#include "jni/ChromeWebApkHost_jni.h"
@@ -13,6 +16,11 @@ namespace {
// Variations flag to enable installing WebAPKs using Google Play.
const char* kPlayInstall = "play_install";
+bool IsGooglePlayInstallAllowed() {
+ return variations::GetVariationParamValueByFeature(
+ chrome::android::kImprovedA2HS, kPlayInstall) == "true";
+}
+
} // anonymous namespace
// static
@@ -27,9 +35,37 @@ bool ChromeWebApkHost::AreWebApkEnabled() {
}
// static
+bool ChromeWebApkHost::CanUseGooglePlayToInstallWebApk() {
+ return IsGooglePlayInstallAllowed();
+}
+
+// static
+void ChromeWebApkHost::CanUseGooglePlayInstallApi(
+ const CanUseGooglePlayInstallApiCallback& callback) {
+ uintptr_t callback_pointer = reinterpret_cast<uintptr_t>(
+ new CanUseGooglePlayInstallApiCallback(callback));
+ Java_ChromeWebApkHost_canUseGooglePlayInstallApi(
+ base::android::AttachCurrentThread(), callback_pointer);
+}
+
+// static
jboolean CanUseGooglePlayToInstallWebApk(
JNIEnv* env,
const base::android::JavaParamRef<jclass>& clazz) {
- return variations::GetVariationParamValueByFeature(
- chrome::android::kImprovedA2HS, kPlayInstall) == "true";
+ return IsGooglePlayInstallAllowed();
+}
+
+// static
+void OnCanUseGooglePlayInstallApi(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jclass>& clazz,
+ const jlong jcallback_pointer,
+ jboolean is_available) {
+ DCHECK(jcallback_pointer);
+
+ ChromeWebApkHost::CanUseGooglePlayInstallApiCallback* callback =
+ reinterpret_cast<ChromeWebApkHost::CanUseGooglePlayInstallApiCallback*>(
+ jcallback_pointer);
+ callback->Run(is_available);
+ delete callback;
}

Powered by Google App Engine
This is Rietveld 408576698