From 25f5738d760f2a2fe9686c2f857f97fcae438a45 Mon Sep 17 00:00:00 2001 From: Marina Samuel Date: Tue, 10 Dec 2013 13:42:16 -0500 Subject: [PATCH] Bug 945842: Show Metro bookmarks folder in Windows 8 only. r=bbondy --- .../customizableui/src/CustomizableWidgets.jsm | 10 +--------- browser/components/nsBrowserGlue.js | 13 ++++++++----- .../places/tests/unit/head_bookmarks.js | 5 +++-- xpcom/base/nsSystemInfo.cpp | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/browser/components/customizableui/src/CustomizableWidgets.jsm b/browser/components/customizableui/src/CustomizableWidgets.jsm index 1ffb1296bbc..025d4dbfa4c 100644 --- a/browser/components/customizableui/src/CustomizableWidgets.jsm +++ b/browser/components/customizableui/src/CustomizableWidgets.jsm @@ -29,14 +29,6 @@ const kWidePanelItemClass = "panel-wide-item"; let gModuleName = "[CustomizableWidgets]"; #include logging.js -function isWin8OrHigher() { - let osName = Services.sysinfo.getProperty("name"); - let version = Services.sysinfo.getProperty("version"); - - // Windows 8 is version >= 6.2 - return osName == "Windows_NT" && Services.vc.compare(version, "6.2") >= 0; -} - function setAttributes(aNode, aAttrs) { for (let [name, value] of Iterator(aAttrs)) { if (!value) { @@ -800,7 +792,7 @@ const CustomizableWidgets = [{ #ifdef XP_WIN #ifdef MOZ_METRO -if (isWin8OrHigher()) { +if (Services.sysinfo.getProperty("hasWindowsTouchInterface")) { let widgetArgs = {tooltiptext: "switch-to-metro-button2.tooltiptext"}; let brandShortName = BrandBundle.GetStringFromName("brandShortName"); let metroTooltip = CustomizableUI.getLocalizedProperty(widgetArgs, "tooltiptext", diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index f0c2e1ad2f8..17491c320f9 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -1591,7 +1591,7 @@ BrowserGlue.prototype = { // 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"; @@ -1653,7 +1653,10 @@ BrowserGlue.prototype = { 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] + @@ -1665,9 +1668,9 @@ BrowserGlue.prototype = { "&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 diff --git a/browser/components/places/tests/unit/head_bookmarks.js b/browser/components/places/tests/unit/head_bookmarks.js index ca6b0b6816f..aa9b53c1028 100644 --- a/browser/components/places/tests/unit/head_bookmarks.js +++ b/browser/components/places/tests/unit/head_bookmarks.js @@ -63,9 +63,10 @@ let (XULAppInfo = { } // 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; diff --git a/xpcom/base/nsSystemInfo.cpp b/xpcom/base/nsSystemInfo.cpp index cc0acf665e3..4c6e8a4ff17 100644 --- a/xpcom/base/nsSystemInfo.cpp +++ b/xpcom/base/nsSystemInfo.cpp @@ -176,6 +176,21 @@ nsSystemInfo::Init() } } +#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());