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

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

Issue 2629573004: Add a chrome://webapks page. (Closed)
Patch Set: Makes the listWebApks method receive a callback on the Java side 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..699916586c3b76a907414488b1766998b2f47383 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::ListWebApks(JNIEnv* env,
pkotwicz 2017/01/18 02:08:21 Nit: Remove the JNIEnv* parameter and call AttachC
gonzalon 2017/01/18 15:29:32 Done.
+ const base::Callback<void(std::vector<WebApkInfo*>)>& callback) {
+ uintptr_t callback_pointer = reinterpret_cast<uintptr_t>(
+ new base::Callback<void(std::vector<WebApkInfo*>)>(callback));
+ Java_ShortcutHelper_listWebApks(env, 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,41 @@ void OnWebappDataStored(JNIEnv* env,
delete splash_image_callback;
}
+void OnWebApksFound(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);
+
+ std::vector<WebApkInfo*> webapks_list;
pkotwicz 2017/01/18 02:08:21 Can this be std::vector<WebApkInfo> instead?
gonzalon 2017/01/18 15:29:32 Done.
+ for (size_t i = 0; i < short_names.size(); ++i) {
+ WebApkInfo* webapk_info =
+ new WebApkInfo(short_names[i], package_names[i], shell_apk_versions[i],
+ version_codes[i]);
+ webapks_list.push_back(webapk_info);
+ }
+
+ base::Callback<void(std::vector<WebApkInfo*>)>* webapks_list_callback =
+ reinterpret_cast<base::Callback<void(std::vector<WebApkInfo*>)>*>(
+ jcallback_pointer);
+ webapks_list_callback->Run(webapks_list);
+ delete webapks_list_callback;
+}
+
bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
return RegisterNativesImpl(env);
}

Powered by Google App Engine
This is Rietveld 408576698