Java Code Examples for org.chromium.chrome.browser.util.UrlUtilities#isInternalScheme()
The following examples show how to use
org.chromium.chrome.browser.util.UrlUtilities#isInternalScheme() .
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: UrlBar.java From 365browser with Apache License 2.0 | 6 votes |
/** * Emphasize components of the URL for readability. */ public void emphasizeUrl() { Editable url = getText(); if (OmniboxUrlEmphasizer.hasEmphasisSpans(url) || hasFocus()) { return; } if (url.length() < 1) { return; } Tab currentTab = mUrlBarDelegate.getCurrentTab(); if (currentTab == null || currentTab.getProfile() == null) return; boolean isInternalPage = false; try { String tabUrl = currentTab.getUrl(); isInternalPage = UrlUtilities.isInternalScheme(new URI(tabUrl)); } catch (URISyntaxException e) { // Ignore as this only is for applying color } OmniboxUrlEmphasizer.emphasizeUrl(url, getResources(), currentTab.getProfile(), currentTab.getSecurityLevel(), isInternalPage, mUseDarkColors, mUrlBarDelegate.shouldEmphasizeHttpsScheme()); }
Example 2
Source File: UrlBar.java From delion with Apache License 2.0 | 5 votes |
/** * Emphasize the TLD and second domain of the URL. */ public void emphasizeUrl() { Editable url = getText(); if (OmniboxUrlEmphasizer.hasEmphasisSpans(url) || hasFocus()) { return; } if (url.length() < 1) { return; } // We retrieve the domain and registry from the full URL (the url bar shows a simplified // version of the URL). Tab currentTab = mUrlBarDelegate.getCurrentTab(); if (currentTab == null || currentTab.getProfile() == null) return; boolean isInternalPage = false; try { String tabUrl = currentTab.getUrl(); isInternalPage = UrlUtilities.isInternalScheme(new URI(tabUrl)); } catch (URISyntaxException e) { // Ignore as this only is for applying color } OmniboxUrlEmphasizer.emphasizeUrl(url, getResources(), currentTab.getProfile(), currentTab.getSecurityLevel(), isInternalPage, mUseDarkColors, mUrlBarDelegate.shouldEmphasizeHttpsScheme()); }
Example 3
Source File: TabContextMenuItemDelegate.java From delion with Apache License 2.0 | 5 votes |
@Override public void onOpenInChrome(String linkUrl, String pageUrl) { Intent chromeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)); chromeIntent.setPackage(mTab.getApplicationContext().getPackageName()); chromeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); boolean activityStarted = false; if (pageUrl != null) { try { URI pageUri = URI.create(pageUrl); if (UrlUtilities.isInternalScheme(pageUri)) { IntentHandler.startChromeLauncherActivityForTrustedIntent( chromeIntent, mTab.getApplicationContext()); activityStarted = true; } } catch (IllegalArgumentException ex) { // Ignore the exception for creating the URI and launch the intent // without the trusted intent extras. } } if (!activityStarted) { Context context = mTab.getActivity(); if (context == null) context = mTab.getApplicationContext(); context.startActivity(chromeIntent); activityStarted = true; } }
Example 4
Source File: ChromeLauncherActivity.java From delion 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 reroute Chrome Intents. Context context = ContextUtils.getApplicationContext(); if (TextUtils.equals(context.getPackageName(), IntentUtils.safeGetStringExtra(intent, Browser.EXTRA_APPLICATION_ID))) { 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; } return true; }
Example 5
Source File: UrlBar.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Emphasize the TLD and second domain of the URL. */ public void emphasizeUrl() { Editable url = getText(); if (OmniboxUrlEmphasizer.hasEmphasisSpans(url) || hasFocus()) { return; } if (url.length() < 1) { return; } // We retrieve the domain and registry from the full URL (the url bar shows a simplified // version of the URL). Tab currentTab = mUrlBarDelegate.getCurrentTab(); if (currentTab == null || currentTab.getProfile() == null) return; boolean isInternalPage = false; try { String tabUrl = currentTab.getUrl(); isInternalPage = UrlUtilities.isInternalScheme(new URI(tabUrl)); } catch (URISyntaxException e) { // Ignore as this only is for applying color } OmniboxUrlEmphasizer.emphasizeUrl(url, getResources(), currentTab.getProfile(), currentTab.getSecurityLevel(), isInternalPage, mUseDarkColors, mUrlBarDelegate.shouldEmphasizeHttpsScheme()); }
Example 6
Source File: TabContextMenuItemDelegate.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onOpenInChrome(String linkUrl, String pageUrl) { Intent chromeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)); chromeIntent.setPackage(mTab.getApplicationContext().getPackageName()); chromeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); boolean activityStarted = false; if (pageUrl != null) { try { URI pageUri = URI.create(pageUrl); if (UrlUtilities.isInternalScheme(pageUri)) { IntentHandler.startChromeLauncherActivityForTrustedIntent( chromeIntent, mTab.getApplicationContext()); activityStarted = true; } } catch (IllegalArgumentException ex) { // Ignore the exception for creating the URI and launch the intent // without the trusted intent extras. } } if (!activityStarted) { Context context = mTab.getActivity(); if (context == null) context = mTab.getApplicationContext(); context.startActivity(chromeIntent); activityStarted = true; } }
Example 7
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 8
Source File: TabContextMenuItemDelegate.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onOpenInChrome(String linkUrl, String pageUrl) { Intent chromeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)); chromeIntent.setPackage(mTab.getApplicationContext().getPackageName()); chromeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); boolean activityStarted = false; if (pageUrl != null) { try { URI pageUri = URI.create(pageUrl); if (UrlUtilities.isInternalScheme(pageUri)) { IntentHandler.startChromeLauncherActivityForTrustedIntent(chromeIntent); activityStarted = true; } } catch (IllegalArgumentException ex) { // Ignore the exception for creating the URI and launch the intent // without the trusted intent extras. } } if (!activityStarted) { Context context = mTab.getActivity(); if (context == null) context = mTab.getApplicationContext(); context.startActivity(chromeIntent); activityStarted = true; } }
Example 9
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; }