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

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

Issue 2629573004: Add a chrome://webapks page. (Closed)
Patch Set: Adds an about:webapks page with information about all installed Web APKs on the device 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..4e8033bee6ad85cb6a10db511217bd5d76fd218c 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(const WebApkInfoCallback& callback) {
+ uintptr_t callback_pointer =
+ reinterpret_cast<uintptr_t>(new WebApkInfoCallback(callback));
+ Java_ShortcutHelper_listWebApks(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,39 @@ void OnWebappDataStored(JNIEnv* env,
delete splash_image_callback;
}
+void OnWebApksFound(JNIEnv* env,
dominickn 2017/01/23 00:48:07 OnWebApksRetrieved (you might not find any WebAPKs
gonzalon 2017/01/23 16:58:51 Done.
+ 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);
dominickn 2017/01/23 00:48:07 You should DCHECK that all of the vectors are the
gonzalon 2017/01/23 16:58:51 Done.
+
+ std::vector<const WebApkInfo> webapk_list;
dominickn 2017/01/23 00:48:07 Since you know how long this vector will be, you c
gonzalon 2017/01/23 16:58:51 Done.
+ for (size_t i = 0; i < short_names.size(); ++i) {
+ const WebApkInfo webapk_info(short_names[i], package_names[i],
dominickn 2017/01/23 00:48:07 Fix indentation here.
gonzalon 2017/01/23 16:58:51 I'm sorry, I'm not sure what you mean. I tried run
+ shell_apk_versions[i], version_codes[i]);
+ webapk_list.push_back(webapk_info);
+ }
+
+ 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