1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 23:28:06 +02:00

Managed preferences for Chrome administrators

Implement support for managed preferences. This feature allows users
(administrators) to easily change the default settings of the PDF Viewer for
all Chrome or Chromium browsers within their organization.

External resources for end users (administrators)

- http://www.chromium.org/administrators/
- http://www.chromium.org/administrators/configuring-policy-for-extensions
- http://www.chromium.org/administrators/windows-quick-start
- http://www.chromium.org/administrators/mac-quick-start
- http://www.chromium.org/administrators/linux-quick-start
- http://www.chromium.org/administrators/policy-templates

Administrators can read one of the previous links to learn more about creating
policies. We want to auto-generate these templates, but there are no public
tools for doing that. It will be added in the future, see:
https://code.google.com/p/chromium/issues/detail?id=389061

Resources for PDF.js/extension developers

- http://cs.chromium.org/file:policy_templates.json
- https://developer.chrome.com/extensions/manifest/storage
This commit is contained in:
Rob Wu 2014-07-24 23:19:17 +02:00
parent 2642583e82
commit 00746011a3
4 changed files with 114 additions and 1 deletions

View file

@ -18,6 +18,9 @@
'use strict';
//#if CHROME
////Note: Keep in sync with extensions/chromium/preferences_schema.json !
//#endif
var DEFAULT_PREFERENCES = {
showPreviousViewOnLoad: true,
defaultZoomValue: '',

View file

@ -178,7 +178,46 @@ var Preferences = {
//};
//#endif
//#if !(FIREFOX || MOZCENTRAL || B2G)
//#if CHROME
//Preferences._writeToStorage = function (prefObj) {
// return new Promise(function (resolve) {
// if (prefObj == DEFAULT_PREFERENCES) {
// var keysToRemove = Object.keys(DEFAULT_PREFERENCES);
// // If the storage is reset, remove the keys so that the values from
// // managed storage are applied again.
// chrome.storage.local.remove(keysToRemove, function() {
// resolve();
// });
// } else {
// chrome.storage.local.set(prefObj, function() {
// resolve();
// });
// }
// });
//};
//
//Preferences._readFromStorage = function (prefObj) {
// return new Promise(function (resolve) {
// if (chrome.storage.managed) {
// // Get preferences as set by the system administrator.
// // See extensions/chromium/preferences_schema.json for more information.
// // These preferences can be overridden by the user.
// chrome.storage.managed.get(DEFAULT_PREFERENCES, getPreferences);
// } else {
// // Managed storage not supported, e.g. in Opera.
// getPreferences(DEFAULT_PREFERENCES);
// }
//
// function getPreferences(defaultPrefs) {
// chrome.storage.local.get(defaultPrefs, function(readPrefs) {
// resolve(readPrefs);
// });
// }
// });
//};
//#endif
//#if !(FIREFOX || MOZCENTRAL || B2G || CHROME)
Preferences._writeToStorage = function (prefObj) {
return new Promise(function (resolve) {
localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));