| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shortcut_helper.h" | 5 #include "chrome/browser/android/shortcut_helper.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 std::string webapk_package_name = ""; | 254 std::string webapk_package_name = ""; |
| 255 if (java_webapk_package_name.obj()) { | 255 if (java_webapk_package_name.obj()) { |
| 256 webapk_package_name = base::android::ConvertJavaStringToUTF8( | 256 webapk_package_name = base::android::ConvertJavaStringToUTF8( |
| 257 env, java_webapk_package_name); | 257 env, java_webapk_package_name); |
| 258 } | 258 } |
| 259 return webapk_package_name; | 259 return webapk_package_name; |
| 260 } | 260 } |
| 261 | 261 |
| 262 // static | 262 // static |
| 263 bool ShortcutHelper::IsWebApkInstalled(const GURL& url) { | 263 bool ShortcutHelper::IsWebApkInstalled(const GURL& url) { |
| 264 JNIEnv* env = base::android::AttachCurrentThread(); | 264 return !QueryWebApkPackage(url).empty(); |
| 265 ScopedJavaLocalRef<jstring> java_url = | |
| 266 base::android::ConvertUTF8ToJavaString(env, url.spec()); | |
| 267 return Java_ShortcutHelper_isWebApkInstalled(env, java_url); | |
| 268 } | 265 } |
| 269 | 266 |
| 270 GURL ShortcutHelper::GetScopeFromURL(const GURL& url) { | 267 GURL ShortcutHelper::GetScopeFromURL(const GURL& url) { |
| 271 JNIEnv* env = base::android::AttachCurrentThread(); | 268 JNIEnv* env = base::android::AttachCurrentThread(); |
| 272 ScopedJavaLocalRef<jstring> java_url = | 269 ScopedJavaLocalRef<jstring> java_url = |
| 273 base::android::ConvertUTF8ToJavaString(env, url.spec()); | 270 base::android::ConvertUTF8ToJavaString(env, url.spec()); |
| 274 ScopedJavaLocalRef<jstring> java_scope_url = | 271 ScopedJavaLocalRef<jstring> java_scope_url = |
| 275 Java_ShortcutHelper_getScopeFromUrl(env, java_url); | 272 Java_ShortcutHelper_getScopeFromUrl(env, java_url); |
| 276 return GURL(base::android::ConvertJavaStringToUTF16(env, java_scope_url)); | 273 return GURL(base::android::ConvertJavaStringToUTF16(env, java_scope_url)); |
| 277 } | 274 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 289 DCHECK(jsplash_image_callback); | 286 DCHECK(jsplash_image_callback); |
| 290 base::Closure* splash_image_callback = | 287 base::Closure* splash_image_callback = |
| 291 reinterpret_cast<base::Closure*>(jsplash_image_callback); | 288 reinterpret_cast<base::Closure*>(jsplash_image_callback); |
| 292 splash_image_callback->Run(); | 289 splash_image_callback->Run(); |
| 293 delete splash_image_callback; | 290 delete splash_image_callback; |
| 294 } | 291 } |
| 295 | 292 |
| 296 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { | 293 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
| 297 return RegisterNativesImpl(env); | 294 return RegisterNativesImpl(env); |
| 298 } | 295 } |
| OLD | NEW |