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

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

Issue 2124703003: Do not show "Add to Home Screen" info bar if WebAPK is installed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_app_banner_already_installed 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 *is_generated = true; 206 *is_generated = true;
207 result = Java_ShortcutHelper_generateHomeScreenIcon( 207 result = Java_ShortcutHelper_generateHomeScreenIcon(
208 env, java_url.obj(), SkColorGetR(mean_color), SkColorGetG(mean_color), 208 env, java_url.obj(), SkColorGetR(mean_color), SkColorGetG(mean_color),
209 SkColorGetB(mean_color)); 209 SkColorGetB(mean_color));
210 } 210 }
211 211
212 return gfx::CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(result.obj())); 212 return gfx::CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(result.obj()));
213 } 213 }
214 214
215 // static
216 bool ShortcutHelper::IsWebApkInstalled(const GURL& url) {
217 JNIEnv* env = base::android::AttachCurrentThread();
218 ScopedJavaLocalRef<jstring> java_url =
219 base::android::ConvertUTF8ToJavaString(env, url.spec());
220 return Java_ShortcutHelper_isWebApkInstalled(env, java_url.obj());
221 }
222
215 // Callback used by Java when the shortcut has been created. 223 // Callback used by Java when the shortcut has been created.
216 // |splash_image_callback| is a pointer to a base::Closure allocated in 224 // |splash_image_callback| is a pointer to a base::Closure allocated in
217 // AddShortcutInBackgroundWithSkBitmap, so reinterpret_cast it back and run it. 225 // AddShortcutInBackgroundWithSkBitmap, so reinterpret_cast it back and run it.
218 // 226 //
219 // This callback should only ever be called when the shortcut was for a 227 // This callback should only ever be called when the shortcut was for a
220 // webapp-capable site; otherwise, |splash_image_callback| will have never been 228 // webapp-capable site; otherwise, |splash_image_callback| will have never been
221 // allocated and doesn't need to be run or deleted. 229 // allocated and doesn't need to be run or deleted.
222 void OnWebappDataStored(JNIEnv* env, 230 void OnWebappDataStored(JNIEnv* env,
223 const JavaParamRef<jclass>& clazz, 231 const JavaParamRef<jclass>& clazz,
224 jlong jsplash_image_callback) { 232 jlong jsplash_image_callback) {
225 DCHECK(jsplash_image_callback); 233 DCHECK(jsplash_image_callback);
226 base::Closure* splash_image_callback = 234 base::Closure* splash_image_callback =
227 reinterpret_cast<base::Closure*>(jsplash_image_callback); 235 reinterpret_cast<base::Closure*>(jsplash_image_callback);
228 splash_image_callback->Run(); 236 splash_image_callback->Run();
229 delete splash_image_callback; 237 delete splash_image_callback;
230 } 238 }
231 239
232 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 240 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
233 return RegisterNativesImpl(env); 241 return RegisterNativesImpl(env);
234 } 242 }
OLDNEW
« no previous file with comments | « chrome/browser/android/shortcut_helper.h ('k') | chrome/browser/banners/app_banner_data_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698