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

Side by Side Diff: chrome/browser/android/shortcut_helper.cc

Issue 2050933002: Upstream: Add additional checks before creating a WebAPK after clicking "Add to Homescreen" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'create_webapk_requirements_enum_class' into create_webapk_requirements2 Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/android/banners/app_banner_infobar_delegate_android.cc ('k') | chrome/browser/android/shortcut_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698