Bug 1325488 - Deduplicate subdomain removal in IconGenerator. r=ahunt

This commit is contained in:
Brian Chen 2016-12-23 17:35:00 -05:00
Родитель acb94fc181
Коммит 348fb50602
1 изменённых файлов: 3 добавлений и 14 удалений

Просмотреть файл

@ -21,6 +21,7 @@ import android.util.TypedValue;
import org.mozilla.gecko.R;
import org.mozilla.gecko.icons.IconRequest;
import org.mozilla.gecko.icons.IconResponse;
import org.mozilla.gecko.util.StringUtils;
/**
* This loader will generate an icon in case no icon could be loaded. In order to do so this needs
@ -43,14 +44,6 @@ public class IconGenerator implements IconLoader {
0xFFea385e,
};
// List of common prefixes of host names. Those prefixes will be striped before a prepresentative
// character for an URL is determined.
private static final String[] COMMON_PREFIXES = {
"www.",
"m.",
"mobile.",
};
private static final int TEXT_SIZE_DP = 12;
@Override
public IconResponse load(IconRequest request) {
@ -156,12 +149,8 @@ public class IconGenerator implements IconLoader {
return "?";
}
// Strip common prefixes that we do not want to use to determine the representative character
for (String prefix : COMMON_PREFIXES) {
if (snippet.startsWith(prefix)) {
snippet = snippet.substring(prefix.length());
}
}
// Strip common prefixes that we do not want to use to determine the representative characterS
snippet = StringUtils.stripCommonSubdomains(snippet);
return snippet;
}