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); |
} |