| Index: chrome/browser/resources/print_preview/data/local_parsers.js
|
| diff --git a/chrome/browser/resources/print_preview/data/local_parsers.js b/chrome/browser/resources/print_preview/data/local_parsers.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..af58290a8eb8583d411cd47adcaf856c0d9103fb
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/print_preview/data/local_parsers.js
|
| @@ -0,0 +1,70 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +cr.define('print_preview', function() {
|
| + 'use strict';
|
| +
|
| + /** Namespace that contains a method to parse local print destinations. */
|
| + function LocalDestinationParser() {};
|
| +
|
| + /**
|
| + * Parses a local print destination.
|
| + * @param {object} destinationInfo Information describing a local print
|
| + * destination.
|
| + * @return {!print_preview.Destination} Parsed local print destination.
|
| + */
|
| + LocalDestinationParser.parse = function(destinationInfo) {
|
| + return new print_preview.Destination(
|
| + destinationInfo.deviceName,
|
| + destinationInfo.printerName,
|
| + false /*isRecent*/,
|
| + true /*isLocal*/);
|
| + };
|
| +
|
| + /** Namespace that contains a method to parse local print capabilities. */
|
| + function LocalCapabilitiesParser() {};
|
| +
|
| + /**
|
| + * Parses local print capabilities.
|
| + * @param {object} settingsInfo Object that describes local print
|
| + * capabilities.
|
| + * @return {!print_preview.ChromiumCapabilities} Parsed local print
|
| + * capabilities.
|
| + */
|
| + LocalCapabilitiesParser.parse = function(settingsInfo) {
|
| + var hasColorCapability = false;
|
| + var defaultIsColorEnabled = false;
|
| + if (hasColorCapability = !settingsInfo['disableColorOption']) {
|
| + defaultIsColorEnabled = settingsInfo['setColorAsDefault'];
|
| + }
|
| +
|
| + var hasDuplexCapability = false;
|
| + var defaultIsDuplexEnabled = false;
|
| + if (hasDuplexCapability =
|
| + settingsInfo['printerDefaultDuplexValue'] !=
|
| + print_preview.NativeLayer.DuplexMode.UNKNOWN_DUPLEX_MODE) {
|
| + defaultIsDuplexEnabled =
|
| + settingsInfo['printerDefaultDuplexValue'] ==
|
| + print_preview.NativeLayer.DuplexMode.LONG_EDGE;
|
| + }
|
| +
|
| + return new print_preview.ChromiumCapabilities(
|
| + !settingsInfo['disableCopiesOption'] /*hasCopiesCapability*/,
|
| + '1' /*defaultCopiesStr*/,
|
| + true /*hasCollateCapability*/,
|
| + true /*defaultIsCollateEnabled*/,
|
| + hasDuplexCapability,
|
| + defaultIsDuplexEnabled,
|
| + !settingsInfo['disableLandscapeOption'] /*hasOrientationCapability*/,
|
| + false /*defaultIsLandscapeEnabled*/,
|
| + hasColorCapability,
|
| + defaultIsColorEnabled);
|
| + };
|
| +
|
| + // Export
|
| + return {
|
| + LocalCapabilitiesParser: LocalCapabilitiesParser,
|
| + LocalDestinationParser: LocalDestinationParser
|
| + };
|
| +});
|
|
|