Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.PackageManager; | 10 import android.content.pm.PackageManager; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 import android.graphics.RectF; | 21 import android.graphics.RectF; |
| 22 import android.graphics.drawable.BitmapDrawable; | 22 import android.graphics.drawable.BitmapDrawable; |
| 23 import android.graphics.drawable.Drawable; | 23 import android.graphics.drawable.Drawable; |
| 24 import android.net.Uri; | 24 import android.net.Uri; |
| 25 import android.os.Handler; | 25 import android.os.Handler; |
| 26 import android.os.Looper; | 26 import android.os.Looper; |
| 27 import android.text.TextUtils; | 27 import android.text.TextUtils; |
| 28 import android.util.Base64; | 28 import android.util.Base64; |
| 29 | 29 |
| 30 import org.chromium.base.ApiCompatibilityUtils; | 30 import org.chromium.base.ApiCompatibilityUtils; |
| 31 import org.chromium.base.CommandLine; | |
| 31 import org.chromium.base.ContextUtils; | 32 import org.chromium.base.ContextUtils; |
| 32 import org.chromium.base.Log; | 33 import org.chromium.base.Log; |
| 33 import org.chromium.base.ThreadUtils; | 34 import org.chromium.base.ThreadUtils; |
| 34 import org.chromium.base.VisibleForTesting; | 35 import org.chromium.base.VisibleForTesting; |
| 35 import org.chromium.base.annotations.CalledByNative; | 36 import org.chromium.base.annotations.CalledByNative; |
| 36 import org.chromium.blink_public.platform.WebDisplayMode; | 37 import org.chromium.blink_public.platform.WebDisplayMode; |
| 37 import org.chromium.chrome.R; | 38 import org.chromium.chrome.R; |
| 39 import org.chromium.chrome.browser.webapps.WebApkBuilder; | |
| 38 import org.chromium.chrome.browser.webapps.WebappAuthenticator; | 40 import org.chromium.chrome.browser.webapps.WebappAuthenticator; |
| 39 import org.chromium.chrome.browser.webapps.WebappDataStorage; | 41 import org.chromium.chrome.browser.webapps.WebappDataStorage; |
| 40 import org.chromium.chrome.browser.webapps.WebappLauncherActivity; | 42 import org.chromium.chrome.browser.webapps.WebappLauncherActivity; |
| 41 import org.chromium.chrome.browser.webapps.WebappRegistry; | 43 import org.chromium.chrome.browser.webapps.WebappRegistry; |
| 42 import org.chromium.chrome.browser.widget.RoundedIconGenerator; | 44 import org.chromium.chrome.browser.widget.RoundedIconGenerator; |
| 43 import org.chromium.content_public.common.ScreenOrientationConstants; | 45 import org.chromium.content_public.common.ScreenOrientationConstants; |
| 46 import org.chromium.net.GURLUtils; | |
| 44 import org.chromium.ui.widget.Toast; | 47 import org.chromium.ui.widget.Toast; |
| 45 | 48 |
| 46 import java.io.ByteArrayOutputStream; | 49 import java.io.ByteArrayOutputStream; |
| 47 import java.util.List; | 50 import java.util.List; |
| 48 | 51 |
| 49 /** | 52 /** |
| 50 * This class contains functions related to adding shortcuts to the Android Home | 53 * This class contains functions related to adding shortcuts to the Android Home |
| 51 * screen. These shortcuts are used to either open a page in the main browser | 54 * screen. These shortcuts are used to either open a page in the main browser |
| 52 * or open a web app. | 55 * or open a web app. |
| 53 */ | 56 */ |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 String name, String shortName, Bitmap icon, int displayMode, int ori entation, | 144 String name, String shortName, Bitmap icon, int displayMode, int ori entation, |
| 142 int source, long themeColor, long backgroundColor, boolean isIconGen erated, | 145 int source, long themeColor, long backgroundColor, boolean isIconGen erated, |
| 143 final long callbackPointer) { | 146 final long callbackPointer) { |
| 144 assert !ThreadUtils.runningOnUiThread(); | 147 assert !ThreadUtils.runningOnUiThread(); |
| 145 | 148 |
| 146 Context context = ContextUtils.getApplicationContext(); | 149 Context context = ContextUtils.getApplicationContext(); |
| 147 final Intent shortcutIntent; | 150 final Intent shortcutIntent; |
| 148 boolean isWebappCapable = (displayMode == WebDisplayMode.Standalone | 151 boolean isWebappCapable = (displayMode == WebDisplayMode.Standalone |
| 149 || displayMode == WebDisplayMode.Fullscreen); | 152 || displayMode == WebDisplayMode.Fullscreen); |
| 150 if (isWebappCapable) { | 153 if (isWebappCapable) { |
| 154 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK )) { | |
| 155 WebApkBuilder apkBuilder = ((ChromeApplication) context).createW ebApkBuilder(); | |
| 156 if (apkBuilder != null) { | |
| 157 apkBuilder.buildWebApkAsync(url, GURLUtils.getOrigin(url), s hortName, icon); | |
|
Xi Han
2016/06/06 21:20:18
We could do the encoding for the "icon" here, and
pkotwicz
2016/06/06 21:29:24
We could. I think that the fact that buildWebApkAs
Xi Han
2016/06/07 13:20:37
You are right, we should keep the Bitmap.
| |
| 158 return; | |
| 159 } | |
| 160 } | |
| 151 shortcutIntent = createWebappShortcutIntent(id, sDelegate.getFullscr eenAction(), url, | 161 shortcutIntent = createWebappShortcutIntent(id, sDelegate.getFullscr eenAction(), url, |
| 152 getScopeFromUrl(url), name, shortName, icon, WEBAPP_SHORTCUT _VERSION, | 162 getScopeFromUrl(url), name, shortName, icon, WEBAPP_SHORTCUT _VERSION, |
| 153 displayMode, orientation, themeColor, backgroundColor, isIco nGenerated); | 163 displayMode, orientation, themeColor, backgroundColor, isIco nGenerated); |
| 154 shortcutIntent.putExtra(EXTRA_MAC, getEncodedMac(context, url)); | 164 shortcutIntent.putExtra(EXTRA_MAC, getEncodedMac(context, url)); |
| 155 } else { | 165 } else { |
| 156 // Add the shortcut as a launcher icon to open in the browser Activi ty. | 166 // Add the shortcut as a launcher icon to open in the browser Activi ty. |
| 157 shortcutIntent = createShortcutIntent(url); | 167 shortcutIntent = createShortcutIntent(url); |
| 158 } | 168 } |
| 159 | 169 |
| 160 // Always attach a source (one of add to home screen menu item, app bann er, or unknown) to | 170 // Always attach a source (one of add to home screen menu item, app bann er, or unknown) to |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 if (drawable instanceof BitmapDrawable) { | 569 if (drawable instanceof BitmapDrawable) { |
| 560 BitmapDrawable bd = (BitmapDrawable) drawable; | 570 BitmapDrawable bd = (BitmapDrawable) drawable; |
| 561 return bd.getBitmap(); | 571 return bd.getBitmap(); |
| 562 } | 572 } |
| 563 assert false : "The drawable was not a bitmap drawable as expected"; | 573 assert false : "The drawable was not a bitmap drawable as expected"; |
| 564 return null; | 574 return null; |
| 565 } | 575 } |
| 566 | 576 |
| 567 private static native void nativeOnWebappDataStored(long callbackPointer); | 577 private static native void nativeOnWebappDataStored(long callbackPointer); |
| 568 } | 578 } |
| OLD | NEW |