| 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); |
| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 if (drawable instanceof BitmapDrawable) { | 568 if (drawable instanceof BitmapDrawable) { |
| 559 BitmapDrawable bd = (BitmapDrawable) drawable; | 569 BitmapDrawable bd = (BitmapDrawable) drawable; |
| 560 return bd.getBitmap(); | 570 return bd.getBitmap(); |
| 561 } | 571 } |
| 562 assert false : "The drawable was not a bitmap drawable as expected"; | 572 assert false : "The drawable was not a bitmap drawable as expected"; |
| 563 return null; | 573 return null; |
| 564 } | 574 } |
| 565 | 575 |
| 566 private static native void nativeOnWebappDataStored(long callbackPointer); | 576 private static native void nativeOnWebappDataStored(long callbackPointer); |
| 567 } | 577 } |
| OLD | NEW |