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

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

Issue 1961313002: Cache web app data for home screen sites declaring "display": "fullscreen" in their manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits Created 4 years, 7 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/context_utils.h" 9 #include "base/android/context_utils.h"
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 base::android::ConvertUTF16ToJavaString(env, info.user_title); 78 base::android::ConvertUTF16ToJavaString(env, info.user_title);
79 ScopedJavaLocalRef<jstring> java_name = 79 ScopedJavaLocalRef<jstring> java_name =
80 base::android::ConvertUTF16ToJavaString(env, info.name); 80 base::android::ConvertUTF16ToJavaString(env, info.name);
81 ScopedJavaLocalRef<jstring> java_short_name = 81 ScopedJavaLocalRef<jstring> java_short_name =
82 base::android::ConvertUTF16ToJavaString(env, info.short_name); 82 base::android::ConvertUTF16ToJavaString(env, info.short_name);
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 86
87 uintptr_t callback_pointer = 0; 87 uintptr_t callback_pointer = 0;
88 bool is_webapp_capable = info.display == blink::WebDisplayModeStandalone; 88 if (info.display == blink::WebDisplayModeStandalone ||
89 89 info.display == blink::WebDisplayModeFullscreen) {
90 if (is_webapp_capable) {
91 // The callback will need to be run after shortcut creation completes in 90 // The callback will need to be run after shortcut creation completes in
92 // order to download the splash image and save it to the WebappDataStorage. 91 // order to download the splash image and save it to the WebappDataStorage.
93 // Create a copy of the callback here and send the pointer to Java, which 92 // Create a copy of the callback here and send the pointer to Java, which
94 // will send it back once the asynchronous shortcut creation process 93 // will send it back once the asynchronous shortcut creation process
95 // finishes. 94 // finishes.
96 callback_pointer = 95 callback_pointer =
97 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback)); 96 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback));
98 } 97 }
99 98
100 Java_ShortcutHelper_addShortcut( 99 Java_ShortcutHelper_addShortcut(
101 env, 100 env,
102 base::android::GetApplicationContext(), 101 base::android::GetApplicationContext(),
103 java_webapp_id.obj(), 102 java_webapp_id.obj(),
104 java_url.obj(), 103 java_url.obj(),
105 java_user_title.obj(), 104 java_user_title.obj(),
106 java_name.obj(), 105 java_name.obj(),
107 java_short_name.obj(), 106 java_short_name.obj(),
108 java_bitmap.obj(), 107 java_bitmap.obj(),
109 is_webapp_capable, 108 info.display,
110 info.orientation, 109 info.orientation,
111 info.source, 110 info.source,
112 info.theme_color, 111 info.theme_color,
113 info.background_color, 112 info.background_color,
114 info.is_icon_generated, 113 info.is_icon_generated,
115 callback_pointer); 114 callback_pointer);
116 } 115 }
117 116
118 int ShortcutHelper::GetIdealHomescreenIconSizeInDp() { 117 int ShortcutHelper::GetIdealHomescreenIconSizeInDp() {
119 if (kIdealHomescreenIconSize == -1) 118 if (kIdealHomescreenIconSize == -1)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 DCHECK(jsplash_image_callback); 226 DCHECK(jsplash_image_callback);
228 base::Closure* splash_image_callback = 227 base::Closure* splash_image_callback =
229 reinterpret_cast<base::Closure*>(jsplash_image_callback); 228 reinterpret_cast<base::Closure*>(jsplash_image_callback);
230 splash_image_callback->Run(); 229 splash_image_callback->Run();
231 delete splash_image_callback; 230 delete splash_image_callback;
232 } 231 }
233 232
234 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 233 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
235 return RegisterNativesImpl(env); 234 return RegisterNativesImpl(env);
236 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698