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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java

Issue 2363183002: Skip installation process if WebAPK is already installed. (Closed)
Patch Set: Addressing comments Created 4 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/android/banners/app_banner_infobar_delegate_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 package org.chromium.chrome.browser; 5 package org.chromium.chrome.browser;
6 6
7 import android.app.ActivityManager; 7 import android.app.ActivityManager;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.pm.ApplicationInfo; 10 import android.content.pm.ApplicationInfo;
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 RoundedIconGenerator generator = new RoundedIconGenerator( 448 RoundedIconGenerator generator = new RoundedIconGenerator(
449 innerSize, innerSize, cornerRadius, color, fontSize); 449 innerSize, innerSize, cornerRadius, color, fontSize);
450 Bitmap icon = generator.generateIconForUrl(url); 450 Bitmap icon = generator.generateIconForUrl(url);
451 if (icon == null) return null; // Bookmark URL does not have a domain. 451 if (icon == null) return null; // Bookmark URL does not have a domain.
452 canvas.drawBitmap(icon, padding, padding, null); 452 canvas.drawBitmap(icon, padding, padding, null);
453 453
454 return bitmap; 454 return bitmap;
455 } 455 }
456 456
457 /** 457 /**
458 * Returns true if WebAPKs are enabled and there is a WebAPK installed which can handle 458 * Returns the package name of the WebAPK if WebAPKs are enabled and there i s an installed
459 * WebAPK which can handle {@link url}. Returns null otherwise.
460 */
461 @CalledByNative
462 private static String queryWebApkPackage(String url) {
463 if (!ChromeWebApkHost.isEnabled()) return null;
464 return WebApkValidator.queryWebApkPackage(ContextUtils.getApplicationCon text(), url);
465 }
466
467 /**
468 * Returns true if WebAPKs are enabled and there is an installed WebAPK whic h can handle
459 * {@link url}. 469 * {@link url}.
460 */ 470 */
461 @CalledByNative 471 @CalledByNative
462 private static boolean isWebApkInstalled(String url) { 472 private static boolean isWebApkInstalled(String url) {
463 if (!ChromeWebApkHost.isEnabled()) { 473 return queryWebApkPackage(url) != null;
464 return false;
465 }
466 return WebApkValidator.queryWebApkPackage(ContextUtils.getApplicationCon text(), url)
467 != null;
468 } 474 }
469 475
470 /** 476 /**
471 * Compresses a bitmap into a PNG and converts into a Base64 encoded string. 477 * Compresses a bitmap into a PNG and converts into a Base64 encoded string.
472 * The encoded string can be decoded using {@link decodeBitmapFromString(Str ing)}. 478 * The encoded string can be decoded using {@link decodeBitmapFromString(Str ing)}.
473 * @param bitmap The Bitmap to compress and encode. 479 * @param bitmap The Bitmap to compress and encode.
474 * @return the String encoding the Bitmap. 480 * @return the String encoding the Bitmap.
475 */ 481 */
476 public static String encodeBitmapAsString(Bitmap bitmap) { 482 public static String encodeBitmapAsString(Bitmap bitmap) {
477 if (bitmap == null) return ""; 483 if (bitmap == null) return "";
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 if (drawable instanceof BitmapDrawable) { 632 if (drawable instanceof BitmapDrawable) {
627 BitmapDrawable bd = (BitmapDrawable) drawable; 633 BitmapDrawable bd = (BitmapDrawable) drawable;
628 return bd.getBitmap(); 634 return bd.getBitmap();
629 } 635 }
630 assert false : "The drawable was not a bitmap drawable as expected"; 636 assert false : "The drawable was not a bitmap drawable as expected";
631 return null; 637 return null;
632 } 638 }
633 639
634 private static native void nativeOnWebappDataStored(long callbackPointer); 640 private static native void nativeOnWebappDataStored(long callbackPointer);
635 } 641 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/banners/app_banner_infobar_delegate_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698