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

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

Issue 2453423002: Send all of the icon URLs listed in Web Manifest to WebAPK Server. (Closed)
Patch Set: Nits. Created 4 years, 1 month 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ScopedJavaLocalRef<jstring> java_url = 103 ScopedJavaLocalRef<jstring> java_url =
104 base::android::ConvertUTF8ToJavaString(env, info.url.spec()); 104 base::android::ConvertUTF8ToJavaString(env, info.url.spec());
105 ScopedJavaLocalRef<jstring> java_scope_url = 105 ScopedJavaLocalRef<jstring> java_scope_url =
106 base::android::ConvertUTF8ToJavaString(env, info.scope.spec()); 106 base::android::ConvertUTF8ToJavaString(env, info.scope.spec());
107 ScopedJavaLocalRef<jstring> java_user_title = 107 ScopedJavaLocalRef<jstring> java_user_title =
108 base::android::ConvertUTF16ToJavaString(env, info.user_title); 108 base::android::ConvertUTF16ToJavaString(env, info.user_title);
109 ScopedJavaLocalRef<jstring> java_name = 109 ScopedJavaLocalRef<jstring> java_name =
110 base::android::ConvertUTF16ToJavaString(env, info.name); 110 base::android::ConvertUTF16ToJavaString(env, info.name);
111 ScopedJavaLocalRef<jstring> java_short_name = 111 ScopedJavaLocalRef<jstring> java_short_name =
112 base::android::ConvertUTF16ToJavaString(env, info.short_name); 112 base::android::ConvertUTF16ToJavaString(env, info.short_name);
113 ScopedJavaLocalRef<jstring> java_icon_url = 113 ScopedJavaLocalRef<jstring> java_best_icon_url =
114 base::android::ConvertUTF8ToJavaString(env, info.icon_url.spec()); 114 base::android::ConvertUTF8ToJavaString(env, info.best_icon_url.spec());
115 ScopedJavaLocalRef<jobject> java_bitmap; 115 ScopedJavaLocalRef<jobject> java_bitmap;
116 if (icon_bitmap.getSize()) 116 if (icon_bitmap.getSize())
117 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); 117 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap);
118 118
119 // The callback will need to be run after shortcut creation completes in order 119 // The callback will need to be run after shortcut creation completes in order
120 // to download the splash image and save it to the WebappDataStorage. Create a 120 // to download the splash image and save it to the WebappDataStorage. Create a
121 // copy of the callback here and send the pointer to Java, which will send it 121 // copy of the callback here and send the pointer to Java, which will send it
122 // back once the asynchronous shortcut creation process finishes. 122 // back once the asynchronous shortcut creation process finishes.
123 uintptr_t callback_pointer = 123 uintptr_t callback_pointer =
124 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback)); 124 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback));
125 125
126 Java_ShortcutHelper_addWebapp(env, java_webapp_id, java_url, java_scope_url, 126 Java_ShortcutHelper_addWebapp(env, java_webapp_id, java_url, java_scope_url,
127 java_user_title, java_name, java_short_name, 127 java_user_title, java_name, java_short_name,
128 java_icon_url, java_bitmap, info.display, 128 java_best_icon_url, java_bitmap, info.display,
129 info.orientation, info.source, info.theme_color, 129 info.orientation, info.source, info.theme_color,
130 info.background_color, callback_pointer); 130 info.background_color, callback_pointer);
131 } 131 }
132 132
133 void ShortcutHelper::AddShortcutWithSkBitmap( 133 void ShortcutHelper::AddShortcutWithSkBitmap(
134 const ShortcutInfo& info, 134 const ShortcutInfo& info,
135 const SkBitmap& icon_bitmap) { 135 const SkBitmap& icon_bitmap) {
136 JNIEnv* env = base::android::AttachCurrentThread(); 136 JNIEnv* env = base::android::AttachCurrentThread();
137 ScopedJavaLocalRef<jstring> java_url = 137 ScopedJavaLocalRef<jstring> java_url =
138 base::android::ConvertUTF8ToJavaString(env, info.url.spec()); 138 base::android::ConvertUTF8ToJavaString(env, info.url.spec());
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 DCHECK(jsplash_image_callback); 286 DCHECK(jsplash_image_callback);
287 base::Closure* splash_image_callback = 287 base::Closure* splash_image_callback =
288 reinterpret_cast<base::Closure*>(jsplash_image_callback); 288 reinterpret_cast<base::Closure*>(jsplash_image_callback);
289 splash_image_callback->Run(); 289 splash_image_callback->Run();
290 delete splash_image_callback; 290 delete splash_image_callback;
291 } 291 }
292 292
293 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 293 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
294 return RegisterNativesImpl(env); 294 return RegisterNativesImpl(env);
295 } 295 }
OLDNEW
« no previous file with comments | « chrome/browser/android/banners/app_banner_manager_android.cc ('k') | chrome/browser/android/shortcut_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698