org.chromium.chrome.browser.ShortcutHelper Java Examples
The following examples show how to use
org.chromium.chrome.browser.ShortcutHelper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebappInfo.java From delion with Apache License 2.0 | 7 votes |
public static int displayModeFromIntent(Intent intent) { String displayMode = IntentUtils.safeGetStringExtra(intent, WebApkConstants.EXTRA_WEBAPK_DISPLAY_MODE); if (displayMode == null) { return IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Standalone); } // {@link displayMode} should be one of // https://w3c.github.io/manifest/#dfn-display-modes-values if (displayMode.equals("fullscreen")) { return WebDisplayMode.Fullscreen; } else if (displayMode.equals("minimal-ui")) { return WebDisplayMode.MinimalUi; } else if (displayMode.equals("browser")) { return WebDisplayMode.Browser; } else { return WebDisplayMode.Standalone; } }
Example #2
Source File: WebappInfo.java From delion with Apache License 2.0 | 6 votes |
/** * Construct a WebappInfo. * @param intent Intent containing info about the app. */ public static WebappInfo create(Intent intent) { String id = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ID); String icon = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ICON); String url = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_URL); int displayMode = displayModeFromIntent(intent); int orientation = orientationFromIntent(intent); int source = IntentUtils.safeGetIntExtra(intent, ShortcutHelper.EXTRA_SOURCE, ShortcutSource.UNKNOWN); long themeColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_THEME_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); long backgroundColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_BACKGROUND_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); boolean isIconGenerated = IntentUtils.safeGetBooleanExtra(intent, ShortcutHelper.EXTRA_IS_ICON_GENERATED, false); String name = nameFromIntent(intent); String shortName = shortNameFromIntent(intent); String webApkPackageName = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME); return create(id, url, icon, name, shortName, displayMode, orientation, source, themeColor, backgroundColor, isIconGenerated, webApkPackageName); }
Example #3
Source File: WebApkActivity.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); // We could bring a WebAPK hosted WebappActivity to foreground and navigate it to a // different URL. For example, WebAPK "foo" is launched and navigates to // "www.foo.com/foo". In Chrome, user clicks a link "www.foo.com/bar" in Google search // results. After clicking the link, WebAPK "foo" is brought to foreground, and // loads the page of "www.foo.com/bar" at the same time. // The extra {@link ShortcutHelper.EXTRA_URL} provides the URL that the WebAPK will // navigate to. String overrideUrl = intent.getStringExtra(ShortcutHelper.EXTRA_URL); if (overrideUrl != null && isInitialized() && !overrideUrl.equals(getActivityTab().getUrl())) { getActivityTab().loadUrl( new LoadUrlParams(overrideUrl, PageTransition.AUTO_TOPLEVEL)); } }
Example #4
Source File: WebApkMetaDataUtils.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Populates {@link WebappInfo} with meta data extracted from WebAPK's Android Manifest. * @param webApkPackageName Package name of the WebAPK to extract meta data from. * @param url WebAPK start URL. * @param source {@link ShortcutSource} that the WebAPK was opened from. */ public static WebApkInfo extractWebappInfoFromWebApk( String webApkPackageName, String url, int source) { WebApkMetaData metaData = extractMetaDataFromWebApk(webApkPackageName); if (metaData == null) return null; PackageManager packageManager = ContextUtils.getApplicationContext().getPackageManager(); Resources resources; try { resources = packageManager.getResourcesForApplication(webApkPackageName); } catch (PackageManager.NameNotFoundException e) { return null; } Bitmap icon = BitmapFactory.decodeResource(resources, metaData.iconId); String encodedIcon = ShortcutHelper.encodeBitmapAsString(icon); return WebApkInfo.create(WebApkConstants.WEBAPK_ID_PREFIX + webApkPackageName, url, metaData.scope, encodedIcon, metaData.name, metaData.shortName, metaData.displayMode, metaData.orientation, source, metaData.themeColor, metaData.backgroundColor, TextUtils.isEmpty(metaData.iconUrl), webApkPackageName); }
Example #5
Source File: WebappDelegateFactory.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void activateContents() { String startUrl = mActivity.getWebappInfo().uri().toString(); // Create an Intent that will be fired toward the WebappLauncherActivity, which in turn // will fire an Intent to launch the correct WebappActivity. On L+ this could probably // be changed to call AppTask.moveToFront(), but for backwards compatibility we relaunch // it the hard way. Intent intent = new Intent(); intent.setAction(WebappLauncherActivity.ACTION_START_WEBAPP); intent.setPackage(mActivity.getPackageName()); mActivity.getWebappInfo().setWebappIntentExtras(intent); intent.putExtra( ShortcutHelper.EXTRA_MAC, ShortcutHelper.getEncodedMac(mActivity, startUrl)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ContextUtils.getApplicationContext().startActivity(intent); }
Example #6
Source File: WebappLauncherActivity.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Checks whether the WebAPK package specified in the intent is a valid WebAPK and whether the * url specified in the intent can be fulfilled by the WebAPK. * * @param intent The intent * @return true iff all validation criteria are met. */ private boolean isValidWebApk(Intent intent) { if (!ChromeWebApkHost.isEnabled()) return false; String webApkPackage = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME); if (TextUtils.isEmpty(webApkPackage)) return false; String url = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_URL); if (TextUtils.isEmpty(url)) return false; if (!webApkPackage.equals(WebApkValidator.queryWebApkPackage(this, url))) { Log.d(TAG, "%s is not within scope of %s WebAPK", url, webApkPackage); return false; } return true; }
Example #7
Source File: WebappDelegateFactory.java From delion with Apache License 2.0 | 6 votes |
@Override public void activateContents() { String startUrl = mActivity.getWebappInfo().uri().toString(); // Create an Intent that will be fired toward the WebappLauncherActivity, which in turn // will fire an Intent to launch the correct WebappActivity. On L+ this could probably // be changed to call AppTask.moveToFront(), but for backwards compatibility we relaunch // it the hard way. Intent intent = new Intent(); intent.setAction(WebappLauncherActivity.ACTION_START_WEBAPP); intent.setPackage(mActivity.getPackageName()); mActivity.getWebappInfo().setWebappIntentExtras(intent); intent.putExtra( ShortcutHelper.EXTRA_MAC, ShortcutHelper.getEncodedMac(mActivity, startUrl)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ContextUtils.getApplicationContext().startActivity(intent); }
Example #8
Source File: WebappInfo.java From delion with Apache License 2.0 | 6 votes |
/** * Sets extras on an Intent that will launch a WebappActivity. * @param intent Intent that will be used to launch a WebappActivity. */ public void setWebappIntentExtras(Intent intent) { intent.putExtra(ShortcutHelper.EXTRA_ID, id()); intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString()); intent.putExtra(ShortcutHelper.EXTRA_SCOPE, ShortcutHelper.getScopeFromUrl(uri().toString())); intent.putExtra(ShortcutHelper.EXTRA_ICON, encodedIcon()); intent.putExtra(ShortcutHelper.EXTRA_VERSION, ShortcutHelper.WEBAPP_SHORTCUT_VERSION); intent.putExtra(ShortcutHelper.EXTRA_NAME, name()); intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName()); intent.putExtra(ShortcutHelper.EXTRA_DISPLAY_MODE, displayMode()); intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, orientation()); intent.putExtra(ShortcutHelper.EXTRA_SOURCE, source()); intent.putExtra(ShortcutHelper.EXTRA_THEME_COLOR, themeColor()); intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, backgroundColor()); intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, isIconGenerated()); if (webApkPackageName() != null) { intent.putExtra(ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME, webApkPackageName()); } }
Example #9
Source File: WebApkInfo.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Constructs a WebApkInfo from the passed in Intent and <meta-data> in the WebAPK's Android * manifest. * @param intent Intent containing info about the app. */ public static WebApkInfo create(Intent intent) { String webApkPackageName = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME); if (TextUtils.isEmpty(webApkPackageName)) { return null; } String url = urlFromIntent(intent); int source = sourceFromIntent(intent); // Unlike non-WebAPK web apps, WebAPK ids are predictable. A malicious actor may send an // intent with a valid start URL and arbitrary other data. Only use the start URL, the // package name and the ShortcutSource from the launch intent and extract the remaining data // from the <meta-data> in the WebAPK's Android manifest. return WebApkMetaDataUtils.extractWebappInfoFromWebApk(webApkPackageName, url, source); }
Example #10
Source File: WebappLauncherActivity.java From 365browser with Apache License 2.0 | 6 votes |
/** * Checks whether the WebAPK package specified in the intent is a valid WebAPK and whether the * url specified in the intent can be fulfilled by the WebAPK. * * @param intent The intent * @return true iff all validation criteria are met. */ private boolean isValidWebApk(Intent intent) { if (!ChromeWebApkHost.isEnabled()) return false; String webApkPackage = IntentUtils.safeGetStringExtra(intent, WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME); if (TextUtils.isEmpty(webApkPackage)) return false; String url = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_URL); if (TextUtils.isEmpty(url)) return false; if (!webApkPackage.equals(WebApkValidator.queryWebApkPackage(this, url))) { Log.d(TAG, "%s is not within scope of %s WebAPK", url, webApkPackage); return false; } return true; }
Example #11
Source File: WebappInfo.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Sets extras on an Intent that will launch a WebappActivity. * @param intent Intent that will be used to launch a WebappActivity. */ public void setWebappIntentExtras(Intent intent) { intent.putExtra(ShortcutHelper.EXTRA_ID, id()); intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString()); intent.putExtra(ShortcutHelper.EXTRA_SCOPE, scopeUri().toString()); intent.putExtra(ShortcutHelper.EXTRA_ICON, encodedIcon()); intent.putExtra(ShortcutHelper.EXTRA_VERSION, ShortcutHelper.WEBAPP_SHORTCUT_VERSION); intent.putExtra(ShortcutHelper.EXTRA_NAME, name()); intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName()); intent.putExtra(ShortcutHelper.EXTRA_DISPLAY_MODE, displayMode()); intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, orientation()); intent.putExtra(ShortcutHelper.EXTRA_SOURCE, source()); intent.putExtra(ShortcutHelper.EXTRA_THEME_COLOR, themeColor()); intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, backgroundColor()); intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, isIconGenerated()); if (webApkPackageName() != null) { intent.putExtra(ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME, webApkPackageName()); } }
Example #12
Source File: WebappInfo.java From AndroidChromium with Apache License 2.0 | 6 votes |
protected WebappInfo(String id, String url, String scope, String encodedIcon, String name, String shortName, int displayMode, int orientation, int source, long themeColor, long backgroundColor, boolean isIconGenerated) { Uri uri = Uri.parse(url); if (TextUtils.isEmpty(scope)) { scope = ShortcutHelper.getScopeFromUrl(url); } Uri scopeUri = Uri.parse(scope); mEncodedIcon = encodedIcon; mId = id; mName = name; mShortName = shortName; mUri = uri; mScopeUri = scopeUri; mDisplayMode = displayMode; mOrientation = orientation; mSource = source; mThemeColor = themeColor; mBackgroundColor = backgroundColor; mIsIconGenerated = isIconGenerated; mIsInitialized = mUri != null; }
Example #13
Source File: WebappInfo.java From 365browser with Apache License 2.0 | 6 votes |
/** * Construct a WebappInfo. * @param intent Intent containing info about the app. */ public static WebappInfo create(Intent intent) { String id = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ID); String icon = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ICON); String url = urlFromIntent(intent); String scope = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_SCOPE); int displayMode = IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.STANDALONE); int orientation = IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT); int source = sourceFromIntent(intent); long themeColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_THEME_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); long backgroundColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_BACKGROUND_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); boolean isIconGenerated = IntentUtils.safeGetBooleanExtra(intent, ShortcutHelper.EXTRA_IS_ICON_GENERATED, false); String name = nameFromIntent(intent); String shortName = shortNameFromIntent(intent); return create(id, url, scope, new Icon(icon), name, shortName, displayMode, orientation, source, themeColor, backgroundColor, isIconGenerated); }
Example #14
Source File: WebappInfo.java From 365browser with Apache License 2.0 | 6 votes |
protected WebappInfo(String id, String url, String scope, Icon icon, String name, String shortName, int displayMode, int orientation, int source, long themeColor, long backgroundColor, boolean isIconGenerated) { Uri uri = Uri.parse(url); if (TextUtils.isEmpty(scope)) { scope = ShortcutHelper.getScopeFromUrl(url); } Uri scopeUri = Uri.parse(scope); mIcon = icon; mId = id; mName = name; mShortName = shortName; mUri = uri; mScopeUri = scopeUri; mDisplayMode = displayMode; mOrientation = orientation; mSource = source; mThemeColor = themeColor; mBackgroundColor = backgroundColor; mIsIconGenerated = isIconGenerated; mIsInitialized = mUri != null; }
Example #15
Source File: WebApkActivity.java From delion with Apache License 2.0 | 6 votes |
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); // We could bring a WebAPK hosted WebappActivity to foreground and navigate it to a // different URL. For example, WebAPK "foo" is launched and navigates to // "www.foo.com/foo". In Chrome, user clicks a link "www.foo.com/bar" in Google search // results. After clicking the link, WebAPK "foo" is brought to foreground, and // loads the page of "www.foo.com/bar" at the same time. // The extra {@link ShortcutHelper.EXTRA_URL} provides the URL that the WebAPK will // navigate to. String overrideUrl = intent.getStringExtra(ShortcutHelper.EXTRA_URL); if (overrideUrl != null && isInitialized() && !overrideUrl.equals(getActivityTab().getUrl())) { getActivityTab().loadUrl( new LoadUrlParams(overrideUrl, PageTransition.AUTO_TOPLEVEL)); } }
Example #16
Source File: WebappInfo.java From 365browser with Apache License 2.0 | 6 votes |
/** * Sets extras on an Intent that will launch a WebappActivity. * @param intent Intent that will be used to launch a WebappActivity. */ public void setWebappIntentExtras(Intent intent) { intent.putExtra(ShortcutHelper.EXTRA_ID, id()); intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString()); intent.putExtra(ShortcutHelper.EXTRA_SCOPE, scopeUri().toString()); intent.putExtra(ShortcutHelper.EXTRA_ICON, encodedIcon()); intent.putExtra(ShortcutHelper.EXTRA_VERSION, ShortcutHelper.WEBAPP_SHORTCUT_VERSION); intent.putExtra(ShortcutHelper.EXTRA_NAME, name()); intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName()); intent.putExtra(ShortcutHelper.EXTRA_DISPLAY_MODE, displayMode()); intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, orientation()); intent.putExtra(ShortcutHelper.EXTRA_SOURCE, source()); intent.putExtra(ShortcutHelper.EXTRA_THEME_COLOR, themeColor()); intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, backgroundColor()); intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, isIconGenerated()); }
Example #17
Source File: WebappInfo.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Construct a WebappInfo. * @param intent Intent containing info about the app. */ public static WebappInfo create(Intent intent) { String id = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ID); String icon = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ICON); String url = urlFromIntent(intent); String scope = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_SCOPE); int displayMode = IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Standalone); int orientation = IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT); int source = sourceFromIntent(intent); long themeColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_THEME_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); long backgroundColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_BACKGROUND_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); boolean isIconGenerated = IntentUtils.safeGetBooleanExtra(intent, ShortcutHelper.EXTRA_IS_ICON_GENERATED, false); String name = nameFromIntent(intent); String shortName = shortNameFromIntent(intent); return create(id, url, scope, icon, name, shortName, displayMode, orientation, source, themeColor, backgroundColor, isIconGenerated); }
Example #18
Source File: BookmarkWidgetProxy.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (BookmarkWidgetService.getChangeFolderAction(context) .equals(intent.getAction())) { BookmarkWidgetService.changeFolder(context, intent); } else { Intent view = new Intent(intent); view.setClass(context, ChromeLauncherActivity.class); view.putExtra(ShortcutHelper.EXTRA_SOURCE, ShortcutSource.BOOKMARK_NAVIGATOR_WIDGET); view.putExtra(ShortcutHelper.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); startActivity(context, view); } }
Example #19
Source File: WebApkInfo.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void setWebappIntentExtras(Intent intent) { // For launching a {@link WebApkActivity}. intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString()); intent.putExtra(ShortcutHelper.EXTRA_SOURCE, source()); intent.putExtra(ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME, webApkPackageName()); }
Example #20
Source File: ManifestUpgradeDetector.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Called when the updated Web Manifest has been fetched. */ @Override public void onGotManifestData(String startUrl, String scopeUrl, String name, String shortName, String iconUrl, String iconMurmur2Hash, Bitmap iconBitmap, int displayMode, int orientation, long themeColor, long backgroundColor) { mFetcher.destroy(); mFetcher = null; if (TextUtils.isEmpty(scopeUrl)) { scopeUrl = ShortcutHelper.getScopeFromUrl(startUrl); } FetchedManifestData fetchedData = new FetchedManifestData(); fetchedData.startUrl = startUrl; fetchedData.scopeUrl = scopeUrl; fetchedData.name = name; fetchedData.shortName = shortName; fetchedData.iconUrl = iconUrl; fetchedData.iconMurmur2Hash = iconMurmur2Hash; fetchedData.icon = iconBitmap; fetchedData.displayMode = displayMode; fetchedData.orientation = orientation; fetchedData.themeColor = themeColor; fetchedData.backgroundColor = backgroundColor; // TODO(hanxi): crbug.com/627824. Validate whether the new fetched data is // WebAPK-compatible. boolean upgrade = needsUpgrade(fetchedData); mCallback.onGotManifestData(upgrade, fetchedData); }
Example #21
Source File: AppBannerManager.java From delion with Apache License 2.0 | 5 votes |
/** * Checks if app banners are enabled. * @return True if banners are enabled, false otherwise. */ public static boolean isEnabled() { if (sIsEnabled == null) { Context context = ContextUtils.getApplicationContext(); sIsEnabled = ShortcutHelper.isAddToHomeIntentSupported(context); } return sIsEnabled; }
Example #22
Source File: ChromeLauncherActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @return Whether or not an Herb prototype may hijack an Intent. */ public static boolean canBeHijackedByHerb(Intent intent) { String url = IntentHandler.getUrlFromIntent(intent); // Only VIEW Intents with URLs are rerouted to Custom Tabs. if (intent == null || !TextUtils.equals(Intent.ACTION_VIEW, intent.getAction()) || TextUtils.isEmpty(url)) { return false; } // Don't open explicitly opted out intents in custom tabs. if (CustomTabsIntent.shouldAlwaysUseBrowserUI(intent)) { return false; } // Don't reroute Chrome Intents. Context context = ContextUtils.getApplicationContext(); if (TextUtils.equals(context.getPackageName(), IntentUtils.safeGetStringExtra(intent, Browser.EXTRA_APPLICATION_ID)) || IntentHandler.wasIntentSenderChrome(intent, context)) { return false; } // Don't reroute internal chrome URLs. try { URI uri = URI.create(url); if (UrlUtilities.isInternalScheme(uri)) return false; } catch (IllegalArgumentException e) { return false; } // Don't reroute Home screen shortcuts. if (IntentUtils.safeHasExtra(intent, ShortcutHelper.EXTRA_SOURCE)) { return false; } return true; }
Example #23
Source File: BookmarkWidgetProxy.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (BookmarkWidgetService.getChangeFolderAction(context) .equals(intent.getAction())) { BookmarkWidgetService.changeFolder(context, intent); } else { Intent view = new Intent(intent); view.setClass(context, ChromeLauncherActivity.class); view.putExtra(ShortcutHelper.EXTRA_SOURCE, ShortcutSource.BOOKMARK_NAVIGATOR_WIDGET); view.putExtra(ShortcutHelper.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); startActivity(context, view); } }
Example #24
Source File: AppBannerManager.java From 365browser with Apache License 2.0 | 5 votes |
/** * Checks if the add to home screen intent is supported. * @return true if add to home screen is supported, false otherwise. */ public static boolean isSupported() { if (sIsSupported == null) { sIsSupported = ShortcutHelper.isAddToHomeIntentSupported(); } return sIsSupported; }
Example #25
Source File: ContentSuggestionsNotificationHelper.java From 365browser with Apache License 2.0 | 5 votes |
private static void openUrl(Uri uri) { Context context = ContextUtils.getApplicationContext(); Intent intent = new Intent() .setAction(Intent.ACTION_VIEW) .setData(uri) .setClass(context, ChromeLauncherActivity.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()) .putExtra(ShortcutHelper.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); IntentHandler.addTrustedIntentExtras(intent); context.startActivity(intent); }
Example #26
Source File: WebappLauncherActivity.java From 365browser with Apache License 2.0 | 5 votes |
private void launchInTab(String webappUrl, int webappSource) { if (TextUtils.isEmpty(webappUrl)) return; Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webappUrl)); launchIntent.setClassName(getPackageName(), ChromeLauncherActivity.class.getName()); launchIntent.putExtra(ShortcutHelper.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); launchIntent.putExtra(ShortcutHelper.EXTRA_SOURCE, webappSource); launchIntent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | ApiCompatibilityUtils.getActivityNewDocumentFlag()); startActivity(launchIntent); }
Example #27
Source File: WebappInfo.java From 365browser with Apache License 2.0 | 5 votes |
protected static int sourceFromIntent(Intent intent) { int source = IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_SOURCE, ShortcutSource.UNKNOWN); if (source >= ShortcutSource.COUNT) { source = ShortcutSource.UNKNOWN; } return source; }
Example #28
Source File: WebappInfo.java From 365browser with Apache License 2.0 | 5 votes |
private static String titleFromIntent(Intent intent) { // The reference to title has been kept for reasons of backward compatibility. For intents // and shortcuts which were created before we utilized the concept of name and shortName, // we set the name and shortName to be the title. String title = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_TITLE); return title == null ? "" : title; }
Example #29
Source File: WebApkInfo.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void setWebappIntentExtras(Intent intent) { // For launching a {@link WebApkActivity}. intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString()); intent.putExtra(ShortcutHelper.EXTRA_SOURCE, source()); intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, webApkPackageName()); intent.putExtra(WebApkConstants.EXTRA_WEBAPK_FORCE_NAVIGATION, mForceNavigation); }
Example #30
Source File: ChromeLauncherActivity.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return Whether or not an Herb prototype may hijack an Intent. */ public static boolean canBeHijackedByHerb(Intent intent) { String url = IntentHandler.getUrlFromIntent(intent); // Only VIEW Intents with URLs are rerouted to Custom Tabs. if (intent == null || !TextUtils.equals(Intent.ACTION_VIEW, intent.getAction()) || TextUtils.isEmpty(url)) { return false; } // Don't open explicitly opted out intents in custom tabs. if (CustomTabsIntent.shouldAlwaysUseBrowserUI(intent)) { return false; } // Don't reroute Chrome Intents. Context context = ContextUtils.getApplicationContext(); if (TextUtils.equals(context.getPackageName(), IntentUtils.safeGetStringExtra(intent, Browser.EXTRA_APPLICATION_ID)) || IntentHandler.wasIntentSenderChrome(intent)) { return false; } // Don't reroute internal chrome URLs. try { URI uri = URI.create(url); if (UrlUtilities.isInternalScheme(uri)) return false; } catch (IllegalArgumentException e) { return false; } // Don't reroute Home screen shortcuts. if (IntentUtils.safeHasExtra(intent, ShortcutHelper.EXTRA_SOURCE)) { return false; } return true; }