]> git.parisson.com Git - pdf.js.git/commitdiff
Merge upstream. Use new l10n.
authorBrendan Dahl <brendan.dahl@gmail.com>
Tue, 15 May 2012 17:33:01 +0000 (10:33 -0700)
committerBrendan Dahl <brendan.dahl@gmail.com>
Tue, 15 May 2012 17:33:01 +0000 (10:33 -0700)
1  2 
extensions/firefox/components/PdfStreamConverter.js
l10n/en-US/chrome.properties
make.js
src/api.js
src/core.js
src/evaluator.js
web/viewer.js

index 9f5cc6bee779c2f3e88c082e294efccbc1811b48,1bcccbe22ad49499e85daa09bb3cff3685550c0b..ced6b104846744f977898a3339fd4953d7ae2a9d
@@@ -11,18 -11,27 +11,29 @@@ const Cr = Components.results
  const Cu = Components.utils;
  const PDFJS_EVENT_ID = 'pdf.js.message';
  const PDF_CONTENT_TYPE = 'application/pdf';
 -const EXT_PREFIX = 'extensions.uriloader@pdf.js';
 +const EXT_ID = 'uriloader@pdf.js';
 +const EXT_PREFIX = 'extensions.' + EXT_ID;
  const MAX_DATABASE_LENGTH = 4096;
+ const FIREFOX_ID = '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}';
+ const SEAMONKEY_ID = '{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}';
  
  Cu.import('resource://gre/modules/XPCOMUtils.jsm');
  Cu.import('resource://gre/modules/Services.jsm');
  Cu.import('resource://gre/modules/NetUtil.jsm');
 +Cu.import('resource://gre/modules/AddonManager.jsm');
  
- let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
-                         .getService(Ci.nsIPrivateBrowsingService);
- let inPrivateBrowswing = privateBrowsing.privateBrowsingEnabled;
+ let appInfo = Cc['@mozilla.org/xre/app-info;1']
+                   .getService(Ci.nsIXULAppInfo);
+ let privateBrowsing, inPrivateBrowsing;
+ if (appInfo.ID === FIREFOX_ID) {
+   privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
+                           .getService(Ci.nsIPrivateBrowsingService);
+   inPrivateBrowsing = privateBrowsing.privateBrowsingEnabled;
+ } else if (appInfo.ID === SEAMONKEY_ID) {
+   privateBrowsing = null;
+   inPrivateBrowsing = false;
+ }
  
  function getBoolPref(pref, def) {
    try {
@@@ -61,12 -70,27 +72,32 @@@ function getDOMWindow(aChannel) 
    return win;
  }
  
- // Fake l10n until we get the real l10n sorted out.
- var mozL10n = {
-   get: function(key, args, fallback) {
-     return fallback;
+ function getLocalizedStrings(path) {
+   var stringBundle = Cc['@mozilla.org/intl/stringbundle;1'].
+       getService(Ci.nsIStringBundleService).
+       createBundle('chrome://pdf.js/locale/' + path);
+   var map = {};
+   var enumerator = stringBundle.getSimpleEnumeration();
+   while (enumerator.hasMoreElements()) {
+     var string = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement);
+     var key = string.key, property = 'textContent';
+     var i = key.lastIndexOf('.');
+     if (i >= 0) {
+       property = key.substring(i + 1);
+       key = key.substring(0, i);
+     }
+     if (!(key in map))
+       map[key] = {};
+     map[key][property] = string.value;
    }
- };
+   return map;
+ }
++function getLocalizedString(strings, id) {
++  if (id in strings)
++    return strings[id]['textContent'];
++  return id;
++}
  
  // All the priviledged actions.
  function ChromeActions() {
@@@ -122,35 -146,21 +153,47 @@@ ChromeActions.prototype = 
    getLocale: function() {
      return getStringPref('general.useragent.locale', 'en-US');
    },
+   getStrings: function(data) {
+     try {
+       // Lazy initialization of localizedStrings
+       if (!('localizedStrings' in this))
+         this.localizedStrings = getLocalizedStrings('viewer.properties');
+       var result = this.localizedStrings[data];
+       return JSON.stringify(result || null);
+     } catch (e) {
+       log('Unable to retrive localized strings: ' + e);
+       return 'null';
+     }
+   },
    pdfBugEnabled: function() {
      return getBoolPref(EXT_PREFIX + '.pdfBugEnabled', false);
-     var message = mozL10n.get('unsupported_feature', null,
-                   'An unsupported feature was detected in this PDF document.');
 +  },
 +  fallback: function(url) {
++    var strings = getLocalizedStrings('chrome.properties');
 +    var self = this;
-       label: mozL10n.get('download_document', null, 'Download Document'),
++    var message = getLocalizedString(strings, 'unsupported_feature');
 +    var win = Services.wm.getMostRecentWindow('navigator:browser');
 +    var notificationBox = win.gBrowser.getNotificationBox();
 +    var buttons = [{
-       label: mozL10n.get('disable_viewer', null,
-                          'Disable Mozilla PDF Viewer'),
++      label: getLocalizedString(strings, 'download_document'),
 +      accessKey: null,
 +      callback: function() {
 +        self.download(url);
 +      }
 +    }, {
++      label: getLocalizedString(strings, 'disable_viewer'),
 +      accessKey: null,
 +      callback: function() {
 +        AddonManager.getAddonByID(EXT_ID, function(aAddon) {
 +          aAddon.userDisabled = true;
 +          win.gBrowser.contentWindow.location.reload();
 +        });
 +      }
 +    }];
 +    notificationBox.appendNotification(message, 'pdfjs-fallback', null,
 +                                       notificationBox.PRIORITY_WARNING_LOW,
 +                                       buttons);
    }
  };
  
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..f0f4bcb8841cf892bbc76bb5c816a7ec2426bdb2
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,3 @@@
++unsupported_feature=An unsupported feature was detected in this PDF document.
++download_document=Download Document
++disable_viewer=Disable Mozilla PDF Viewer
diff --cc make.js
index 0a39e0b07dcbaa875f729bcc0ff526fe2b44f183,88f7c69a073a2cf5c2013dfb933230a1ca44b3af..e166b6b96fb68e757d574138bb59d894cc2477e9
+++ b/make.js
@@@ -91,14 -97,15 +97,19 @@@ target.locale = function() 
        continue;
      }
  
+     mkdir('-p', EXTENSION_LOCALE_OUTPUT + '/' + locale);
+     chromeManifestContent += 'locale  pdf.js  ' + locale + '  locale/' + locale + '/\n';
      if (test('-f', path + '/viewer.properties')) {
        var properties = cat(path + '/viewer.properties');
-       if (locale == DEFAULT_LOCALE)
-         viewerOutput = '[*]\n' + properties + '\n' + viewerOutput;
-       else
-         viewerOutput = viewerOutput + '[' + locale + ']\n' + properties + '\n';
+       viewerOutput += '[' + locale + ']\n' + properties + '\n';
+       cp(path + '/viewer.properties', EXTENSION_LOCALE_OUTPUT + '/' + locale);
+     }
++    if (test('-f', path + '/chrome.properties')) {
++      cp(path + '/chrome.properties', EXTENSION_LOCALE_OUTPUT + '/' + locale);
 +    }
 +
      if (test('-f', path + '/metadata.inc')) {
        var metadata = cat(path + '/metadata.inc');
        metadataContent += metadata;
diff --cc src/api.js
Simple merge
diff --cc src/core.js
Simple merge
Simple merge
diff --cc web/viewer.js
Simple merge