diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm index 1c2bb5257..e714c841e 100644 --- a/extensions/firefox/content/PdfStreamConverter.jsm +++ b/extensions/firefox/content/PdfStreamConverter.jsm @@ -114,6 +114,9 @@ function getStringPref(pref, def) { } function log(aMsg) { + if (!getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false)) { + return; + } var msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg); Services.console.logStringMessage(msg); dump(msg + '\n'); diff --git a/extensions/firefox/content/PdfjsChromeUtils.jsm b/extensions/firefox/content/PdfjsChromeUtils.jsm index 89e995b3a..8b28ce45d 100644 --- a/extensions/firefox/content/PdfjsChromeUtils.jsm +++ b/extensions/firefox/content/PdfjsChromeUtils.jsm @@ -1,3 +1,5 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +25,7 @@ const Ci = Components.interfaces; const Cr = Components.results; const Cu = Components.utils; -const PREF_PREFIX = 'pdfjs'; +const PREF_PREFIX = 'PDFJSSCRIPT_PREF_PREFIX'; const PDF_CONTENT_TYPE = 'application/pdf'; Cu.import('resource://gre/modules/XPCOMUtils.jsm'); @@ -175,8 +177,10 @@ let PdfjsChromeUtils = { return true; }, - _isPrefAllowed: function (aPrefName) { - if (this._allowedPrefNames.indexOf(aPrefName) == -1) { + _ensurePreferenceAllowed: function (aPrefName) { + let unPrefixedName = aPrefName.split(PREF_PREFIX + '.'); + if (unPrefixedName[0] !== '' || + this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) { let msg = "'" + aPrefName + "' "; msg += "can't be accessed from content. See PdfjsChromeUtils." throw new Error(msg); @@ -184,27 +188,27 @@ let PdfjsChromeUtils = { }, _clearUserPref: function (aPrefName) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); Services.prefs.clearUserPref(aPrefName); }, _setIntPref: function (aPrefName, aPrefValue) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); Services.prefs.setIntPref(aPrefName, aPrefValue); }, _setBoolPref: function (aPrefName, aPrefValue) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); Services.prefs.setBoolPref(aPrefName, aPrefValue); }, _setCharPref: function (aPrefName, aPrefValue) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); Services.prefs.setCharPref(aPrefName, aPrefValue); }, _setStringPref: function (aPrefName, aPrefValue) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); let str = Cc['@mozilla.org/supports-string;1'] .createInstance(Ci.nsISupportsString); str.data = aPrefValue; diff --git a/extensions/firefox/content/pdfjschildbootstrap.js b/extensions/firefox/content/pdfjschildbootstrap.js index 8e5a48aa4..c9758b3e5 100644 --- a/extensions/firefox/content/pdfjschildbootstrap.js +++ b/extensions/firefox/content/pdfjschildbootstrap.js @@ -1,6 +1,19 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +/* Copyright 2014 Mozilla Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ /* jshint esnext:true */ /* globals Components, PdfjsContentUtils, PdfJs */ diff --git a/make.js b/make.js index 7ab11f765..f7789da8a 100644 --- a/make.js +++ b/make.js @@ -680,6 +680,8 @@ target.firefox = function() { FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm'); sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'false', FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm'); + sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX, + FIREFOX_BUILD_CONTENT_DIR + 'PdfjsChromeUtils.jsm'); // Update localized metadata var localizedMetadata = cat(EXTENSION_SRC_DIR + '/firefox/metadata.inc'); @@ -808,6 +810,8 @@ target.mozcentral = function() { MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm'); sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'true', MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm'); + sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX, + MOZCENTRAL_CONTENT_DIR + 'PdfjsChromeUtils.jsm'); // Copy test files mkdir('-p', MOZCENTRAL_TEST_DIR);