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

Side by Side 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 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/webapk/chrome_webapk_host.h" 5 #include "chrome/browser/android/webapk/chrome_webapk_host.h"
6 6
7 #include "base/android/jni_android.h"
8 #include "base/bind.h"
pkotwicz 2017/02/03 23:05:05 Is this include necessary?
7 #include "chrome/browser/android/chrome_feature_list.h" 9 #include "chrome/browser/android/chrome_feature_list.h"
10 #include "chrome/browser/android/webapk/webapk_install_service.h"
pkotwicz 2017/02/03 23:05:05 Is this include necessary?
8 #include "components/variations/variations_associated_data.h" 11 #include "components/variations/variations_associated_data.h"
9 #include "jni/ChromeWebApkHost_jni.h" 12 #include "jni/ChromeWebApkHost_jni.h"
10 13
11 namespace { 14 namespace {
12 15
13 // Variations flag to enable installing WebAPKs using Google Play. 16 // Variations flag to enable installing WebAPKs using Google Play.
14 const char* kPlayInstall = "play_install"; 17 const char* kPlayInstall = "play_install";
15 18
19 bool IsGooglePlayInstallAllowed() {
20 return variations::GetVariationParamValueByFeature(
21 chrome::android::kImprovedA2HS, kPlayInstall) == "true";
22 }
23
16 } // anonymous namespace 24 } // anonymous namespace
17 25
18 // static 26 // static
19 bool ChromeWebApkHost::Register(JNIEnv* env) { 27 bool ChromeWebApkHost::Register(JNIEnv* env) {
20 return RegisterNativesImpl(env); 28 return RegisterNativesImpl(env);
21 } 29 }
22 30
23 // static 31 // static
24 bool ChromeWebApkHost::AreWebApkEnabled() { 32 bool ChromeWebApkHost::AreWebApkEnabled() {
25 JNIEnv* env = base::android::AttachCurrentThread(); 33 JNIEnv* env = base::android::AttachCurrentThread();
26 return Java_ChromeWebApkHost_areWebApkEnabled(env); 34 return Java_ChromeWebApkHost_areWebApkEnabled(env);
27 } 35 }
28 36
29 // static 37 // static
38 bool ChromeWebApkHost::CanUseGooglePlayToInstallWebApk() {
39 return IsGooglePlayInstallAllowed();
40 }
41
42 // static
43 void ChromeWebApkHost::CanUseGooglePlayInstallApi(
44 const CanUseGooglePlayInstallApiCallback& callback) {
45 uintptr_t callback_pointer = reinterpret_cast<uintptr_t>(
46 new CanUseGooglePlayInstallApiCallback(callback));
47 Java_ChromeWebApkHost_canUseGooglePlayInstallApi(
48 base::android::AttachCurrentThread(), callback_pointer);
49 }
50
51 // static
30 jboolean CanUseGooglePlayToInstallWebApk( 52 jboolean CanUseGooglePlayToInstallWebApk(
31 JNIEnv* env, 53 JNIEnv* env,
32 const base::android::JavaParamRef<jclass>& clazz) { 54 const base::android::JavaParamRef<jclass>& clazz) {
33 return variations::GetVariationParamValueByFeature( 55 return IsGooglePlayInstallAllowed();
34 chrome::android::kImprovedA2HS, kPlayInstall) == "true";
35 } 56 }
57
58 // static
59 void OnCanUseGooglePlayInstallApi(
60 JNIEnv* env,
61 const base::android::JavaParamRef<jclass>& clazz,
62 const jlong jcallback_pointer,
63 jboolean is_available) {
64 DCHECK(jcallback_pointer);
65
66 ChromeWebApkHost::CanUseGooglePlayInstallApiCallback* callback =
67 reinterpret_cast<ChromeWebApkHost::CanUseGooglePlayInstallApiCallback*>(
68 jcallback_pointer);
69 callback->Run(is_available);
70 delete callback;
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698