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

Unified Diff: chrome/browser/android/shortcut_helper.cc

Issue 2629573004: Add a chrome://webapks page. (Closed)
Patch Set: Add a chrome://webapks page. Created 3 years, 11 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/shortcut_helper.cc
diff --git a/chrome/browser/android/shortcut_helper.cc b/chrome/browser/android/shortcut_helper.cc
index 1536a9ad36607c177243cc6cb253e8eee2637c17..31487758dc1fe770c802aea4d001cba1e59d85fe 100644
--- a/chrome/browser/android/shortcut_helper.cc
+++ b/chrome/browser/android/shortcut_helper.cc
@@ -282,6 +282,13 @@ GURL ShortcutHelper::GetScopeFromURL(const GURL& url) {
return GURL(base::android::ConvertJavaStringToUTF16(env, java_scope_url));
}
+void ShortcutHelper::RetrieveWebApks(const WebApkInfoCallback& callback) {
+ uintptr_t callback_pointer =
+ reinterpret_cast<uintptr_t>(new WebApkInfoCallback(callback));
+ Java_ShortcutHelper_retrieveWebApks(base::android::AttachCurrentThread(),
+ callback_pointer);
+}
+
// Callback used by Java when the shortcut has been created.
// |splash_image_callback| is a pointer to a base::Closure allocated in
// AddShortcutWithSkBitmap, so reinterpret_cast it back and run it.
@@ -299,6 +306,44 @@ void OnWebappDataStored(JNIEnv* env,
delete splash_image_callback;
}
+void OnWebApksRetrieved(JNIEnv* env,
+ const JavaParamRef<jclass>& clazz,
+ const jlong jcallback_pointer,
+ const JavaParamRef<jobjectArray>& jshort_names,
+ const JavaParamRef<jobjectArray>& jpackage_names,
+ const JavaParamRef<jintArray>& jshell_apk_versions,
+ const JavaParamRef<jintArray>& jversion_codes) {
+ DCHECK(jcallback_pointer);
+ std::vector<std::string> short_names;
+ base::android::AppendJavaStringArrayToStringVector(env, jshort_names,
+ &short_names);
+ std::vector<std::string> package_names;
+ base::android::AppendJavaStringArrayToStringVector(env, jpackage_names,
+ &package_names);
+ std::vector<int> shell_apk_versions;
+ base::android::JavaIntArrayToIntVector(env, jshell_apk_versions,
+ &shell_apk_versions);
+ std::vector<int> version_codes;
+ base::android::JavaIntArrayToIntVector(env, jversion_codes, &version_codes);
+
+ DCHECK(short_names.size() == package_names.size());
+ DCHECK(short_names.size() == shell_apk_versions.size());
+ DCHECK(short_names.size() == version_codes.size());
+
+ std::vector<WebApkInfo> webapk_list;
+ webapk_list.reserve(short_names.size());
+ for (size_t i = 0; i < short_names.size(); ++i) {
+ webapk_list.push_back(WebApkInfo(std::move(short_names[i]),
+ std::move(package_names[i]),
+ shell_apk_versions[i], version_codes[i]));
+ }
+
+ ShortcutHelper::WebApkInfoCallback* webapk_list_callback =
+ reinterpret_cast<ShortcutHelper::WebApkInfoCallback*>(jcallback_pointer);
+ webapk_list_callback->Run(webapk_list);
+ delete webapk_list_callback;
+}
+
bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
return RegisterNativesImpl(env);
}

Powered by Google App Engine
This is Rietveld 408576698