Bug 1320298 - Change mutable array to unmutable list; r?sebastian draft
authorShan <11812r@gmail.com>
Tue, 13 Dec 2016 14:41:10 +0530
changeset 448939 22ce2802d7937394e6564d0bd7a8629f69831e32
parent 445204 cfdd02175506ef93b6c05beeba28b9228feb0950
child 451376 bf710bc39aee16d67affdb44e512947d27b60f0e
child 451465 bcb104bb63c00a0c7673d416e23ebb72f472b5ab
child 539426 af350b3cfb4ede0c7e7ad1e1a47b6827d237c1c5
push id38490
push userbmo:11812r@gmail.com
push dateTue, 13 Dec 2016 09:13:12 +0000
reviewerssebastian
bugs1320298
milestone53.0a1
Bug 1320298 - Change mutable array to unmutable list; r?sebastian MozReview-Commit-ID: 3HkWfzEeZFw
mobile/android/base/java/org/mozilla/gecko/AboutPages.java
mobile/android/base/java/org/mozilla/gecko/icons/preparation/AboutPagesPreparer.java
--- a/mobile/android/base/java/org/mozilla/gecko/AboutPages.java
+++ b/mobile/android/base/java/org/mozilla/gecko/AboutPages.java
@@ -5,16 +5,20 @@
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.annotation.RobocopTarget;
 import org.mozilla.gecko.home.HomeConfig;
 import org.mozilla.gecko.home.HomeConfig.PanelType;
 import org.mozilla.gecko.util.StringUtils;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 public class AboutPages {
     // All of our special pages.
     public static final String ACCOUNTS        = "about:accounts";
     public static final String ADDONS          = "about:addons";
     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";
@@ -67,41 +71,41 @@ public class AboutPages {
         return isAboutPage(PRIVATEBROWSING, url);
     }
 
     public static boolean isAboutPage(String page, String url) {
         return url != null && url.toLowerCase().startsWith(page);
 
     }
 
-    public static final String[] DEFAULT_ICON_PAGES = new String[] {
-        HOME,
-        ACCOUNTS,
-        ADDONS,
-        CONFIG,
-        DOWNLOADS,
-        FIREFOX,
-        HEALTHREPORT,
-        UPDATER
-    };
+    public static final List<String> DEFAULT_ICON_PAGES = Collections.unmodifiableList(Arrays.asList(
+            HOME,
+            ACCOUNTS,
+            ADDONS,
+            CONFIG,
+            DOWNLOADS,
+            FIREFOX,
+            HEALTHREPORT,
+            UPDATER
+    ));
 
     public static boolean isBuiltinIconPage(final String url) {
         if (url == null ||
             !url.startsWith("about:")) {
             return false;
         }
 
         // about:home uses a separate search built-in icon.
         if (isAboutHome(url)) {
             return true;
         }
 
         // 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)) {
+        for (String page : DEFAULT_ICON_PAGES) {
+            if (page.equals(url)) {
                 return true;
             }
         }
         return false;
     }
 
     /**
      * Get a URL that navigates to the specified built-in Home Panel.
--- a/mobile/android/base/java/org/mozilla/gecko/icons/preparation/AboutPagesPreparer.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/preparation/AboutPagesPreparer.java
@@ -16,19 +16,17 @@ import java.util.Set;
 
 /**
  * Preparer implementation for adding the omni.ja URL for internal about: pages.
  */
 public class AboutPagesPreparer implements Preparer {
     private Set<String> aboutUrls;
 
     public AboutPagesPreparer() {
-        aboutUrls = new HashSet<>();
-
-        Collections.addAll(aboutUrls, AboutPages.DEFAULT_ICON_PAGES);
+        aboutUrls = new HashSet<>(AboutPages.DEFAULT_ICON_PAGES);
     }
 
     @Override
     public void prepare(IconRequest request) {
         if (aboutUrls.contains(request.getPageUrl())) {
             final String iconUrl = GeckoJarReader.getJarURL(request.getContext(), "chrome/chrome/content/branding/favicon64.png");
 
             request.modify()