org.chromium.chrome.browser.UrlConstants Java Examples
The following examples show how to use
org.chromium.chrome.browser.UrlConstants.
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: SearchEngineAdapter.java From 365browser with Apache License 2.0 | 6 votes |
private boolean locationShouldBeShown(TemplateUrl templateUrl) { String url = getSearchEngineUrl(templateUrl); if (url.isEmpty()) return false; // Do not show location if the scheme isn't HTTPS. Uri uri = Uri.parse(url); if (!UrlConstants.HTTPS_SCHEME.equals(uri.getScheme())) return false; // Only show the location setting if it is explicitly enabled or disabled. GeolocationInfo locationSettings = new GeolocationInfo(url, null, false); ContentSetting locationPermission = locationSettings.getContentSetting(); if (locationPermission != ContentSetting.ASK) return true; if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONSISTENT_OMNIBOX_GEOLOCATION)) { return WebsitePreferenceBridge.shouldUseDSEGeolocationSetting(url, false); } return GeolocationHeader.isGeoHeaderEnabledForUrl(url, false); }
Example #2
Source File: PaymentRequestHeader.java From 365browser with Apache License 2.0 | 6 votes |
/** * Sets the title and origin on the header. * * @param title The title to display on the header. * @param origin The origin to display on the header. * @param securityLevel The security level of the page that invoked PaymentRequest. */ public void setTitleAndOrigin(String title, String origin, int securityLevel) { ((TextView) findViewById(R.id.page_title)).setText(title); TextView hostName = (TextView) findViewById(R.id.hostname); Spannable url = new SpannableStringBuilder(origin); OmniboxUrlEmphasizer.emphasizeUrl(url, mContext.getResources(), Profile.getLastUsedProfile(), securityLevel, false /* isInternalPage */, true /* useDarkColors */, true /* emphasizeHttpsScheme */); hostName.setText(url); if (origin.startsWith(UrlConstants.HTTPS_URL_PREFIX)) { // Add a lock icon. ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(hostName, TintedDrawable.constructTintedDrawable(mContext.getResources(), R.drawable.omnibox_https_valid, R.color.google_green_700), null, null, null); // Remove left padding to align left compound drawable with the title. Note that the // left compound drawable has transparent boundary. hostName.setPaddingRelative(0, 0, 0, 0); } }
Example #3
Source File: BookmarkUIState.java From 365browser with Apache License 2.0 | 6 votes |
/** * @return A state corresponding to the URI object. If the URI is not valid, * return all_bookmarks. */ static BookmarkUIState createStateFromUrl(Uri uri, BookmarkModel bookmarkModel) { BookmarkUIState state = new BookmarkUIState(); state.mState = STATE_INVALID; state.mUrl = uri.toString(); if (state.mUrl.equals(UrlConstants.BOOKMARKS_URL)) { return createFolderState(bookmarkModel.getDefaultFolder(), bookmarkModel); } else if (state.mUrl.startsWith(UrlConstants.BOOKMARKS_FOLDER_URL)) { String path = uri.getLastPathSegment(); if (!path.isEmpty()) { state.mFolder = BookmarkId.getBookmarkIdFromString(path); state.mState = STATE_FOLDER; } } if (!state.isValid(bookmarkModel)) { state = createFolderState(bookmarkModel.getDefaultFolder(), bookmarkModel); } return state; }
Example #4
Source File: HelpAndFeedback.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Get help context ID from URL. * * @param url The URL to be checked. * @param isIncognito Whether we are in incognito mode or not. * @return Help context ID that matches the URL and incognito mode. */ public static String getHelpContextIdFromUrl(Context context, String url, boolean isIncognito) { if (TextUtils.isEmpty(url)) { return context.getString(R.string.help_context_general); } else if (url.startsWith(UrlConstants.BOOKMARKS_URL)) { return context.getString(R.string.help_context_bookmarks); } else if (url.equals(UrlConstants.HISTORY_URL)) { return context.getString(R.string.help_context_history); // Note: For www.google.com the following function returns false. } else if (UrlUtilities.nativeIsGoogleSearchUrl(url)) { return context.getString(R.string.help_context_search_results); // For incognito NTP, we want to show incognito help. } else if (isIncognito) { return context.getString(R.string.help_context_incognito); } else if (url.equals(UrlConstants.NTP_URL)) { return context.getString(R.string.help_context_new_tab); } return context.getString(R.string.help_context_webpage); }
Example #5
Source File: ActivityDelegate.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Check whether or not the Intent contains an ID for document mode. * @param intent Intent to check. * @return ID for the document that has the given intent as base intent, or * {@link Tab.INVALID_TAB_ID} if it couldn't be retrieved. */ public static int getTabIdFromIntent(Intent intent) { if (intent == null || intent.getData() == null) return Tab.INVALID_TAB_ID; // Avoid AsyncTabCreationParams related flows early returning here. if (AsyncTabParamsManager.hasParamsWithTabToReparent()) { return IntentUtils.safeGetIntExtra( intent, IntentHandler.EXTRA_TAB_ID, Tab.INVALID_TAB_ID); } Uri data = intent.getData(); if (!TextUtils.equals(data.getScheme(), UrlConstants.DOCUMENT_SCHEME)) { return Tab.INVALID_TAB_ID; } try { return Integer.parseInt(data.getHost()); } catch (NumberFormatException e) { return Tab.INVALID_TAB_ID; } }
Example #6
Source File: RoundedIconGenerator.java From delion with Apache License 2.0 | 6 votes |
/** * Returns the text which should be used for generating a rounded icon based on |url|. * * @param url URL to consider when getting the icon's text. * @param includePrivateRegistries Should private registries be considered as TLDs? * @return The text to use on the rounded icon, or NULL if |url| is empty or the domain cannot * be resolved. */ @Nullable @VisibleForTesting public static String getIconTextForUrl(String url, boolean includePrivateRegistries) { String domain = UrlUtilities.getDomainAndRegistry(url, includePrivateRegistries); if (!TextUtils.isEmpty(domain)) return domain; // Special-case chrome:// and chrome-native:// URLs. if (url.startsWith(UrlConstants.CHROME_SCHEME) || url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME)) { return "chrome"; } // Use the host component of |url| when it can be parsed as a URI. try { URI uri = new URI(url); if (!TextUtils.isEmpty(uri.getHost())) { return uri.getHost(); } } catch (Exception e) { Log.w(TAG, "Unable to parse the URL for generating an icon: " + url); } return url; }
Example #7
Source File: ChromeFileProvider.java From 365browser with Apache License 2.0 | 6 votes |
/** * Returns an unique uri to identify the file to be shared and block access to it till * notifyFileReady is called. * * This function clobbers any uri that was previously created and the client application * accessing those uri will get a null file descriptor. * @param context Activity context that is used to access package manager. */ public static Uri generateUriAndBlockAccess(final Context context) { String authority = context.getPackageName() + AUTHORITY_SUFFIX; String fileName = BLOCKED_FILE_PREFIX + String.valueOf(System.nanoTime()); Uri blockingUri = new Uri.Builder() .scheme(UrlConstants.CONTENT_SCHEME) .authority(authority) .path(fileName) .build(); synchronized (sLock) { sCurrentBlockingUri = blockingUri; sFileUri = null; sIsFileReady = false; // In case the previous file never got ready. sLock.notify(); } return blockingUri; }
Example #8
Source File: LayoutManagerDocument.java From delion with Apache License 2.0 | 6 votes |
@Override public void initLayoutTabFromHost(final int tabId) { if (getTabModelSelector() == null || getActiveLayout() == null) return; TabModelSelector selector = getTabModelSelector(); Tab tab = selector.getTabById(tabId); if (tab == null) return; LayoutTab layoutTab = mTabCache.get(tabId); if (layoutTab == null) return; String url = tab.getUrl(); boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME); int themeColor = tab.getThemeColor(); boolean canUseLiveTexture = tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage; layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(), canUseLiveTexture, themeColor, ColorUtils.getTextBoxColorForToolbarBackground( mContext.getResources(), tab, themeColor), ColorUtils.getTextBoxAlphaForToolbarBackground(tab)); mHost.requestRender(); }
Example #9
Source File: RoundedIconGenerator.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Returns the text which should be used for generating a rounded icon based on |url|. * * @param url URL to consider when getting the icon's text. * @param includePrivateRegistries Should private registries be considered as TLDs? * @return The text to use on the rounded icon, or NULL if |url| is empty or the domain cannot * be resolved. */ @Nullable @VisibleForTesting public static String getIconTextForUrl(String url, boolean includePrivateRegistries) { String domain = UrlUtilities.getDomainAndRegistry(url, includePrivateRegistries); if (!TextUtils.isEmpty(domain)) return domain; // Special-case chrome:// and chrome-native:// URLs. if (url.startsWith(UrlConstants.CHROME_SCHEME) || url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME)) { return "chrome"; } // Use the host component of |url| when it can be parsed as a URI. try { URI uri = new URI(url); if (!TextUtils.isEmpty(uri.getHost())) { return uri.getHost(); } } catch (Exception e) { Log.w(TAG, "Unable to parse the URL for generating an icon: " + url); } return url; }
Example #10
Source File: DownloadUtils.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Whether the user should be allowed to download the current page. * @param tab Tab displaying the page that will be downloaded. * @return Whether the "Download Page" button should be enabled. */ public static boolean isAllowedToDownloadPage(Tab tab) { if (tab == null) return false; // Only allow HTTP and HTTPS pages, as that is these are the only scenarios supported by the // background/offline page saving. if (!tab.getUrl().startsWith(UrlConstants.HTTP_SCHEME) && !tab.getUrl().startsWith(UrlConstants.HTTPS_SCHEME)) { return false; } if (tab.isShowingErrorPage()) return false; if (tab.isShowingInterstitialPage()) return false; // Don't allow re-downloading the currently displayed offline page. if (tab.isOfflinePage()) return false; // Offline pages isn't supported in Incognito. if (tab.isIncognito()) return false; return true; }
Example #11
Source File: CustomTabToolbar.java From delion with Apache License 2.0 | 6 votes |
@Override public void setTitleToPageTitle() { Tab currentTab = getToolbarDataProvider().getTab(); if (currentTab == null || TextUtils.isEmpty(currentTab.getTitle())) { mTitleBar.setText(""); return; } String title = currentTab.getTitle(); // It takes some time to parse the title of the webcontent, and before that Tab#getTitle // always return the url. We postpone the title animation until the title is authentic. if ((mState == STATE_DOMAIN_AND_TITLE || mState == STATE_TITLE_ONLY) && !title.equals(currentTab.getUrl()) && !title.equals(UrlConstants.ABOUT_BLANK)) { // Delay the title animation until security icon animation finishes. ThreadUtils.postOnUiThreadDelayed(mTitleAnimationStarter, TITLE_ANIM_DELAY_MS); } mTitleBar.setText(title); }
Example #12
Source File: CustomTabActivity.java From 365browser with Apache License 2.0 | 6 votes |
/** * @return The URL that should be used from this intent. If it is a WebLite url, it may be * overridden if the Data Reduction Proxy is using Lo-Fi previews. */ private String getUrlToLoad() { String url = IntentHandler.getUrlFromIntent(getIntent()); // Intents fired for media viewers have an additional file:// URI passed along so that the // tab can display the actual filename to the user when it is loaded. if (mIntentDataProvider.isMediaViewer()) { String mediaViewerUrl = mIntentDataProvider.getMediaViewerUrl(); if (!TextUtils.isEmpty(mediaViewerUrl)) { Uri mediaViewerUri = Uri.parse(mediaViewerUrl); if (UrlConstants.FILE_SCHEME.equals(mediaViewerUri.getScheme())) { url = mediaViewerUrl; } } } if (!TextUtils.isEmpty(url)) { url = DataReductionProxySettings.getInstance().maybeRewriteWebliteUrl(url); } return url; }
Example #13
Source File: ActivityDelegate.java From 365browser with Apache License 2.0 | 6 votes |
/** * Check whether or not the Intent contains an ID for document mode. * @param intent Intent to check. * @return ID for the document that has the given intent as base intent, or * {@link Tab.INVALID_TAB_ID} if it couldn't be retrieved. */ public static int getTabIdFromIntent(Intent intent) { if (intent == null || intent.getData() == null) return Tab.INVALID_TAB_ID; // Avoid AsyncTabCreationParams related flows early returning here. if (AsyncTabParamsManager.hasParamsWithTabToReparent()) { return IntentUtils.safeGetIntExtra( intent, IntentHandler.EXTRA_TAB_ID, Tab.INVALID_TAB_ID); } Uri data = intent.getData(); if (!TextUtils.equals(data.getScheme(), UrlConstants.DOCUMENT_SCHEME)) { return Tab.INVALID_TAB_ID; } try { return Integer.parseInt(data.getHost()); } catch (NumberFormatException e) { return Tab.INVALID_TAB_ID; } }
Example #14
Source File: ToolbarManager.java From delion with Apache License 2.0 | 5 votes |
@Override public void openHomepage() { Tab currentTab = mToolbarModel.getTab(); if (currentTab == null) return; Context context = mToolbar.getContext(); String homePageUrl = HomepageManager.getHomepageUri(context); if (TextUtils.isEmpty(homePageUrl)) { homePageUrl = UrlConstants.NTP_URL; } currentTab.loadUrl(new LoadUrlParams(homePageUrl, PageTransition.HOME_PAGE)); }
Example #15
Source File: GoogleActivityController.java From delion with Apache License 2.0 | 5 votes |
/** * Opens the "Web & App Activity" settings that allows the user to control how Google uses Chrome * browsing history. * @param activity The activity to open the settings. * @param accountName The account for which is requested. */ public void openWebAndAppActivitySettings(Activity activity, String accountName) { Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse(UrlConstants.GOOGLE_ACCOUNT_ACTIVITY_CONTROLS_URL)); intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName()); intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); intent.setPackage(activity.getPackageName()); activity.startActivity(intent); }
Example #16
Source File: ToolbarManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void openHomepage() { RecordUserAction.record("Home"); Tab currentTab = mToolbarModel.getTab(); if (currentTab == null) return; Context context = mToolbar.getContext(); String homePageUrl = HomepageManager.getHomepageUri(context); if (TextUtils.isEmpty(homePageUrl)) { homePageUrl = UrlConstants.NTP_URL; } currentTab.loadUrl(new LoadUrlParams(homePageUrl, PageTransition.HOME_PAGE)); }
Example #17
Source File: GoogleActivityController.java From 365browser with Apache License 2.0 | 5 votes |
/** * Opens the "Web & App Activity" settings that allows the user to control how Google uses Chrome * browsing history. * @param activity The activity to open the settings. * @param accountName The account for which is requested. */ public void openWebAndAppActivitySettings(Activity activity, String accountName) { Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse(UrlConstants.GOOGLE_ACCOUNT_ACTIVITY_CONTROLS_URL)); intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName()); intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); intent.setPackage(activity.getPackageName()); activity.startActivity(intent); }
Example #18
Source File: TabStateBrowserControlsVisibilityDelegate.java From 365browser with Apache License 2.0 | 5 votes |
@Override public boolean isHidingBrowserControlsEnabled() { WebContents webContents = mTab.getWebContents(); if (webContents == null || webContents.isDestroyed()) return false; String url = mTab.getUrl(); boolean enableHidingBrowserControls = url != null; enableHidingBrowserControls &= !url.startsWith(UrlConstants.CHROME_URL_PREFIX); enableHidingBrowserControls &= !url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX); int securityState = mTab.getSecurityLevel(); enableHidingBrowserControls &= (securityState != ConnectionSecurityLevel.DANGEROUS && securityState != ConnectionSecurityLevel.SECURITY_WARNING); enableHidingBrowserControls &= !AccessibilityUtil.isAccessibilityEnabled(); ContentViewCore cvc = mTab.getContentViewCore(); enableHidingBrowserControls &= cvc == null || !cvc.isFocusedNodeEditable(); enableHidingBrowserControls &= !mTab.isShowingErrorPage(); enableHidingBrowserControls &= !webContents.isShowingInterstitialPage(); enableHidingBrowserControls &= !mTab.isRendererUnresponsive(); enableHidingBrowserControls &= (mTab.getFullscreenManager() != null); enableHidingBrowserControls &= DeviceClassManager.enableFullscreen(); enableHidingBrowserControls &= !mIsFullscreenWaitingForLoad; return enableHidingBrowserControls; }
Example #19
Source File: ChromeBrowserProvider.java From 365browser with Apache License 2.0 | 5 votes |
private Cursor getBookmarkHistorySuggestions(String selection, String[] selectionArgs, String sortOrder, boolean excludeHistory) { boolean matchTitles = false; Vector<String> args = new Vector<String>(); String like = selectionArgs[0] + "%"; if (selectionArgs[0].startsWith(UrlConstants.HTTP_SCHEME) || selectionArgs[0].startsWith(UrlConstants.FILE_SCHEME)) { args.add(like); } else { // Match against common URL prefixes. args.add(UrlConstants.HTTP_URL_PREFIX + like); args.add(UrlConstants.HTTPS_URL_PREFIX + like); args.add(UrlConstants.HTTP_URL_PREFIX + "www." + like); args.add(UrlConstants.HTTPS_URL_PREFIX + "www." + like); args.add(UrlConstants.FILE_URL_PREFIX + like); matchTitles = true; } StringBuilder urlWhere = new StringBuilder("("); urlWhere.append(buildSuggestWhere(selection, args.size())); if (matchTitles) { args.add(like); urlWhere.append(" OR title LIKE ?"); } urlWhere.append(")"); if (excludeHistory) { urlWhere.append(" AND bookmark=?"); args.add("1"); } selectionArgs = args.toArray(selectionArgs); Cursor cursor = queryBookmarkFromAPI(SUGGEST_PROJECTION, urlWhere.toString(), selectionArgs, sortOrder); return new ChromeBrowserProviderSuggestionsCursor(cursor); }
Example #20
Source File: NativePageFactory.java From 365browser with Apache License 2.0 | 5 votes |
private static NativePageType nativePageType(String url, NativePage candidatePage, boolean isIncognito) { if (url == null) return NativePageType.NONE; Uri uri = Uri.parse(url); if (!UrlConstants.CHROME_NATIVE_SCHEME.equals(uri.getScheme())) { return NativePageType.NONE; } String host = uri.getHost(); if (candidatePage != null && candidatePage.getHost().equals(host)) { return NativePageType.CANDIDATE; } if (UrlConstants.NTP_HOST.equals(host)) { return NativePageType.NTP; } else if (UrlConstants.BOOKMARKS_HOST.equals(host)) { return NativePageType.BOOKMARKS; } else if (UrlConstants.DOWNLOADS_HOST.equals(host)) { return NativePageType.DOWNLOADS; } else if (UrlConstants.HISTORY_HOST.equals(host)) { return NativePageType.HISTORY; } else if (UrlConstants.RECENT_TABS_HOST.equals(host) && !isIncognito) { return NativePageType.RECENT_TABS; } else if (UrlConstants.PHYSICAL_WEB_DIAGNOSTICS_HOST.equals(host)) { if (ChromeFeatureList.isEnabled("PhysicalWeb")) { return NativePageType.PHYSICAL_WEB; } else { return NativePageType.NONE; } } else { return NativePageType.NONE; } }
Example #21
Source File: BookmarkActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mBookmarkManager = new BookmarkManager(this, true); String url = getIntent().getDataString(); if (TextUtils.isEmpty(url)) url = UrlConstants.BOOKMARKS_URL; mBookmarkManager.updateForUrl(url); setContentView(mBookmarkManager.getView()); // Hack to work around inferred theme false lint error: http://crbug.com/445633 assert (R.layout.bookmark_main_content != 0); }
Example #22
Source File: LayoutManagerDocument.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void initLayoutTabFromHost(final int tabId) { if (getTabModelSelector() == null || getActiveLayout() == null) return; TabModelSelector selector = getTabModelSelector(); Tab tab = selector.getTabById(tabId); if (tab == null) return; LayoutTab layoutTab = mTabCache.get(tabId); if (layoutTab == null) return; String url = tab.getUrl(); boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME); int themeColor = tab.getThemeColor(); // TODO(xingliu): Remove this override themeColor for Blimp tabs. See crbug.com/644774. if (tab.isBlimpTab() && tab.getBlimpContents() != null) { themeColor = tab.getBlimpContents().getThemeColor(); } boolean canUseLiveTexture = tab.isBlimpTab() || tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage; boolean needsUpdate = layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(), canUseLiveTexture, themeColor, ColorUtils.getTextBoxColorForToolbarBackground( mContext.getResources(), tab, themeColor), ColorUtils.getTextBoxAlphaForToolbarBackground(tab)); if (needsUpdate) requestUpdate(); mHost.requestRender(); }
Example #23
Source File: TabCreatorManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Creates a new tab and loads the NTP. */ public final void launchNTP() { try { TraceEvent.begin("TabCreator.launchNTP"); launchUrl(UrlConstants.NTP_URL, TabModel.TabLaunchType.FROM_CHROME_UI); } finally { TraceEvent.end("TabCreator.launchNTP"); } }
Example #24
Source File: BeamCallback.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return Whether given URL is valid and sharable via Beam. */ private static boolean isValidUrl(String url) { if (TextUtils.isEmpty(url)) return false; try { String urlProtocol = (new URL(url)).getProtocol(); return (UrlConstants.HTTP_SCHEME.equals(urlProtocol) || UrlConstants.HTTPS_SCHEME.equals(urlProtocol)); } catch (MalformedURLException e) { return false; } }
Example #25
Source File: DownloadFilter.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @return The URL representing the filter. */ public static String getUrlForFilter(int filter) { if (filter == FILTER_ALL) { return UrlConstants.DOWNLOADS_URL; } return UrlConstants.DOWNLOADS_FILTER_URL + filter; }
Example #26
Source File: DownloadFilter.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @return The filter that the given URL represents. */ public static int getFilterFromUrl(String url) { if (TextUtils.isEmpty(url) || UrlConstants.DOWNLOADS_HOST.equals(url)) return FILTER_ALL; int result = FILTER_ALL; if (url.startsWith(UrlConstants.DOWNLOADS_FILTER_URL)) { try { result = Integer .parseInt(url.substring(UrlConstants.DOWNLOADS_FILTER_URL.length())); } catch (NumberFormatException e) { Log.e(TAG, "Url parsing failed."); } } return result; }
Example #27
Source File: DownloadActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean isOffTheRecord = DownloadUtils.shouldShowOffTheRecordDownloads(getIntent()); ComponentName parentComponent = IntentUtils.safeGetParcelableExtra( getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT); mDownloadManagerUi = new DownloadManagerUi(this, isOffTheRecord, parentComponent); setContentView(mDownloadManagerUi.getView()); mIsOffTheRecord = isOffTheRecord; mDownloadManagerUi.addObserver(mUiObserver); // Call updateForUrl() to align with how DownloadPage interacts with DownloadManagerUi. mDownloadManagerUi.updateForUrl(UrlConstants.DOWNLOADS_URL); }
Example #28
Source File: TabStateBrowserControlsVisibilityDelegate.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public boolean isHidingBrowserControlsEnabled() { WebContents webContents = mTab.getWebContents(); if (webContents == null || webContents.isDestroyed()) return false; String url = mTab.getUrl(); boolean enableHidingBrowserControls = url != null; enableHidingBrowserControls &= !url.startsWith(UrlConstants.CHROME_SCHEME); enableHidingBrowserControls &= !url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME); int securityState = mTab.getSecurityLevel(); enableHidingBrowserControls &= (securityState != ConnectionSecurityLevel.DANGEROUS && securityState != ConnectionSecurityLevel.SECURITY_WARNING); enableHidingBrowserControls &= !AccessibilityUtil.isAccessibilityEnabled(mTab.getApplicationContext()); ContentViewCore cvc = mTab.getContentViewCore(); enableHidingBrowserControls &= cvc == null || !cvc.isFocusedNodeEditable(); enableHidingBrowserControls &= !mTab.isShowingErrorPage(); enableHidingBrowserControls &= !webContents.isShowingInterstitialPage(); enableHidingBrowserControls &= !mTab.isRendererUnresponsive(); enableHidingBrowserControls &= (mTab.getFullscreenManager() != null); enableHidingBrowserControls &= DeviceClassManager.enableFullscreen(); enableHidingBrowserControls &= !mIsFullscreenWaitingForLoad; return enableHidingBrowserControls; }
Example #29
Source File: GoogleActivityController.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Opens the "Web & App Activity" settings that allows the user to control how Google uses Chrome * browsing history. * @param activity The activity to open the settings. * @param accountName The account for which is requested. */ public void openWebAndAppActivitySettings(Activity activity, String accountName) { Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse(UrlConstants.GOOGLE_ACCOUNT_ACTIVITY_CONTROLS_URL)); intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName()); intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); intent.setPackage(activity.getPackageName()); activity.startActivity(intent); }
Example #30
Source File: NativePageFactory.java From AndroidChromium with Apache License 2.0 | 5 votes |
private static NativePageType nativePageType(String url, NativePage candidatePage, boolean isIncognito) { if (url == null) return NativePageType.NONE; Uri uri = Uri.parse(url); if (!CHROME_NATIVE_SCHEME.equals(uri.getScheme())) { return NativePageType.NONE; } String host = uri.getHost(); if (candidatePage != null && candidatePage.getHost().equals(host)) { return NativePageType.CANDIDATE; } if (UrlConstants.NTP_HOST.equals(host)) { return NativePageType.NTP; } else if (UrlConstants.BOOKMARKS_HOST.equals(host)) { return NativePageType.BOOKMARKS; } else if (UrlConstants.DOWNLOADS_HOST.equals(host)) { return NativePageType.DOWNLOADS; } else if (UrlConstants.RECENT_TABS_HOST.equals(host) && !isIncognito) { return NativePageType.RECENT_TABS; } else if (UrlConstants.PHYSICAL_WEB_HOST.equals(host)) { if (ChromeFeatureList.isEnabled("PhysicalWeb")) { return NativePageType.PHYSICAL_WEB; } else { return NativePageType.NONE; } } else { return NativePageType.NONE; } }