bug 395644: postface plugin names with '(in Firefox)' in Applications prefpane actions dropdown menu; r=gavin, a=mconnor
authormyk@mozilla.org
Mon, 17 Sep 2007 11:58:05 -0700
changeset 5966 dc20140681cea87c13a0f9f0369541630e954d18
parent 5965 29d324f849766ed5852292d4a2aa11e33b2c03a1
child 5967 cb25a3cb2540545f168ddf26eda079c9eca425d9
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, mconnor
bugs395644
milestone1.9a8pre
bug 395644: postface plugin names with '(in Firefox)' in Applications prefpane actions dropdown menu; r=gavin, a=mconnor
browser/components/preferences/applications.js
browser/components/preferences/preferences.xul
browser/locales/en-US/chrome/browser/preferences/preferences.properties
--- a/browser/components/preferences/applications.js
+++ b/browser/components/preferences/applications.js
@@ -218,19 +218,19 @@ HandlerInfoWrapper.prototype = {
     return this._type;
   },
 
   get description() {
     if (this.wrappedHandlerInfo.description)
       return this.wrappedHandlerInfo.description;
 
     if (this.primaryExtension) {
-      let bundle = this.element("bundlePreferences");
       var extension = this.primaryExtension.toUpperCase();
-      return bundle.getFormattedString("fileEnding", [extension]);
+      return this.element("bundlePreferences").getFormattedString("fileEnding",
+                                                                  [extension]);
     }
 
     return this.type;
   },
 
   get preferredApplicationHandler() {
     return this.wrappedHandlerInfo.preferredApplicationHandler;
   },
@@ -474,17 +474,17 @@ var feedHandlerInfo = {
   _shellSvc: Cc["@mozilla.org/browser/shell-service;1"].
              getService(Ci.nsIShellService),
 
 
   //**************************************************************************//
   // nsIHandlerInfo
 
   get description() {
-    return gApplicationsPane._bundle.getString("webFeed");
+    return this.element("bundlePreferences").getString("webFeed");
   },
 
   get preferredApplicationHandler() {
     switch (this.element(PREF_FEED_SELECTED_READER).value) {
       case "client":
         var file = this.element(PREF_FEED_SELECTED_APP).value;
         if (file)
           return getLocalHandlerApp(file);
@@ -707,17 +707,18 @@ var feedHandlerInfo = {
 //****************************************************************************//
 // Prefpane Controller
 
 var gApplicationsPane = {
   // The set of types the app knows how to handle.  A hash of HandlerInfoWrapper
   // objects, indexed by type.
   _handledTypes: {},
 
-  _bundle       : null,
+  _brandBundle  : null,
+  _prefsBundle  : null,
   _list         : null,
   _filter       : null,
 
   // Retrieve this as nsIPrefBranch and then immediately QI to nsIPrefBranch2
   // so both interfaces are available to callers.
   _prefSvc      : Cc["@mozilla.org/preferences-service;1"].
                   getService(Ci.nsIPrefBranch).
                   QueryInterface(Ci.nsIPrefBranch2),
@@ -735,17 +736,18 @@ var gApplicationsPane = {
                   getService(Ci.nsIIOService),
 
 
   //**************************************************************************//
   // Initialization & Destruction
 
   init: function() {
     // Initialize shortcuts to some commonly accessed elements.
-    this._bundle = document.getElementById("bundlePreferences");
+    this._brandBundle = document.getElementById("bundleBrand");
+    this._prefsBundle = document.getElementById("bundlePreferences");
     this._list = document.getElementById("handlersView");
     this._filter = document.getElementById("filter");
 
     // Observe preferences that influence what we display so we can rebuild
     // the view when they change.
     this._prefSvc.addObserver(PREF_SHOW_PLUGINS_IN_LIST, this, false);
     this._prefSvc.addObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this, false);
     this._prefSvc.addObserver(PREF_FEED_SELECTED_APP, this, false);
@@ -998,29 +1000,29 @@ var gApplicationsPane = {
    *                                      is being described
    */
   _describePreferredAction: function(aHandlerInfo) {
     // alwaysAskBeforeHandling overrides the preferred action, so if that flag
     // is set, then describe that behavior instead.  Currently we hide all types
     // with alwaysAskBeforeHandling except for the feed type, so here we use
     // a feed-specific message to describe the behavior.
     if (aHandlerInfo.alwaysAskBeforeHandling)
-      return this._bundle.getString("alwaysAskAboutFeed");
+      return this._prefsBundle.getString("alwaysAskAboutFeed");
 
     switch (aHandlerInfo.preferredAction) {
       case Ci.nsIHandlerInfo.saveToDisk:
-        return this._bundle.getString("saveToDisk");
+        return this._prefsBundle.getString("saveToDisk");
 
       case Ci.nsIHandlerInfo.useHelperApp:
         return aHandlerInfo.preferredApplicationHandler.name;
 
       case Ci.nsIHandlerInfo.handleInternally:
         // For the feed type, handleInternally means live bookmarks.
         if (aHandlerInfo.type == TYPE_MAYBE_FEED)
-          return this._bundle.getString("liveBookmarks");
+          return this._prefsBundle.getString("liveBookmarks");
 
         // For other types, handleInternally looks like either useHelperApp
         // or useSystemDefault depending on whether or not there's a preferred
         // handler app.
         if (this.isValidHandlerApp(aHandlerInfo.preferredApplicationHandler))
           return aHandlerInfo.preferredApplicationHandler.name;
 
         return aHandlerInfo.defaultDescription;
@@ -1029,17 +1031,20 @@ var gApplicationsPane = {
         // Is it because the app can't actually do that?  But if that's true,
         // then why would a preferredAction ever get set to this value
         // in the first place?
 
       case Ci.nsIHandlerInfo.useSystemDefault:
         return aHandlerInfo.defaultDescription;
 
       case kActionUsePlugin:
-        return aHandlerInfo.plugin.name;
+        let brandShortName = this._brandBundle.getString("brandShortName");
+        return this._prefsBundle.getFormattedString("pluginName",
+                                                    [aHandlerInfo.plugin.name,
+                                                     brandShortName]);
     }
   },
 
   /**
    * Whether or not the given handler app is valid.
    *
    * @param aHandlerApp {nsIHandlerApp} the handler app in question
    *
@@ -1077,24 +1082,25 @@ var gApplicationsPane = {
     // Clear out existing items.
     while (menuPopup.hasChildNodes())
       menuPopup.removeChild(menuPopup.lastChild);
 
     // If this is the feed type, add Preview in Firefox and Live Bookmarks items.
     if (handlerInfo.type == TYPE_MAYBE_FEED) {
       let menuItem = document.createElementNS(kXULNS, "menuitem");
       menuItem.setAttribute("alwaysAsk", "true");
-      menuItem.setAttribute("label", this._bundle.getString("alwaysAskAboutFeed"));
+      menuItem.setAttribute("label",
+                            this._prefsBundle.getString("alwaysAskAboutFeed"));
       menuPopup.appendChild(menuItem);
       if (handlerInfo.alwaysAskBeforeHandling)
         menu.selectedItem = menuItem;
 
       menuItem = document.createElementNS(kXULNS, "menuitem");
       menuItem.setAttribute("action", Ci.nsIHandlerInfo.handleInternally);
-      menuItem.setAttribute("label", this._bundle.getString("liveBookmarks"));
+      menuItem.setAttribute("label", this._prefsBundle.getString("liveBookmarks"));
       menuItem.setAttribute("image", "chrome://browser/skin/page-livemarks.png");
       menuPopup.appendChild(menuItem);
       if (handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally)
         menu.selectedItem = menuItem;
 
       // Add a separator to distinguish these items from the helper app items
       // that follow them.
       menuItem = document.createElementNS(kXULNS, "menuseparator");
@@ -1144,17 +1150,21 @@ var gApplicationsPane = {
           preferredApp.equals(possibleApp))
         menu.selectedItem = menuItem;
     }
 
     // Create a menu item for the plugin.
     if (handlerInfo.plugin) {
       let menuItem = document.createElementNS(kXULNS, "menuitem");
       menuItem.setAttribute("action", kActionUsePlugin);
-      menuItem.setAttribute("label", handlerInfo.plugin.name);
+      let brandShortName = this._brandBundle.getString("brandShortName");
+      let label = this._prefsBundle.getFormattedString("pluginName",
+                                                       [handlerInfo.plugin.name,
+                                                        brandShortName]);
+      menuItem.setAttribute("label", label);
       menuPopup.appendChild(menuItem);
       if (handlerInfo.preferredAction == kActionUsePlugin)
         menu.selectedItem = menuItem;
     }
 
     // Create a menu item for saving to disk.
     // Note: this option isn't available to protocol types, since we don't know
     // what it means to save a URL having a certain scheme to disk, nor is it
@@ -1162,27 +1172,27 @@ var gApplicationsPane = {
     // And it's not available to types handled only by plugins either, although
     // I would think we'd want to give users the ability to redirect that stuff
     // to disk (so maybe we should revisit that decision).
     if ((handlerInfo instanceof Ci.nsIMIMEInfo) &&
         handlerInfo.type != TYPE_MAYBE_FEED &&
         !handlerInfo.handledOnlyByPlugin) {
       let menuItem = document.createElementNS(kXULNS, "menuitem");
       menuItem.setAttribute("action", Ci.nsIHandlerInfo.saveToDisk);
-      menuItem.setAttribute("label", this._bundle.getString("saveToDisk"));
+      menuItem.setAttribute("label", this._prefsBundle.getString("saveToDisk"));
       menuPopup.appendChild(menuItem);
       if (handlerInfo.preferredAction == Ci.nsIHandlerInfo.saveToDisk)
         menu.selectedItem = menuItem;
     }
 
     // Create a menu item for selecting a local application.
     {
       let menuItem = document.createElementNS(kXULNS, "menuitem");
       menuItem.setAttribute("oncommand", "gApplicationsPane.chooseApp(event)");
-      menuItem.setAttribute("label", this._bundle.getString("chooseApp"));
+      menuItem.setAttribute("label", this._prefsBundle.getString("chooseApp"));
       menuPopup.appendChild(menuItem);
     }
   },
 
 
   //**************************************************************************//
   // Sorting & Filtering
 
@@ -1331,17 +1341,17 @@ var gApplicationsPane = {
   },
 
   chooseApp: function(aEvent) {
     // Don't let the normal "on select action" handler get this event,
     // as we handle it specially ourselves.
     aEvent.stopPropagation();
 
     var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
-    var winTitle = this._bundle.getString("fpTitleChooseApp");
+    var winTitle = this._prefsBundle.getString("fpTitleChooseApp");
     fp.init(window, winTitle, Ci.nsIFilePicker.modeOpen);
     fp.appendFilters(Ci.nsIFilePicker.filterApps);
 
     if (fp.show() == Ci.nsIFilePicker.returnOK && fp.file) {
       // XXXben - we need to compare this with the running instance executable
       //          just don't know how to do that via script...
       // XXXmano TBD: can probably add this to nsIShellService
 #ifdef XP_WIN
--- a/browser/components/preferences/preferences.xul
+++ b/browser/components/preferences/preferences.xul
@@ -85,17 +85,18 @@
             style="&prefWin.styleWin;">
 #else
 #ifdef XP_MACOSX
             style="&prefWindow.styleMac;">
 #else
             style="&prefWin.styleGNOME;">
 #endif
 #endif
-  
+
+    <stringbundle id="bundleBrand" src="chrome://branding/locale/brand.properties"/>
     <stringbundle id="bundlePreferences"
                   src="chrome://browser/locale/preferences/preferences.properties"/>
 
     <prefpane id="paneMain" label="&paneMain.title;"
               src="chrome://browser/content/preferences/main.xul"/>
     <prefpane id="paneTabs" label="&paneTabs.title;"
               src="chrome://browser/content/preferences/tabs.xul"/>
     <prefpane id="paneContent" label="&paneContent.title;"
--- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties
+++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties
@@ -47,16 +47,20 @@ chooseDownloadFolderTitle=Choose Downloa
 
 fileEnding=%S file
 saveToDisk=Save to Disk
 chooseApp=Choose application...
 fpTitleChooseApp=Select Helper Application
 webFeed=Web Feed
 alwaysAskAboutFeed=Show me a preview and ask me which Feed Reader to use
 liveBookmarks=Live Bookmarks
+# LOCALIZATION NOTE (pluginName):
+# %1$S = plugin name (for example "QuickTime Plugin-in 7.2")
+# %2$S = brandShortName from brand.properties (for example "Minefield")
+pluginName=%S (in %S)
 
 #### Cookie Viewer
 
 hostColon=Host:
 domainColon=Domain:
 forSecureOnly=Encrypted connections only
 forAnyConnection=Any type of connection
 AtEndOfSession = at end of session