| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 const SkBitmap& icon_bitmap, | 65 const SkBitmap& icon_bitmap, |
| 66 const base::Closure& splash_image_callback) { | 66 const base::Closure& splash_image_callback) { |
| 67 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 67 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 68 | 68 |
| 69 // Send the data to the Java side to create the shortcut. | 69 // Send the data to the Java side to create the shortcut. |
| 70 JNIEnv* env = base::android::AttachCurrentThread(); | 70 JNIEnv* env = base::android::AttachCurrentThread(); |
| 71 ScopedJavaLocalRef<jstring> java_webapp_id = | 71 ScopedJavaLocalRef<jstring> java_webapp_id = |
| 72 base::android::ConvertUTF8ToJavaString(env, webapp_id); | 72 base::android::ConvertUTF8ToJavaString(env, webapp_id); |
| 73 ScopedJavaLocalRef<jstring> java_url = | 73 ScopedJavaLocalRef<jstring> java_url = |
| 74 base::android::ConvertUTF8ToJavaString(env, info.url.spec()); | 74 base::android::ConvertUTF8ToJavaString(env, info.url.spec()); |
| 75 ScopedJavaLocalRef<jstring> java_scope_url = |
| 76 base::android::ConvertUTF8ToJavaString(env, info.scope.spec()); |
| 75 ScopedJavaLocalRef<jstring> java_user_title = | 77 ScopedJavaLocalRef<jstring> java_user_title = |
| 76 base::android::ConvertUTF16ToJavaString(env, info.user_title); | 78 base::android::ConvertUTF16ToJavaString(env, info.user_title); |
| 77 ScopedJavaLocalRef<jstring> java_name = | 79 ScopedJavaLocalRef<jstring> java_name = |
| 78 base::android::ConvertUTF16ToJavaString(env, info.name); | 80 base::android::ConvertUTF16ToJavaString(env, info.name); |
| 79 ScopedJavaLocalRef<jstring> java_short_name = | 81 ScopedJavaLocalRef<jstring> java_short_name = |
| 80 base::android::ConvertUTF16ToJavaString(env, info.short_name); | 82 base::android::ConvertUTF16ToJavaString(env, info.short_name); |
| 81 ScopedJavaLocalRef<jstring> java_icon_url = | 83 ScopedJavaLocalRef<jstring> java_icon_url = |
| 82 base::android::ConvertUTF8ToJavaString(env, info.icon_url.spec()); | 84 base::android::ConvertUTF8ToJavaString(env, info.icon_url.spec()); |
| 83 ScopedJavaLocalRef<jobject> java_bitmap; | 85 ScopedJavaLocalRef<jobject> java_bitmap; |
| 84 if (icon_bitmap.getSize()) | 86 if (icon_bitmap.getSize()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 95 // will send it back once the asynchronous shortcut creation process | 97 // will send it back once the asynchronous shortcut creation process |
| 96 // finishes. | 98 // finishes. |
| 97 callback_pointer = | 99 callback_pointer = |
| 98 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback)); | 100 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback)); |
| 99 } | 101 } |
| 100 | 102 |
| 101 Java_ShortcutHelper_addShortcut( | 103 Java_ShortcutHelper_addShortcut( |
| 102 env, | 104 env, |
| 103 java_webapp_id.obj(), | 105 java_webapp_id.obj(), |
| 104 java_url.obj(), | 106 java_url.obj(), |
| 107 java_scope_url.obj(), |
| 105 java_user_title.obj(), | 108 java_user_title.obj(), |
| 106 java_name.obj(), | 109 java_name.obj(), |
| 107 java_short_name.obj(), | 110 java_short_name.obj(), |
| 108 java_icon_url.obj(), | 111 java_icon_url.obj(), |
| 109 java_bitmap.obj(), | 112 java_bitmap.obj(), |
| 110 info.display, | 113 info.display, |
| 111 info.orientation, | 114 info.orientation, |
| 112 info.source, | 115 info.source, |
| 113 info.theme_color, | 116 info.theme_color, |
| 114 info.background_color, | 117 info.background_color, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DCHECK(jsplash_image_callback); | 228 DCHECK(jsplash_image_callback); |
| 226 base::Closure* splash_image_callback = | 229 base::Closure* splash_image_callback = |
| 227 reinterpret_cast<base::Closure*>(jsplash_image_callback); | 230 reinterpret_cast<base::Closure*>(jsplash_image_callback); |
| 228 splash_image_callback->Run(); | 231 splash_image_callback->Run(); |
| 229 delete splash_image_callback; | 232 delete splash_image_callback; |
| 230 } | 233 } |
| 231 | 234 |
| 232 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { | 235 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
| 233 return RegisterNativesImpl(env); | 236 return RegisterNativesImpl(env); |
| 234 } | 237 } |
| OLD | NEW |