Java Code Examples for org.chromium.chrome.browser.favicon.FaviconHelper#getLocalFaviconImageForURL()

The following examples show how to use org.chromium.chrome.browser.favicon.FaviconHelper#getLocalFaviconImageForURL() . 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: PaymentRequestImpl.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Builds the PaymentRequest service implementation.
 *
 * @param webContents The web contents that have invoked the PaymentRequest API.
 */
public PaymentRequestImpl(WebContents webContents) {
    if (webContents == null) return;

    ContentViewCore contentViewCore = ContentViewCore.fromWebContents(webContents);
    if (contentViewCore == null) return;

    WindowAndroid window = contentViewCore.getWindowAndroid();
    if (window == null) return;

    mContext = window.getActivity().get();
    if (mContext == null) return;

    mMerchantName = webContents.getTitle();
    // The feature is available only in secure context, so it's OK to not show HTTPS.
    mOrigin = UrlUtilities.formatUrlForSecurityDisplay(webContents.getVisibleUrl(), false);

    final FaviconHelper faviconHelper = new FaviconHelper();
    float scale = mContext.getResources().getDisplayMetrics().density;
    faviconHelper.getLocalFaviconImageForURL(Profile.getLastUsedProfile(),
            webContents.getVisibleUrl(), (int) (FAVICON_SIZE_DP * scale + 0.5f),
            new FaviconHelper.FaviconImageCallback() {
                @Override
                public void onFaviconAvailable(Bitmap bitmap, String iconUrl) {
                    faviconHelper.destroy();
                    if (bitmap == null) return;
                    if (mUI == null) {
                        mFavicon = bitmap;
                        return;
                    }
                    mUI.setTitleBitmap(bitmap);
                }
            });

    mApps = PaymentAppFactory.create(webContents);
}
 
Example 2
Source File: WebsitePreference.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    TextView usageText = (TextView) view.findViewById(R.id.usage_text);
    usageText.setVisibility(View.GONE);
    if (mCategory.showStorageSites()) {
        long totalUsage = mSite.getTotalUsage();
        if (totalUsage > 0) {
            usageText.setText(Formatter.formatShortFileSize(getContext(), totalUsage));
            usageText.setTextSize(TEXT_SIZE_SP);
            usageText.setVisibility(View.VISIBLE);
        }
    }

    if (!mFaviconFetched) {
        // Start the favicon fetching. Will respond in onFaviconAvailable.
        mFaviconHelper = new FaviconHelper();
        if (!mFaviconHelper.getLocalFaviconImageForURL(
                    Profile.getLastUsedProfile(), faviconUrl(), mFaviconSizePx, this)) {
            onFaviconAvailable(null, null);
        }
        mFaviconFetched = true;
    }

    float density = getContext().getResources().getDisplayMetrics().density;
    int iconPadding = Math.round(FAVICON_PADDING_DP * density);
    View iconView = view.findViewById(android.R.id.icon);
    iconView.setPadding(iconPadding, iconPadding, iconPadding, iconPadding);
}
 
Example 3
Source File: WebsitePreference.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    TextView usageText = (TextView) view.findViewById(R.id.usage_text);
    usageText.setVisibility(View.GONE);
    if (mCategory.showStorageSites()) {
        long totalUsage = mSite.getTotalUsage();
        if (totalUsage > 0) {
            usageText.setText(Formatter.formatShortFileSize(getContext(), totalUsage));
            usageText.setTextSize(TEXT_SIZE_SP);
            usageText.setVisibility(View.VISIBLE);
        }
    }

    if (!mFaviconFetched) {
        // Start the favicon fetching. Will respond in onFaviconAvailable.
        mFaviconHelper = new FaviconHelper();
        if (!mFaviconHelper.getLocalFaviconImageForURL(
                    Profile.getLastUsedProfile(), faviconUrl(), mFaviconSizePx, this)) {
            onFaviconAvailable(null, null);
        }
        mFaviconFetched = true;
    }

    float density = getContext().getResources().getDisplayMetrics().density;
    int iconPadding = Math.round(FAVICON_PADDING_DP * density);
    View iconView = view.findViewById(android.R.id.icon);
    iconView.setPadding(iconPadding, iconPadding, iconPadding, iconPadding);
}
 
Example 4
Source File: WebsitePreference.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    TextView usageText = (TextView) view.findViewById(R.id.usage_text);
    usageText.setVisibility(View.GONE);
    if (mCategory.showStorageSites()) {
        long totalUsage = mSite.getTotalUsage();
        if (totalUsage > 0) {
            usageText.setText(Formatter.formatShortFileSize(getContext(), totalUsage));
            usageText.setTextSize(TEXT_SIZE_SP);
            usageText.setVisibility(View.VISIBLE);
        }
    }

    if (!mFaviconFetched) {
        // Start the favicon fetching. Will respond in onFaviconAvailable.
        mFaviconHelper = new FaviconHelper();
        if (!mFaviconHelper.getLocalFaviconImageForURL(
                    Profile.getLastUsedProfile(), faviconUrl(), mFaviconSizePx, this)) {
            onFaviconAvailable(null, null);
        }
        mFaviconFetched = true;
    }

    float density = getContext().getResources().getDisplayMetrics().density;
    int iconPadding = Math.round(FAVICON_PADDING_DP * density);
    View iconView = view.findViewById(android.R.id.icon);
    iconView.setPadding(iconPadding, iconPadding, iconPadding, iconPadding);
}