genericcom.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2022 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * JavaScript code in this page
  21. */
  22. "use strict";
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.GenericCom = void 0;
  27. var _app = require("./app.js");
  28. var _preferences = require("./preferences.js");
  29. var _download_manager = require("./download_manager.js");
  30. var _genericl10n = require("./genericl10n.js");
  31. var _generic_scripting = require("./generic_scripting.js");
  32. ;
  33. const GenericCom = {};
  34. exports.GenericCom = GenericCom;
  35. class GenericPreferences extends _preferences.BasePreferences {
  36. async _writeToStorage(prefObj) {
  37. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  38. }
  39. async _readFromStorage(prefObj) {
  40. return JSON.parse(localStorage.getItem("pdfjs.preferences"));
  41. }
  42. }
  43. class GenericExternalServices extends _app.DefaultExternalServices {
  44. static createDownloadManager() {
  45. return new _download_manager.DownloadManager();
  46. }
  47. static createPreferences() {
  48. return new GenericPreferences();
  49. }
  50. static createL10n({
  51. locale = "en-US"
  52. }) {
  53. return new _genericl10n.GenericL10n(locale);
  54. }
  55. static createScripting({
  56. sandboxBundleSrc
  57. }) {
  58. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  59. }
  60. }
  61. _app.PDFViewerApplication.externalServices = GenericExternalServices;