Bug 945842 - Show Metro bookmarks folder in Windows 8 only. r=jaws, a=akeybl
authorMarina Samuel <msamuel@mozilla.com>
Thu, 12 Dec 2013 17:54:16 -0500
changeset 175234 7ce333a03499352094b659d273a7d361273cfc7d
parent 175233 d9a1af3800c5ccc6008b194bf8f227686a6cad79
child 175235 4d297d7127921612e1bf6c3b6f401918be4cab0e
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, akeybl
bugs945842
milestone28.0a2
Bug 945842 - Show Metro bookmarks folder in Windows 8 only. r=jaws, a=akeybl
browser/components/nsBrowserGlue.js
browser/components/places/tests/unit/head_bookmarks.js
xpcom/base/nsSystemInfo.cpp
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1577,17 +1577,17 @@ BrowserGlue.prototype = {
   ensurePlacesDefaultQueriesInitialized:
   function BG_ensurePlacesDefaultQueriesInitialized() {
     // This is actual version of the smart bookmarks, must be increased every
     // time smart bookmarks change.
     // When adding a new smart bookmark below, its newInVersion property must
     // be set to the version it has been added in, we will compare its value
     // to users' smartBookmarksVersion and add new smart bookmarks without
     // recreating old deleted ones.
-    const SMART_BOOKMARKS_VERSION = 5;
+    const SMART_BOOKMARKS_VERSION = 6;
     const SMART_BOOKMARKS_ANNO = "Places/SmartBookmark";
     const SMART_BOOKMARKS_PREF = "browser.places.smartBookmarksVersion";
 
     // TODO bug 399268: should this be a pref?
     const MAX_RESULTS = 10;
 
     // Get current smart bookmarks version.  If not set, create them.
     let smartBookmarksCurrentVersion = 0;
@@ -1639,31 +1639,34 @@ BrowserGlue.prototype = {
                                 Ci.nsINavHistoryQueryOptions.RESULTS_AS_TAG_QUERY +
                                 "&sort=" +
                                 Ci.nsINavHistoryQueryOptions.SORT_BY_LASTMODIFIED_DESCENDING +
                                 "&maxResults=" + MAX_RESULTS),
             parent: PlacesUtils.bookmarksMenuFolderId,
             position: menuIndex++,
             newInVersion: 1
           },
-          Windows8Touch: {
+        };
+
+        if (Services.sysinfo.getProperty("hasWindowsTouchInterface")) {
+          smartBookmarks.Windows8Touch = {
             title: bundle.GetStringFromName("windows8TouchTitle"),
             uri: NetUtil.newURI("place:folder=" +
                                 PlacesUtils.annotations.getItemsWithAnnotation('metro/bookmarksRoot', {})[0] +
                                 "&queryType=" +
                                 Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS +
                                 "&sort=" +
                                 Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_DESCENDING +
                                 "&maxResults=" + MAX_RESULTS +
                                 "&excludeQueries=1"),
             parent: PlacesUtils.bookmarksMenuFolderId,
             position: menuIndex++,
-            newInVersion: 5
-          },
-        };
+            newInVersion: 6
+          };
+        }
 
         // Set current itemId, parent and position if Smart Bookmark exists,
         // we will use these informations to create the new version at the same
         // position.
         let smartBookmarkItemIds = PlacesUtils.annotations.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO);
         smartBookmarkItemIds.forEach(function (itemId) {
           let queryId = PlacesUtils.annotations.getItemAnnotation(itemId, SMART_BOOKMARKS_ANNO);
           if (queryId in smartBookmarks) {
--- a/browser/components/places/tests/unit/head_bookmarks.js
+++ b/browser/components/places/tests/unit/head_bookmarks.js
@@ -58,15 +58,16 @@ let (XULAppInfo = {
   };
   let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
   registrar.registerFactory(Components.ID("{fbfae60b-64a4-44ef-a911-08ceb70b9f31}"),
                             "XULAppInfo", "@mozilla.org/xre/app-info;1",
                             XULAppInfoFactory);
 }
 
 // Smart bookmarks constants.
-const SMART_BOOKMARKS_VERSION = 5;
+let isWin8OrHigher = Services.sysinfo.getProperty("hasWindowsTouchInterface");
+const SMART_BOOKMARKS_VERSION = 6
 const SMART_BOOKMARKS_ON_TOOLBAR = 1;
-const SMART_BOOKMARKS_ON_MENU = 4; // Takes in count the additional separator.
+const SMART_BOOKMARKS_ON_MENU = isWin8OrHigher ? 4 : 3; // Takes in count the additional separator.
 
 // Default bookmarks constants.
 const DEFAULT_BOOKMARKS_ON_TOOLBAR = 1;
 const DEFAULT_BOOKMARKS_ON_MENU = 1;
--- a/xpcom/base/nsSystemInfo.cpp
+++ b/xpcom/base/nsSystemInfo.cpp
@@ -171,16 +171,31 @@ nsSystemInfo::Init()
         if (NS_WARN_IF(NS_FAILED(rv)))
           return rv;
       }
       else {
         NS_WARNING("PR_GetSystemInfo failed");
       }
     }
 
+#if defined(XP_WIN) && defined(MOZ_METRO)
+    // Create "hasWindowsTouchInterface" property.
+    nsAutoString version;
+    rv = GetPropertyAsAString(NS_LITERAL_STRING("version"), version);
+    NS_ENSURE_SUCCESS(rv, rv);
+    double versionDouble = atof(NS_ConvertUTF16toUTF8(version).get());
+
+    rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16("hasWindowsTouchInterface"),
+      versionDouble >= 6.2);
+    NS_ENSURE_SUCCESS(rv, rv);
+#else
+    rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16("hasWindowsTouchInterface"), false);
+    NS_ENSURE_SUCCESS(rv, rv);
+#endif
+
     // Additional informations not available through PR_GetSystemInfo.
     SetInt32Property(NS_LITERAL_STRING("pagesize"), PR_GetPageSize());
     SetInt32Property(NS_LITERAL_STRING("pageshift"), PR_GetPageShift());
     SetInt32Property(NS_LITERAL_STRING("memmapalign"), PR_GetMemMapAlignment());
     SetInt32Property(NS_LITERAL_STRING("cpucount"), PR_GetNumberOfProcessors());
     SetUint64Property(NS_LITERAL_STRING("memsize"), PR_GetPhysicalMemorySize());
 
     for (uint32_t i = 0; i < ArrayLength(cpuPropItems); i++) {