2013-11-21 23:33:28 -08:00
|
|
|
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
2013-12-17 22:43:31 -08:00
|
|
|
import org.mozilla.gecko.util.StringUtils;
|
2013-12-17 22:43:31 -08:00
|
|
|
|
2013-11-21 23:33:28 -08:00
|
|
|
public class AboutPages {
|
|
|
|
// All of our special pages.
|
|
|
|
public static final String ADDONS = "about:addons";
|
|
|
|
public static final String APPS = "about:apps";
|
|
|
|
public static final String CONFIG = "about:config";
|
|
|
|
public static final String DOWNLOADS = "about:downloads";
|
|
|
|
public static final String FIREFOX = "about:firefox";
|
|
|
|
public static final String HEALTHREPORT = "about:healthreport";
|
|
|
|
public static final String HOME = "about:home";
|
|
|
|
public static final String PRIVATEBROWSING = "about:privatebrowsing";
|
|
|
|
public static final String READER = "about:reader";
|
|
|
|
public static final String UPDATER = "about:";
|
|
|
|
|
|
|
|
public static final String URL_FILTER = "about:%";
|
|
|
|
|
2014-01-17 10:41:15 -08:00
|
|
|
public static final String PANEL_PARAM = "panel";
|
|
|
|
|
2013-11-21 23:33:28 -08:00
|
|
|
public static final boolean isAboutPage(final String url) {
|
2014-03-19 05:47:45 -07:00
|
|
|
return url != null && url.startsWith("about:");
|
2013-11-21 23:33:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final boolean isTitlelessAboutPage(final String url) {
|
2013-12-17 22:43:31 -08:00
|
|
|
return isAboutHome(url) ||
|
2013-11-21 23:33:28 -08:00
|
|
|
PRIVATEBROWSING.equals(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final boolean isAboutHome(final String url) {
|
2013-12-17 22:43:31 -08:00
|
|
|
if (url == null || !url.startsWith(HOME)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// We sometimes append a parameter to "about:home" to specify which page to
|
|
|
|
// show when we open the home pager. Discard this parameter when checking
|
|
|
|
// whether or not this URL is "about:home".
|
|
|
|
return HOME.equals(url.split("\\?")[0]);
|
|
|
|
}
|
|
|
|
|
2014-01-17 10:41:15 -08:00
|
|
|
public static final String getPanelIdFromAboutHomeUrl(String aboutHomeUrl) {
|
|
|
|
return StringUtils.getQueryParameter(aboutHomeUrl, PANEL_PARAM);
|
2013-11-21 23:33:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final boolean isAboutReader(final String url) {
|
|
|
|
if (url == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return url.startsWith(READER);
|
|
|
|
}
|
2013-11-26 19:48:30 -08:00
|
|
|
|
|
|
|
private static final String[] DEFAULT_ICON_PAGES = new String[] {
|
|
|
|
ADDONS,
|
|
|
|
CONFIG,
|
|
|
|
DOWNLOADS,
|
|
|
|
FIREFOX,
|
|
|
|
HEALTHREPORT,
|
|
|
|
UPDATER
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callers must not modify the returned array.
|
|
|
|
*/
|
|
|
|
public static String[] getDefaultIconPages() {
|
|
|
|
return DEFAULT_ICON_PAGES;
|
|
|
|
}
|
|
|
|
|
2014-08-18 02:40:09 -07:00
|
|
|
public static boolean isBuiltinIconPage(final String url) {
|
2013-11-26 19:48:30 -08:00
|
|
|
if (url == null ||
|
|
|
|
!url.startsWith("about:")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-18 02:40:09 -07:00
|
|
|
// about:home uses a separate search built-in icon.
|
|
|
|
if (isAboutHome(url)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-26 19:48:30 -08:00
|
|
|
// TODO: it'd be quicker to not compare the "about:" part every time.
|
|
|
|
for (int i = 0; i < DEFAULT_ICON_PAGES.length; ++i) {
|
|
|
|
if (DEFAULT_ICON_PAGES[i].equals(url)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-11-21 23:33:28 -08:00
|
|
|
}
|
|
|
|
|