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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 base::android::ConvertUTF16ToJavaString(env, info.short_name); | 80 base::android::ConvertUTF16ToJavaString(env, info.short_name); |
81 ScopedJavaLocalRef<jstring> java_icon_url = | 81 ScopedJavaLocalRef<jstring> java_icon_url = |
82 base::android::ConvertUTF8ToJavaString(env, info.icon_url.spec()); | 82 base::android::ConvertUTF8ToJavaString(env, info.icon_url.spec()); |
83 ScopedJavaLocalRef<jobject> java_bitmap; | 83 ScopedJavaLocalRef<jobject> java_bitmap; |
84 if (icon_bitmap.getSize()) | 84 if (icon_bitmap.getSize()) |
85 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); | 85 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); |
86 ScopedJavaLocalRef<jstring> java_manifest_url = | 86 ScopedJavaLocalRef<jstring> java_manifest_url = |
87 base::android::ConvertUTF8ToJavaString(env, info.manifest_url.spec()); | 87 base::android::ConvertUTF8ToJavaString(env, info.manifest_url.spec()); |
88 | 88 |
89 uintptr_t callback_pointer = 0; | 89 uintptr_t callback_pointer = 0; |
90 if (info.display == blink::WebDisplayModeStandalone || | 90 if (info.type == ShortcutInfo::Type::WEBAPP) { |
91 info.display == blink::WebDisplayModeFullscreen) { | |
92 // The callback will need to be run after shortcut creation completes in | 91 // The callback will need to be run after shortcut creation completes in |
93 // order to download the splash image and save it to the WebappDataStorage. | 92 // order to download the splash image and save it to the WebappDataStorage. |
94 // Create a copy of the callback here and send the pointer to Java, which | 93 // Create a copy of the callback here and send the pointer to Java, which |
95 // will send it back once the asynchronous shortcut creation process | 94 // will send it back once the asynchronous shortcut creation process |
96 // finishes. | 95 // finishes. |
97 callback_pointer = | 96 callback_pointer = |
98 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback)); | 97 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback)); |
99 } | 98 } |
100 | 99 |
101 Java_ShortcutHelper_addShortcut( | 100 Java_ShortcutHelper_addShortcut( |
102 env, | 101 env, |
103 java_webapp_id.obj(), | 102 java_webapp_id.obj(), |
| 103 static_cast<int>(info.type), |
104 java_url.obj(), | 104 java_url.obj(), |
105 java_user_title.obj(), | 105 java_user_title.obj(), |
106 java_name.obj(), | 106 java_name.obj(), |
107 java_short_name.obj(), | 107 java_short_name.obj(), |
108 java_icon_url.obj(), | 108 java_icon_url.obj(), |
109 java_bitmap.obj(), | 109 java_bitmap.obj(), |
110 info.display, | 110 info.display, |
111 info.orientation, | 111 info.orientation, |
112 info.source, | 112 info.source, |
113 info.theme_color, | 113 info.theme_color, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 DCHECK(jsplash_image_callback); | 225 DCHECK(jsplash_image_callback); |
226 base::Closure* splash_image_callback = | 226 base::Closure* splash_image_callback = |
227 reinterpret_cast<base::Closure*>(jsplash_image_callback); | 227 reinterpret_cast<base::Closure*>(jsplash_image_callback); |
228 splash_image_callback->Run(); | 228 splash_image_callback->Run(); |
229 delete splash_image_callback; | 229 delete splash_image_callback; |
230 } | 230 } |
231 | 231 |
232 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { | 232 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
233 return RegisterNativesImpl(env); | 233 return RegisterNativesImpl(env); |
234 } | 234 } |
OLD | NEW |