mobile/android/base/AboutPages.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 package org.mozilla.gecko;
michael@0 7
michael@0 8 import org.mozilla.gecko.util.StringUtils;
michael@0 9
michael@0 10 public class AboutPages {
michael@0 11 // All of our special pages.
michael@0 12 public static final String ADDONS = "about:addons";
michael@0 13 public static final String APPS = "about:apps";
michael@0 14 public static final String CONFIG = "about:config";
michael@0 15 public static final String DOWNLOADS = "about:downloads";
michael@0 16 public static final String FIREFOX = "about:firefox";
michael@0 17 public static final String HEALTHREPORT = "about:healthreport";
michael@0 18 public static final String HOME = "about:home";
michael@0 19 public static final String PRIVATEBROWSING = "about:privatebrowsing";
michael@0 20 public static final String READER = "about:reader";
michael@0 21 public static final String UPDATER = "about:";
michael@0 22
michael@0 23 public static final String URL_FILTER = "about:%";
michael@0 24
michael@0 25 public static final String PANEL_PARAM = "panel";
michael@0 26
michael@0 27 public static final boolean isAboutPage(final String url) {
michael@0 28 return url != null && url.startsWith("about:");
michael@0 29 }
michael@0 30
michael@0 31 public static final boolean isTitlelessAboutPage(final String url) {
michael@0 32 return isAboutHome(url) ||
michael@0 33 PRIVATEBROWSING.equals(url);
michael@0 34 }
michael@0 35
michael@0 36 public static final boolean isAboutHome(final String url) {
michael@0 37 if (url == null || !url.startsWith(HOME)) {
michael@0 38 return false;
michael@0 39 }
michael@0 40 // We sometimes append a parameter to "about:home" to specify which page to
michael@0 41 // show when we open the home pager. Discard this parameter when checking
michael@0 42 // whether or not this URL is "about:home".
michael@0 43 return HOME.equals(url.split("\\?")[0]);
michael@0 44 }
michael@0 45
michael@0 46 public static final String getPanelIdFromAboutHomeUrl(String aboutHomeUrl) {
michael@0 47 return StringUtils.getQueryParameter(aboutHomeUrl, PANEL_PARAM);
michael@0 48 }
michael@0 49
michael@0 50 public static final boolean isAboutReader(final String url) {
michael@0 51 if (url == null) {
michael@0 52 return false;
michael@0 53 }
michael@0 54 return url.startsWith(READER);
michael@0 55 }
michael@0 56
michael@0 57 private static final String[] DEFAULT_ICON_PAGES = new String[] {
michael@0 58 HOME,
michael@0 59
michael@0 60 ADDONS,
michael@0 61 CONFIG,
michael@0 62 DOWNLOADS,
michael@0 63 FIREFOX,
michael@0 64 HEALTHREPORT,
michael@0 65 UPDATER
michael@0 66 };
michael@0 67
michael@0 68 /**
michael@0 69 * Callers must not modify the returned array.
michael@0 70 */
michael@0 71 public static String[] getDefaultIconPages() {
michael@0 72 return DEFAULT_ICON_PAGES;
michael@0 73 }
michael@0 74
michael@0 75 public static boolean isDefaultIconPage(final String url) {
michael@0 76 if (url == null ||
michael@0 77 !url.startsWith("about:")) {
michael@0 78 return false;
michael@0 79 }
michael@0 80
michael@0 81 // TODO: it'd be quicker to not compare the "about:" part every time.
michael@0 82 for (int i = 0; i < DEFAULT_ICON_PAGES.length; ++i) {
michael@0 83 if (DEFAULT_ICON_PAGES[i].equals(url)) {
michael@0 84 return true;
michael@0 85 }
michael@0 86 }
michael@0 87 return false;
michael@0 88 }
michael@0 89 }
michael@0 90

mercurial