Commit caa80875 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Finish deletion, remove unused strings

- Delete ticket items and other unused files in data/
- Complete TODOs in handler
- Remove unused strings

Bug: 908705
Change-Id: Ie02a00ad6b8ada56b3d327d75e2ad841e534cb9f
Reviewed-on: https://chromium-review.googlesource.com/c/1357527
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613267}
parent c8ce1331
...@@ -89,9 +89,6 @@ ...@@ -89,9 +89,6 @@
desc="Option shown on printer drop-down list for saving previewed document as a PDF."> desc="Option shown on printer drop-down list for saving previewed document as a PDF.">
Save as PDF Save as PDF
</message> </message>
<message name="IDS_PRINT_PREVIEW_SUMMARY_FORMAT_LONG" desc="Print summary, explaining to the user how many pages will be printed.">
Total: <ph name="NUMBER_OF_SHEETS">$1<ex>10</ex></ph> <ph name="SHEETS_LABEL">$2<ex>sheets of paper</ex></ph> (<ph name="NUMBER_OF_PAGES">$3<ex>4</ex></ph> <ph name="PAGE_OR_PAGES_LABEL">$4<ex>Pages</ex></ph>)
</message>
<message name="IDS_PRINT_PREVIEW_SUMMARY_FORMAT_SHORT" desc="Print summary, explaining to the user how many pages will be printed."> <message name="IDS_PRINT_PREVIEW_SUMMARY_FORMAT_SHORT" desc="Print summary, explaining to the user how many pages will be printed.">
Total: <ph name="NUMBER_OF_SHEETS">$1<ex>10</ex></ph> <ph name="SHEETS_LABEL">$2<ex>sheets of paper</ex></ph> Total: <ph name="NUMBER_OF_SHEETS">$1<ex>10</ex></ph> <ph name="SHEETS_LABEL">$2<ex>sheets of paper</ex></ph>
</message> </message>
...@@ -110,9 +107,6 @@ ...@@ -110,9 +107,6 @@
<message name="IDS_PRINT_PREVIEW_PAGE_RANGE_SYNTAX_INSTRUCTION" desc="Instruction shown when the user enters an invalid page range."> <message name="IDS_PRINT_PREVIEW_PAGE_RANGE_SYNTAX_INSTRUCTION" desc="Instruction shown when the user enters an invalid page range.">
Invalid page range, use <ph name="EXAMPLE_PAGE_RANGE">$1<ex>e.g. 1-5, 8, 11-13</ex></ph> Invalid page range, use <ph name="EXAMPLE_PAGE_RANGE">$1<ex>e.g. 1-5, 8, 11-13</ex></ph>
</message> </message>
<message name="IDS_PRINT_PREVIEW_PAGE_RANGE_LIMIT_INSTRUCTION" desc="Instruction shown when the user enters an excessive page range.">
Out of bounds page reference
</message>
<message name="IDS_PRINT_PREVIEW_PAGE_RANGE_LIMIT_INSTRUCTION_WITH_VALUE" desc="Instruction shown when the user enters an excessive page number, and the maximum page."> <message name="IDS_PRINT_PREVIEW_PAGE_RANGE_LIMIT_INSTRUCTION_WITH_VALUE" desc="Instruction shown when the user enters an excessive page number, and the maximum page.">
Out of bounds page reference, limit is <ph name="MAXIMUM_PAGE">$1<ex>1</ex></ph> Out of bounds page reference, limit is <ph name="MAXIMUM_PAGE">$1<ex>1</ex></ph>
</message> </message>
...@@ -182,9 +176,6 @@ ...@@ -182,9 +176,6 @@
<message name="IDS_PRINT_PREVIEW_DPI_ITEM_LABEL" desc="Print quality option value text."> <message name="IDS_PRINT_PREVIEW_DPI_ITEM_LABEL" desc="Print quality option value text.">
<ph name="DPI">$1<ex>300</ex></ph> dpi <ph name="DPI">$1<ex>300</ex></ph> dpi
</message> </message>
<message name="IDS_PRINT_PREVIEW_NATIVE_DIALOG" desc="Option offering the user to open the native print dialog, displayed when the PDF viewer is missing or when print preview fails.">
Print using system dialog
</message>
<message name="IDS_PRINT_PREVIEW_DESTINATION_SEARCH_TITLE" desc="Title of the destination search UI component."> <message name="IDS_PRINT_PREVIEW_DESTINATION_SEARCH_TITLE" desc="Title of the destination search UI component.">
Select a destination Select a destination
</message> </message>
...@@ -203,9 +194,6 @@ ...@@ -203,9 +194,6 @@
<message name="IDS_PRINT_PREVIEW_NO_DESTINATIONS_MESSAGE" desc="Message to show when no destinations were found."> <message name="IDS_PRINT_PREVIEW_NO_DESTINATIONS_MESSAGE" desc="Message to show when no destinations were found.">
No destinations found No destinations found
</message> </message>
<message name="IDS_PRINT_PREVIEW_SHOW_ALL_BUTTON_TEXT" desc="Label on a button to show all print destinations.">
Show All...
</message>
<message name="IDS_PRINT_PREVIEW_DESTINATION_COUNT" desc="Message to show how many print destinations the user has."> <message name="IDS_PRINT_PREVIEW_DESTINATION_COUNT" desc="Message to show how many print destinations the user has.">
(<ph name="COUNT">$1<ex>154</ex></ph>) (<ph name="COUNT">$1<ex>154</ex></ph>)
</message> </message>
...@@ -245,15 +233,9 @@ ...@@ -245,15 +233,9 @@
<message name="IDS_MORE_OPTIONS_LABEL" desc="Label of the toggle element to switch between showing more or less printing options in the Print Preview."> <message name="IDS_MORE_OPTIONS_LABEL" desc="Label of the toggle element to switch between showing more or less printing options in the Print Preview.">
More settings More settings
</message> </message>
<message name="IDS_LESS_OPTIONS_LABEL" desc="Label of the toggle element to switch between showing more or less printing options in the Print Preview.">
Fewer settings
</message>
<message name="IDS_PRINT_PREVIEW_COULD_NOT_PRINT" desc="Error message when printing fails in the print preview"> <message name="IDS_PRINT_PREVIEW_COULD_NOT_PRINT" desc="Error message when printing fails in the print preview">
Printing failed. Please check your printer and try again. Printing failed. Please check your printer and try again.
</message> </message>
<message name="IDS_PRINT_PREVIEW_REGISTER_PROMO_BUTTON_TEXT">
Register
</message>
<message name="IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_SEARCH_BOX_PLACEHOLDER" desc="Text to put in a advanced settings search box when user has not entered a search query."> <message name="IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_SEARCH_BOX_PLACEHOLDER" desc="Text to put in a advanced settings search box when user has not entered a search query.">
Search settings Search settings
</message> </message>
...@@ -266,12 +248,6 @@ ...@@ -266,12 +248,6 @@
<message name="IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_DIALOG_CONFIRM" desc="In title case: The text for the accept button on the printer advanced settings dialog."> <message name="IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_DIALOG_CONFIRM" desc="In title case: The text for the accept button on the printer advanced settings dialog.">
Apply Apply
</message> </message>
<message name="IDS_PRINT_PREVIEW_ADVANCED_OPTIONS_LABEL" desc="Printer advanced options section label.">
Advanced
</message>
<message name="IDS_PRINT_PREVIEW_SHOW_ADVANCED_OPTIONS" desc="The text for the button to open the printer's advanced settings dialog.">
Change printer options...
</message>
<message name="IDS_PRINT_PREVIEW_NEW_SHOW_ADVANCED_OPTIONS" desc="The text for the button to open the printer's advanced settings dialog in the new UI."> <message name="IDS_PRINT_PREVIEW_NEW_SHOW_ADVANCED_OPTIONS" desc="The text for the button to open the printer's advanced settings dialog in the new UI.">
Advanced settings Advanced settings
</message> </message>
......
// 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.exportPath('print_preview');
/**
* Enumeration of field names for serialized app state.
* @enum {string}
*/
print_preview.AppStateField = {
VERSION: 'version',
RECENT_DESTINATIONS: 'recentDestinations',
DPI: 'dpi',
MEDIA_SIZE: 'mediaSize',
MARGINS_TYPE: 'marginsType',
CUSTOM_MARGINS: 'customMargins',
IS_COLOR_ENABLED: 'isColorEnabled',
IS_DUPLEX_ENABLED: 'isDuplexEnabled',
IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled',
IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled',
IS_COLLATE_ENABLED: 'isCollateEnabled',
IS_FIT_TO_PAGE_ENABLED: 'isFitToPageEnabled',
IS_CSS_BACKGROUND_ENABLED: 'isCssBackgroundEnabled',
SCALING: 'scaling',
VENDOR_OPTIONS: 'vendorOptions'
};
cr.define('print_preview', function() {
'use strict';
class AppState extends cr.EventTarget {
/**
* Object used to get and persist the print preview application state.
* @param {!print_preview.DestinationStore} destinationStore The destination
* store, used to track destination selection changes.
*/
constructor(destinationStore) {
super();
/**
* Internal representation of application state.
* Must contain only plain objects or classes that override the
* toJSON() method.
* @private {!Object}
*/
this.state_ = {};
this.state_[print_preview.AppStateField.VERSION] = AppState.VERSION_;
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
/**
* Whether the app state has been initialized. The app state will ignore
* all writes until it has been initialized.
* @private {boolean}
*/
this.isInitialized_ = false;
/**
* Native Layer object to use for sending app state to C++ handler.
* @private {!print_preview.NativeLayer}
*/
this.nativeLayer_ = print_preview.NativeLayer.getInstance();
/**
* Destination store object for tracking recent destinations.
* @private {!print_preview.DestinationStore}
*/
this.destinationStore_ = destinationStore;
/**
* Event tracker used to track event listeners.
* @private {!EventTracker}
*/
this.tracker_ = new EventTracker();
}
/**
* @return {?print_preview.RecentDestination} The most recent
* destination, which is currently the selected destination.
*/
get selectedDestination() {
return (this.state_[print_preview.AppStateField.RECENT_DESTINATIONS]
.length > 0) ?
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS][0] :
null;
}
/**
* @return {?Array<!print_preview.RecentDestination>} The
* AppState.NUM_DESTINATIONS_ most recent destinations.
*/
get recentDestinations() {
return this.state_[print_preview.AppStateField.RECENT_DESTINATIONS];
}
/**
* @param {!print_preview.AppStateField} field App state field to check if
* set.
* @return {boolean} Whether a field has been set in the app state.
*/
hasField(field) {
return this.state_.hasOwnProperty(field);
}
/**
* @param {!print_preview.AppStateField} field App state field to get.
* @return {?} Value of the app state field.
*/
getField(field) {
if (field == print_preview.AppStateField.CUSTOM_MARGINS) {
return this.state_[field] ?
print_preview.Margins.parse(this.state_[field]) :
null;
}
return this.state_[field];
}
/**
* Initializes the app state from a serialized string returned by the native
* layer.
* @param {?string} serializedAppStateStr Serialized string representation
* of the app state.
*/
init(serializedAppStateStr) {
if (serializedAppStateStr) {
try {
const state = JSON.parse(serializedAppStateStr);
if (!!state &&
state[print_preview.AppStateField.VERSION] == AppState.VERSION_) {
this.state_ = /** @type {!Object} */ (state);
}
} catch (e) {
console.error('Unable to parse state: ' + e);
// Proceed with default state.
}
} else {
// Set some state defaults.
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
}
if (!this.state_[print_preview.AppStateField.RECENT_DESTINATIONS]) {
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
} else if (!(this.state_[print_preview.AppStateField
.RECENT_DESTINATIONS] instanceof
Array)) {
const tmp =
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS];
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [tmp];
} else if (
!this.state_[print_preview.AppStateField.RECENT_DESTINATIONS][0] ||
!this.state_[print_preview.AppStateField.RECENT_DESTINATIONS][0].id) {
// read in incorrectly
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
} else if (
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].length >
AppState.NUM_DESTINATIONS_) {
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].length =
AppState.NUM_DESTINATIONS_;
}
}
/**
* Sets to initialized state. Now object will accept persist requests and
* monitor for destination changes.
*/
setInitialized() {
this.isInitialized_ = true;
this.tracker_.add(
this.destinationStore_,
print_preview.DestinationStore.EventType
.SELECTED_DESTINATION_CAPABILITIES_READY,
this.persistSelectedDestination_.bind(this));
this.tracker_.add(
this.destinationStore_,
print_preview.DestinationStore.EventType.DESTINATION_SELECT,
this.persistSelectedDestination_.bind(this));
}
/**
* Persists the given value for the given field.
* @param {!print_preview.AppStateField} field Field to persist.
* @param {?} value Value of field to persist.
*/
persistField(field, value) {
if (!this.isInitialized_)
return;
if (field == print_preview.AppStateField.CUSTOM_MARGINS) {
this.state_[field] = value ? value.serialize() : null;
} else {
this.state_[field] = value;
}
this.persist_();
}
/**
* Persists the selected destination from the destination store.
* @private
*/
persistSelectedDestination_() {
assert(this.isInitialized_);
const destination = this.destinationStore_.selectedDestination;
if (!destination)
return;
// Determine if this destination is already in the recent destinations,
// and where in the array it is located.
const newDestination =
print_preview.makeRecentDestination(assert(destination));
let indexFound =
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS]
.findIndex(function(recent) {
return (
newDestination.id == recent.id &&
newDestination.origin == recent.origin);
});
// No change
if (indexFound == 0 &&
this.selectedDestination.capabilities ==
newDestination.capabilities) {
this.persist_();
return;
}
// Shift the array so that the nth most recent destination is located at
// index n.
if (indexFound == -1 &&
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].length ==
AppState.NUM_DESTINATIONS_) {
indexFound = AppState.NUM_DESTINATIONS_ - 1;
}
if (indexFound != -1)
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].splice(
indexFound, 1);
// Add the most recent destination
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].splice(
0, 0, newDestination);
this.persist_();
}
/**
* Calls into the native layer to persist the application state.
* @private
*/
persist_() {
this.nativeLayer_.saveAppState(JSON.stringify(this.state_));
}
}
/**
* Number of recent print destinations to store across browser sessions.
* @const {number}
* @private
*/
AppState.NUM_DESTINATIONS_ = 3;
/**
* Current version of the app state. This value helps to understand how to
* parse earlier versions of the app state.
* @const {number}
* @private
*/
AppState.VERSION_ = 2;
return {
AppState: AppState,
};
});
// 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';
/* Mutable reference to a CDD object. */
class CapabilitiesHolder {
constructor() {
/**
* Reference to the capabilities object.
* @private {?print_preview.Cdd}
*/
this.capabilities_ = null;
}
/** @return {?print_preview.Cdd} The instance held by the holder. */
get() {
return this.capabilities_;
}
/**
* @param {!print_preview.Cdd} capabilities New instance to put into the
* holder.
*/
set(capabilities) {
this.capabilities_ = capabilities;
}
}
// Export
return {CapabilitiesHolder: CapabilitiesHolder};
});
// 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';
class PageNumberSet {
/**
* An immutable ordered set of page numbers.
* @param {!Array<number>} pageNumberList A list of page numbers to include
* in the set.
*/
constructor(pageNumberList) {
/**
* Internal data store for the page number set.
* @type {!Array<number>}
* @private
*/
this.pageNumberSet_ = pageListToPageSet(pageNumberList);
}
/** @return {number} The number of page numbers in the set. */
get size() {
return this.pageNumberSet_.length;
}
/**
* @param {number} index 0-based index of the page number to get.
* @return {number} Page number at the given index.
*/
getPageNumberAt(index) {
return this.pageNumberSet_[index];
}
/**
* @param {number} pageNumber 1-based page number to check for.
* @return {boolean} Whether the given page number is in the page range.
*/
hasPageNumber(pageNumber) {
return arrayContains(this.pageNumberSet_, pageNumber);
}
/**
* @param {number} pageNumber 1-based number of the page to get index of.
* @return {number} 0-based index of the given page number with respect to
* all of the pages in the page range.
*/
getPageNumberIndex(pageNumber) {
return this.pageNumberSet_.indexOf(pageNumber);
}
/** @return {!Array<number>} Array representation of the set. */
asArray() {
return this.pageNumberSet_.slice(0);
}
}
// Export
return {PageNumberSet: PageNumberSet};
});
// 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.ticket_items', function() {
'use strict';
class Collate extends print_preview.ticket_items.TicketItem {
/**
* Collate ticket item whose value is a {@code boolean} that indicates
* whether collation is enabled.
* @param {!print_preview.AppState} appState App state used to persist
* collate selection.
* @param {!print_preview.DestinationStore} destinationStore Destination
* store used determine if a destination has the collate capability.
*/
constructor(appState, destinationStore) {
super(
appState, print_preview.AppStateField.IS_COLLATE_ENABLED,
destinationStore);
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
return !!this.getCollateCapability_();
}
/** @override */
getDefaultValueInternal() {
const capability = this.getCollateCapability_();
return capability.hasOwnProperty('default') ? capability.default : true;
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return true;
}
/**
* @return {Object} Collate capability of the selected destination.
* @private
*/
getCollateCapability_() {
const dest = this.getSelectedDestInternal();
return (dest && dest.capabilities && dest.capabilities.printer &&
dest.capabilities.printer.collate) ||
null;
}
}
// Export
return {Collate: Collate};
});
// 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.ticket_items', function() {
'use strict';
class Color extends print_preview.ticket_items.TicketItem {
/**
* Color ticket item whose value is a {@code boolean} that indicates whether
* the document should be printed in color.
* @param {!print_preview.AppState} appState App state persistence object to
* save the state of the color selection.
* @param {!print_preview.DestinationStore} destinationStore Used to
* determine whether color printing should be available.
*/
constructor(appState, destinationStore) {
super(
appState, print_preview.AppStateField.IS_COLOR_ENABLED,
destinationStore);
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
const dest = this.getSelectedDestInternal();
return dest ? dest.hasColorCapability : false;
}
/** @override */
getDefaultValueInternal() {
const dest = this.getSelectedDestInternal();
const defaultOption = dest ? dest.defaultColorOption : null;
return defaultOption &&
(Color.COLOR_TYPES_.indexOf(defaultOption.type) >= 0);
}
/** @override */
getCapabilityNotAvailableValueInternal() {
// TODO(rltoscano): Get rid of this check based on destination ID. These
// destinations should really update their CDDs to have only one color
// option that has type 'STANDARD_COLOR'.
const dest = this.getSelectedDestInternal();
if (dest) {
if (dest.id == print_preview.Destination.GooglePromotedId.DOCS ||
dest.type == print_preview.DestinationType.MOBILE) {
return true;
}
}
return this.getDefaultValueInternal();
}
}
/**
* @private {!Array<string>} List of capability types considered color.
* @const
*/
Color.COLOR_TYPES_ = ['STANDARD_COLOR', 'CUSTOM_COLOR'];
/**
* @private {!Array<string>} List of capability types considered monochrome.
* @const
*/
Color.MONOCHROME_TYPES_ = ['STANDARD_MONOCHROME', 'CUSTOM_MONOCHROME'];
// Export
return {Color: Color};
});
// 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.ticket_items', function() {
'use strict';
class Copies extends print_preview.ticket_items.TicketItem {
/**
* Copies ticket item whose value is a {@code string} that indicates how
* many copies of the document should be printed. The ticket item is backed
* by a string since the user can textually input the copies value.
* @param {!print_preview.DestinationStore} destinationStore Destination
* store used to determine if a destination has the copies capability.
*/
constructor(destinationStore) {
super(null /*appState*/, null /*field*/, destinationStore);
}
/** @override */
wouldValueBeValid(value) {
return value != '';
}
/** @override */
isCapabilityAvailable() {
return !!this.getCopiesCapability_();
}
/** @return {number} The number of copies indicated by the ticket item. */
getValueAsNumber() {
const value = this.getValue();
return value == '' ? 0 : parseInt(value, 10);
}
/** @override */
getDefaultValueInternal() {
const cap = this.getCopiesCapability_();
return cap.hasOwnProperty('default') ? cap.default : '1';
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return '1';
}
/**
* @return {Object} Copies capability of the selected destination.
* @private
*/
getCopiesCapability_() {
const dest = this.getSelectedDestInternal();
return (dest && dest.capabilities && dest.capabilities.printer &&
dest.capabilities.printer.copies) ||
null;
}
}
// Export
return {Copies: Copies};
});
// 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.ticket_items', function() {
'use strict';
class CssBackground extends print_preview.ticket_items.TicketItem {
/**
* Ticket item whose value is a {@code boolean} that represents whether to
* print CSS backgrounds.
* @param {!print_preview.AppState} appState App state to persist CSS
* background value.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
*/
constructor(appState, documentInfo) {
super(
appState, print_preview.AppStateField.IS_CSS_BACKGROUND_ENABLED,
null /*destinationStore*/, documentInfo);
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
return this.getDocumentInfoInternal().isModifiable;
}
/** @override */
getDefaultValueInternal() {
return false;
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return false;
}
}
// Export
return {CssBackground: CssBackground};
});
// 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.ticket_items', function() {
'use strict';
const CustomMarginsOrientation =
print_preview.ticket_items.CustomMarginsOrientation;
class CustomMargins extends print_preview.ticket_items.TicketItem {
/**
* Custom page margins ticket item whose value is a
* {@code print_preview.Margins}.
* @param {!print_preview.AppState} appState App state used to persist
* custom margins.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
*/
constructor(appState, documentInfo) {
super(
appState, print_preview.AppStateField.CUSTOM_MARGINS,
null /*destinationStore*/, documentInfo);
}
/** @override */
wouldValueBeValid(value) {
const margins = /** @type {!print_preview.Margins} */ (value);
for (const key in CustomMarginsOrientation) {
const o = CustomMarginsOrientation[key];
const max = this.getMarginMax_(
o, margins.get(CustomMargins.OppositeOrientation_[o]));
if (margins.get(o) > max || margins.get(o) < 0) {
return false;
}
}
return true;
}
/** @override */
isCapabilityAvailable() {
return this.getDocumentInfoInternal().isModifiable;
}
/** @override */
isValueEqual(value) {
return this.getValue().equals(value);
}
/**
* @param {!print_preview.ticket_items.CustomMarginsOrientation}
* orientation Specifies the margin to get the maximum value for.
* @return {number} Maximum value in points of the specified margin.
*/
getMarginMax(orientation) {
const oppositeOrient = CustomMargins.OppositeOrientation_[orientation];
const margins = /** @type {!print_preview.Margins} */ (this.getValue());
return this.getMarginMax_(orientation, margins.get(oppositeOrient));
}
/** @override */
updateValue(value) {
let margins = /** @type {!print_preview.Margins} */ (value);
if (margins != null) {
margins = new print_preview.Margins(
Math.round(margins.get(CustomMarginsOrientation.TOP)),
Math.round(margins.get(CustomMarginsOrientation.RIGHT)),
Math.round(margins.get(CustomMarginsOrientation.BOTTOM)),
Math.round(margins.get(CustomMarginsOrientation.LEFT)));
}
print_preview.ticket_items.TicketItem.prototype.updateValue.call(
this, margins);
}
/**
* Updates the specified margin in points while keeping the value within
* a maximum and minimum.
* @param {!print_preview.ticket_items.CustomMarginsOrientation}
* orientation Specifies the margin to update.
* @param {number} value Updated margin value in points.
*/
updateMargin(orientation, value) {
const margins = /** @type {!print_preview.Margins} */ (this.getValue());
const oppositeOrientation =
CustomMargins.OppositeOrientation_[orientation];
const max =
this.getMarginMax_(orientation, margins.get(oppositeOrientation));
value = Math.max(0, Math.min(max, value));
this.updateValue(margins.set(orientation, value));
}
/** @override */
getDefaultValueInternal() {
return this.getDocumentInfoInternal().margins ||
new print_preview.Margins(72, 72, 72, 72);
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return this.getDocumentInfoInternal().margins ||
new print_preview.Margins(72, 72, 72, 72);
}
/**
* @param {!print_preview.ticket_items.CustomMarginsOrientation}
* orientation Specifies which margin to get the maximum value of.
* @param {number} oppositeMargin Value of the margin in points
* opposite the specified margin.
* @return {number} Maximum value in points of the specified margin.
* @private
*/
getMarginMax_(orientation, oppositeMargin) {
const dimensionLength = (orientation == CustomMarginsOrientation.TOP ||
orientation == CustomMarginsOrientation.BOTTOM) ?
this.getDocumentInfoInternal().pageSize.height :
this.getDocumentInfoInternal().pageSize.width;
const totalMargin =
dimensionLength - CustomMargins.MINIMUM_MARGINS_DISTANCE_;
return Math.round(totalMargin > 0 ? totalMargin - oppositeMargin : 0);
}
}
/**
* Mapping of a margin orientation to its opposite.
* @type {!Object<!print_preview.ticket_items.CustomMarginsOrientation,
* !print_preview.ticket_items.CustomMarginsOrientation>}
* @private
*/
CustomMargins.OppositeOrientation_ = {};
CustomMargins.OppositeOrientation_[CustomMarginsOrientation.TOP] =
CustomMarginsOrientation.BOTTOM;
CustomMargins.OppositeOrientation_[CustomMarginsOrientation.RIGHT] =
CustomMarginsOrientation.LEFT;
CustomMargins.OppositeOrientation_[CustomMarginsOrientation.BOTTOM] =
CustomMarginsOrientation.TOP;
CustomMargins.OppositeOrientation_[CustomMarginsOrientation.LEFT] =
CustomMarginsOrientation.RIGHT;
/**
* Minimum distance in points that two margins can be separated by.
* @type {number}
* @const
* @private
*/
CustomMargins.MINIMUM_MARGINS_DISTANCE_ = 72; // 1 inch.
// Export
return {CustomMargins: CustomMargins};
});
// Copyright 2014 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.ticket_items', function() {
'use strict';
class Dpi extends print_preview.ticket_items.TicketItem {
/**
* DPI ticket item.
* @param {!print_preview.AppState} appState App state used to persist DPI
* selection.
* @param {!print_preview.DestinationStore} destinationStore Destination
* store used to determine if a destination has the DPI capability.
*/
constructor(appState, destinationStore) {
super(appState, print_preview.AppStateField.DPI, destinationStore);
}
/** @override */
wouldValueBeValid(value) {
if (!this.isCapabilityAvailable())
return false;
return this.capability().option.some(function(option) {
return option.horizontal_dpi == value.horizontal_dpi &&
option.vertical_dpi == value.vertical_dpi &&
option.vendor_id == value.vendor_id;
});
}
/** @override */
isCapabilityAvailable() {
return !!this.capability() && !!this.capability().option &&
this.capability().option.length > 1;
}
/** @override */
isValueEqual(value) {
const myValue = this.getValue();
return myValue.horizontal_dpi == value.horizontal_dpi &&
myValue.vertical_dpi == value.vertical_dpi &&
myValue.vendor_id == value.vendor_id;
}
/** @return {Object} DPI capability of the selected destination. */
capability() {
const destination = this.getSelectedDestInternal();
return (destination && destination.capabilities &&
destination.capabilities.printer &&
destination.capabilities.printer.dpi) ||
null;
}
/** @override */
getDefaultValueInternal() {
const defaultOptions = this.capability().option.filter(function(option) {
return option.is_default;
});
return defaultOptions.length > 0 ? defaultOptions[0] : null;
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return {};
}
}
// Export
return {Dpi: Dpi};
});
// 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.ticket_items', function() {
'use strict';
class Duplex extends print_preview.ticket_items.TicketItem {
/**
* Duplex ticket item whose value is a {@code boolean} that indicates
* whether the document should be duplex printed.
* @param {!print_preview.AppState} appState App state used to persist
* collate selection.
* @param {!print_preview.DestinationStore} destinationStore Destination
* store used determine if a destination has the collate capability.
*/
constructor(appState, destinationStore) {
super(
appState, print_preview.AppStateField.IS_DUPLEX_ENABLED,
destinationStore);
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
const cap = this.getDuplexCapability_();
if (!cap) {
return false;
}
let hasLongEdgeOption = false;
let hasSimplexOption = false;
cap.option.forEach(function(option) {
hasLongEdgeOption = hasLongEdgeOption || option.type == 'LONG_EDGE';
hasSimplexOption = hasSimplexOption || option.type == 'NO_DUPLEX';
});
return hasLongEdgeOption && hasSimplexOption;
}
/** @override */
getDefaultValueInternal() {
const cap = this.getDuplexCapability_();
const defaultOptions = cap.option.filter(function(option) {
return option.is_default;
});
return defaultOptions.length == 0 ? false :
defaultOptions[0].type == 'LONG_EDGE';
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return false;
}
/**
* @return {Object} Duplex capability of the selected destination.
* @private
*/
getDuplexCapability_() {
const dest = this.getSelectedDestInternal();
return (dest && dest.capabilities && dest.capabilities.printer &&
dest.capabilities.printer.duplex) ||
null;
}
}
// Export
return {Duplex: Duplex};
});
// 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.ticket_items', function() {
'use strict';
class FitToPage extends print_preview.ticket_items.TicketItem {
/**
* Fit-to-page ticket item whose value is a {@code boolean} that indicates
* whether to scale the document to fit the page.
* @param {!print_preview.AppState} appState App state to persist item
* value.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
* @param {!print_preview.DestinationStore} destinationStore Used to
* determine whether fit to page should be available.
*/
constructor(appState, documentInfo, destinationStore) {
super(
appState, print_preview.AppStateField.IS_FIT_TO_PAGE_ENABLED,
destinationStore, documentInfo);
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
return !this.getDocumentInfoInternal().isModifiable &&
(!this.getSelectedDestInternal() ||
this.getSelectedDestInternal().id !=
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF);
}
/** @override */
getDefaultValueInternal() {
// It's on by default since it is not a document feature, it is rather
// a property of the printer, hardware margins limitations. User can
// always override it.
return true;
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return !this.getSelectedDestInternal() ||
this.getSelectedDestInternal().id !=
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
}
}
// Export
return {FitToPage: FitToPage};
});
// 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.ticket_items', function() {
'use strict';
class HeaderFooter extends print_preview.ticket_items.TicketItem {
/**
* Header-footer ticket item whose value is a {@code boolean} that indicates
* whether the document should be printed with headers and footers.
* @param {!print_preview.AppState} appState App state used to persist
* whether header-footer is enabled.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
* @param {!print_preview.ticket_items.MarginsType} marginsType Ticket item
* that stores which predefined margins to print with.
* @param {!print_preview.ticket_items.CustomMargins} customMargins Ticket
* item that stores custom margin values.
* @param {!print_preview.ticket_items.MediaSize} mediaSize Ticket item that
* stores media size values.
* @param {!print_preview.ticket_items.Landscape} landscape Ticket item that
* stores landscape values.
*/
constructor(
appState, documentInfo, marginsType, customMargins, mediaSize,
landscape) {
super(
appState, print_preview.AppStateField.IS_HEADER_FOOTER_ENABLED,
null /*destinationStore*/, documentInfo);
/**
* Ticket item that stores which predefined margins to print with.
* @private {!print_preview.ticket_items.MarginsType}
*/
this.marginsType_ = marginsType;
/**
* Ticket item that stores custom margin values.
* @private {!print_preview.ticket_items.CustomMargins}
*/
this.customMargins_ = customMargins;
/**
* Ticket item that stores media size values.
* @private {!print_preview.ticket_items.MediaSize}
*/
this.mediaSize_ = mediaSize;
/**
* Ticket item that stores landscape values.
* @private {!print_preview.ticket_items.Landscape}
*/
this.landscape_ = landscape;
this.addEventListeners_();
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
if (!this.getDocumentInfoInternal().isModifiable) {
return false;
}
if (this.marginsType_.getValue() ==
print_preview.ticket_items.MarginsTypeValue.NO_MARGINS) {
return false;
}
const microns = this.landscape_.getValue() ?
this.mediaSize_.getValue().width_microns :
this.mediaSize_.getValue().height_microns;
if (microns < HeaderFooter.MINIMUM_HEIGHT_MICRONS_) {
// If this is a small paper size, there is not space for headers
// and footers regardless of the margins.
return false;
}
if (this.marginsType_.getValue() ==
print_preview.ticket_items.MarginsTypeValue.MINIMUM) {
return true;
}
let margins;
if (this.marginsType_.getValue() ==
print_preview.ticket_items.MarginsTypeValue.CUSTOM) {
if (!this.customMargins_.isValid()) {
return false;
}
margins = this.customMargins_.getValue();
} else {
margins = this.getDocumentInfoInternal().margins;
}
const orientEnum = print_preview.ticket_items.CustomMarginsOrientation;
return margins == null || margins.get(orientEnum.TOP) > 0 ||
margins.get(orientEnum.BOTTOM) > 0;
}
/** @override */
getDefaultValueInternal() {
return true;
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return false;
}
/**
* Adds CHANGE listeners to dependent ticket items.
* @private
*/
addEventListeners_() {
this.getTrackerInternal().add(
this.marginsType_,
print_preview.ticket_items.TicketItem.EventType.CHANGE,
this.dispatchChangeEventInternal.bind(this));
this.getTrackerInternal().add(
this.customMargins_,
print_preview.ticket_items.TicketItem.EventType.CHANGE,
this.dispatchChangeEventInternal.bind(this));
this.getTrackerInternal().add(
this.mediaSize_,
print_preview.ticket_items.TicketItem.EventType.CHANGE,
this.dispatchChangeEventInternal.bind(this));
this.getTrackerInternal().add(
this.landscape_,
print_preview.ticket_items.TicketItem.EventType.CHANGE,
this.dispatchChangeEventInternal.bind(this));
}
}
/**
* Minimum height of page in microns to allow headers and footers. Should
* match the value for min_size_printer_units in printing/print_settings.cc
* so that we do not request header/footer for margins that will be zero.
* @private {number}
* @const
*/
HeaderFooter.MINIMUM_HEIGHT_MICRONS_ = 25400;
// Export
return {HeaderFooter: HeaderFooter};
});
// 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.ticket_items', function() {
'use strict';
class Landscape extends print_preview.ticket_items.TicketItem {
/**
* Landscape ticket item whose value is a {@code boolean} that indicates
* whether the document should be printed in landscape orientation.
* @param {!print_preview.AppState} appState App state object used to
* persist ticket item values.
* @param {!print_preview.DestinationStore} destinationStore Destination
* store used to determine the default landscape value and if landscape
* printing is available.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
* @param {!print_preview.ticket_items.MarginsType} marginsType Reset when
* landscape value changes.
* @param {!print_preview.ticket_items.CustomMargins} customMargins Reset
* when landscape value changes.
*/
constructor(
appState, destinationStore, documentInfo, marginsType, customMargins) {
super(
appState, print_preview.AppStateField.IS_LANDSCAPE_ENABLED,
destinationStore, documentInfo);
/**
* Margins ticket item. Reset when landscape ticket item changes.
* @type {!print_preview.ticket_items.MarginsType}
* @private
*/
this.marginsType_ = marginsType;
/**
* Custom margins ticket item. Reset when landscape ticket item changes.
* @type {!print_preview.ticket_items.CustomMargins}
* @private
*/
this.customMargins_ = customMargins;
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
const cap = this.getPageOrientationCapability_();
if (!cap)
return false;
let hasAutoOrPortraitOption = false;
let hasLandscapeOption = false;
cap.option.forEach(function(option) {
hasAutoOrPortraitOption = hasAutoOrPortraitOption ||
option.type == 'AUTO' || option.type == 'PORTRAIT';
hasLandscapeOption = hasLandscapeOption || option.type == 'LANDSCAPE';
});
// TODO(rltoscano): Technically, the print destination can still change
// the orientation of the print out (at least for cloud printers) if the
// document is not modifiable. But the preview wouldn't update in this
// case so it would be a bad user experience.
return this.getDocumentInfoInternal().isModifiable &&
!this.getDocumentInfoInternal().hasCssMediaStyles &&
hasAutoOrPortraitOption && hasLandscapeOption;
}
/** @override */
getDefaultValueInternal() {
const cap = this.getPageOrientationCapability_();
const defaultOptions = cap.option.filter(function(option) {
return option.is_default;
});
return defaultOptions.length == 0 ? false :
defaultOptions[0].type == 'LANDSCAPE';
}
/** @override */
getCapabilityNotAvailableValueInternal() {
const doc = this.getDocumentInfoInternal();
return doc.hasCssMediaStyles ?
(doc.pageSize.width > doc.pageSize.height) :
false;
}
/** @override */
updateValueInternal(value) {
const updateMargins = !this.isValueEqual(value);
print_preview.ticket_items.TicketItem.prototype.updateValueInternal.call(
this, value);
if (updateMargins) {
// Reset the user set margins when page orientation changes.
this.marginsType_.updateValue(
print_preview.ticket_items.MarginsTypeValue.DEFAULT);
this.customMargins_.updateValue(null);
}
}
/**
* @return {boolean} Whether capability contains the |value|.
* @param {string} value Option to check.
*/
hasOption(value) {
const cap = this.getPageOrientationCapability_();
if (!cap)
return false;
return cap.option.some(function(option) {
return option.type == value;
});
}
/**
* @return {Object} Page orientation capability of the selected destination.
* @private
*/
getPageOrientationCapability_() {
const dest = this.getSelectedDestInternal();
return (dest && dest.capabilities && dest.capabilities.printer &&
dest.capabilities.printer.page_orientation) ||
null;
}
}
// Export
return {Landscape: Landscape};
});
// 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.ticket_items', function() {
'use strict';
class MarginsType extends print_preview.ticket_items.TicketItem {
/**
* Margins type ticket item whose value is a
* print_preview.ticket_items.MarginsTypeValue} that indicates what
* predefined margins type to use.
* @param {!print_preview.AppState} appState App state persistence object to
* save the state of the margins type selection.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
* @param {!print_preview.ticket_items.CustomMargins} customMargins Custom
* margins ticket item, used to write when margins type changes.
*/
constructor(appState, documentInfo, customMargins) {
super(
appState, print_preview.AppStateField.MARGINS_TYPE,
null /*destinationStore*/, documentInfo);
/**
* Custom margins ticket item, used to write when margins type changes.
* @type {!print_preview.ticket_items.CustomMargins}
* @private
*/
this.customMargins_ = customMargins;
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
return this.getDocumentInfoInternal().isModifiable;
}
/** @override */
getDefaultValueInternal() {
return print_preview.ticket_items.MarginsTypeValue.DEFAULT;
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return print_preview.ticket_items.MarginsTypeValue.DEFAULT;
}
/** @override */
updateValueInternal(value) {
print_preview.ticket_items.TicketItem.prototype.updateValueInternal.call(
this, value);
if (this.isValueEqual(
print_preview.ticket_items.MarginsTypeValue.CUSTOM)) {
// If CUSTOM, set the value of the custom margins so that it won't be
// overridden by the default value.
this.customMargins_.updateValue(this.customMargins_.getValue());
}
}
}
// Export
return {MarginsType: MarginsType};
});
// Copyright 2014 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.ticket_items', function() {
'use strict';
class MediaSize extends print_preview.ticket_items.TicketItem {
/**
* Media size ticket item.
* @param {!print_preview.AppState} appState App state used to persist media
* size selection.
* @param {!print_preview.DestinationStore} destinationStore Destination
* store used to determine if a destination has the media size
* capability.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
* @param {!print_preview.ticket_items.MarginsType} marginsType Reset when
* landscape value changes.
* @param {!print_preview.ticket_items.CustomMargins} customMargins Reset
* when landscape value changes.
*/
constructor(
appState, destinationStore, documentInfo, marginsType, customMargins) {
super(
appState, print_preview.AppStateField.MEDIA_SIZE, destinationStore,
documentInfo);
/**
* Margins ticket item. Reset when this item changes.
* @private {!print_preview.ticket_items.MarginsType}
*/
this.marginsType_ = marginsType;
/**
* Custom margins ticket item. Reset when this item changes.
* @private {!print_preview.ticket_items.CustomMargins}
*/
this.customMargins_ = customMargins;
}
/** @override */
wouldValueBeValid(value) {
if (!this.isCapabilityAvailable()) {
return false;
}
return this.capability().option.some(function(option) {
return option.width_microns == value.width_microns &&
option.height_microns == value.height_microns &&
option.is_continuous_feed == value.is_continuous_feed &&
option.vendor_id == value.vendor_id;
});
}
/** @override */
isCapabilityAvailable() {
const knownSizeToSaveAsPdf =
(!this.getDocumentInfoInternal().isModifiable ||
this.getDocumentInfoInternal().hasCssMediaStyles) &&
this.getSelectedDestInternal() &&
this.getSelectedDestInternal().id ==
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
return !knownSizeToSaveAsPdf && !!this.capability();
}
/** @override */
isValueEqual(value) {
const myValue = this.getValue();
return myValue.width_microns == value.width_microns &&
myValue.height_microns == value.height_microns &&
myValue.is_continuous_feed == value.is_continuous_feed &&
myValue.vendor_id == value.vendor_id;
}
/** @return {Object} Media size capability of the selected destination. */
capability() {
const destination = this.getSelectedDestInternal();
return (destination && destination.capabilities &&
destination.capabilities.printer &&
destination.capabilities.printer.media_size) ||
null;
}
/** @override */
getDefaultValueInternal() {
const defaultOptions = this.capability().option.filter(function(option) {
return option.is_default;
});
return defaultOptions.length > 0 ? defaultOptions[0] : null;
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return {};
}
/** @override */
updateValueInternal(value) {
const updateMargins = !this.isValueEqual(value);
print_preview.ticket_items.TicketItem.prototype.updateValueInternal.call(
this, value);
if (updateMargins) {
// Reset the user set margins when media size changes.
this.marginsType_.updateValue(
print_preview.ticket_items.MarginsTypeValue.DEFAULT);
this.customMargins_.updateValue(null);
}
}
}
// Export
return {MediaSize: MediaSize};
});
// 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.ticket_items', function() {
'use strict';
class PageRange extends print_preview.ticket_items.TicketItem {
/**
* Page range ticket item whose value is a {@code string} that represents
* which pages in the document should be printed.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
*/
constructor(documentInfo) {
super(
null /*appState*/, null /*field*/, null /*destinationStore*/,
documentInfo);
}
/** @override */
wouldValueBeValid(value) {
const result = pageRangeTextToPageRanges(
value, this.getDocumentInfoInternal().pageCount);
return Array.isArray(result);
}
/**
* @return {!print_preview.PageNumberSet} Set of page numbers defined by the
* page range string.
*/
getPageNumberSet() {
const pageNumberList = pageRangeTextToPageList(
this.getValueAsString_(), this.getDocumentInfoInternal().pageCount);
return new print_preview.PageNumberSet(pageNumberList);
}
/** @override */
isCapabilityAvailable() {
return true;
}
/** @override */
getDefaultValueInternal() {
return '';
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return '';
}
/**
* @return {string} The value of the ticket item as a string.
* @private
*/
getValueAsString_() {
return /** @type {string} */ (this.getValue());
}
/**
* @return {!Array<Object<{from: number, to: number}>>} A list of page
* ranges.
*/
getPageRanges() {
const pageRanges = pageRangeTextToPageRanges(this.getValueAsString_());
return Array.isArray(pageRanges) ? pageRanges : [];
}
/**
* @return {!Array<Object<{from: number, to: number}>>} A list of page
* ranges suitable for use in the native layer.
* TODO(vitalybuka): this should be removed when native layer switched to
* page ranges.
*/
getDocumentPageRanges() {
const pageRanges = pageRangeTextToPageRanges(
this.getValueAsString_(), this.getDocumentInfoInternal().pageCount);
return Array.isArray(pageRanges) ? pageRanges : [];
}
/**
* @return {!number} Number of pages reported by the document.
*/
getDocumentNumPages() {
return this.getDocumentInfoInternal().pageCount;
}
/**
* @return {!PageRangeStatus}
*/
checkValidity() {
const pageRanges = pageRangeTextToPageRanges(
this.getValueAsString_(), this.getDocumentInfoInternal().pageCount);
return Array.isArray(pageRanges) ? PageRangeStatus.NO_ERROR : pageRanges;
}
}
/**
* Impossibly large page number.
* @type {number}
* @const
* @private
*/
PageRange.MAX_PAGE_NUMBER_ = 1000000000;
// Export
return {PageRange: PageRange};
});
// Copyright (c) 2016 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.ticket_items', function() {
'use strict';
class Rasterize extends print_preview.ticket_items.TicketItem {
/**
* Rasterize ticket item whose value is a {@code boolean} that indicates
* whether the PDF document should be rendered as images.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print, used to determine if document is a PDF.
*/
constructor(destinationStore, documentInfo) {
super(
null /* appState */, null /* field */, null /* destinationStore */,
documentInfo);
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
return !this.getDocumentInfoInternal().isModifiable;
}
/** @override */
getDefaultValueInternal() {
return false;
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return this.getDefaultValueInternal();
}
}
// Export
return {Rasterize: Rasterize};
});
// Copyright (c) 2016 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.ticket_items', function() {
'use strict';
class Scaling extends print_preview.ticket_items.TicketItem {
/**
* Scaling ticket item whose value is a {@code string} that indicates what
* the scaling (in percent) of the document should be. The ticket item is
* backed by a string since the user can textually input the scaling value.
* @param {!print_preview.AppState} appState App state to persist item
* value.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
* @param {!print_preview.DestinationStore} destinationStore Used to
* determine whether scaling should be available.
*/
constructor(appState, destinationStore, documentInfo) {
super(
appState, print_preview.AppStateField.SCALING, destinationStore,
documentInfo);
}
/** @override */
wouldValueBeValid(value) {
return value != '';
}
/** @override */
isValueEqual(value) {
return this.getValue() == value;
}
/** @override */
isCapabilityAvailable() {
// This is not a function of the printer, but should be disabled if we are
// saving a PDF to a PDF.
const knownSizeToSaveAsPdf =
(!this.getDocumentInfoInternal().isModifiable ||
this.getDocumentInfoInternal().hasCssMediaStyles) &&
this.getSelectedDestInternal() &&
this.getSelectedDestInternal().id ==
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
return !knownSizeToSaveAsPdf;
}
/** @return {number} The scaling percentage indicated by the ticket item. */
getValueAsNumber() {
const value = this.getValue() == '' ? 0 : parseInt(this.getValue(), 10);
assert(!isNaN(value));
return value;
}
/** @override */
getDefaultValueInternal() {
return '100';
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return '100';
}
}
// Export
return {Scaling: Scaling};
});
// 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.ticket_items', function() {
'use strict';
class SelectionOnly extends print_preview.ticket_items.TicketItem {
/**
* Ticket item whose value is a {@code boolean} that represents whether to
* print selection only.
* @param {!print_preview.DocumentInfo} documentInfo Information about the
* document to print.
*/
constructor(documentInfo) {
super(
null /*appState*/, null /*field*/, null /*destinationStore*/,
documentInfo);
}
/** @override */
wouldValueBeValid(value) {
return true;
}
/** @override */
isCapabilityAvailable() {
return this.getDocumentInfoInternal().isModifiable &&
this.getDocumentInfoInternal().hasSelection;
}
/** @override */
getDefaultValueInternal() {
return false;
}
/** @override */
getCapabilityNotAvailableValueInternal() {
return false;
}
}
// Export
return {SelectionOnly: SelectionOnly};
});
// 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.
/**
* @typedef {Object|number|boolean|string}
*/
print_preview.ValueType;
cr.define('print_preview.ticket_items', function() {
'use strict';
class TicketItem extends cr.EventTarget {
/**
* An object that represents a user modifiable item in a print ticket. Each
* ticket item has a value which can be set by the user. Ticket items can
* also be unavailable for modifying if the print destination doesn't
* support it or if other ticket item constraints are not met.
* @param {?print_preview.AppState} appState Application state model to
* update
* when ticket items update.
* @param {?print_preview.AppStateField} field Field of the app state to
* update when ticket item is updated.
* @param {?print_preview.DestinationStore} destinationStore Used listen for
* changes in the currently selected destination's capabilities. Since
* this is a common dependency of ticket items, it's handled in the base
* class.
* @param {?print_preview.DocumentInfo=} opt_documentInfo Used to listen for
* changes in the document. Since this is a common dependency of ticket
* items, it's handled in the base class.
*/
constructor(appState, field, destinationStore, opt_documentInfo) {
super();
/**
* Application state model to update when ticket items update.
* @type {print_preview.AppState}
* @private
*/
this.appState_ = appState || null;
/**
* Field of the app state to update when ticket item is updated.
* @type {?print_preview.AppStateField}
* @private
*/
this.field_ = field || null;
/**
* Used listen for changes in the currently selected destination's
* capabilities.
* @type {print_preview.DestinationStore}
* @private
*/
this.destinationStore_ = destinationStore || null;
/**
* Used to listen for changes in the document.
* @type {print_preview.DocumentInfo}
* @private
*/
this.documentInfo_ = opt_documentInfo || null;
/**
* Backing store of the print ticket item.
* @type {Object}
* @private
*/
this.value_ = null;
/**
* Keeps track of event listeners for the ticket item.
* @type {!EventTracker}
* @private
*/
this.tracker_ = new EventTracker();
this.addEventHandlers_();
}
/**
* Determines whether a given value is valid for the ticket item.
* @param {?} value The value to check for validity.
* @return {boolean} Whether the given value is valid for the ticket item.
*/
wouldValueBeValid(value) {
throw Error('Abstract method not overridden');
}
/**
* @return {boolean} Whether the print destination capability is available.
*/
isCapabilityAvailable() {
throw Error('Abstract method not overridden');
}
/** @return {print_preview.ValueType} The value of the ticket item. */
getValue() {
if (!this.isCapabilityAvailable()) {
return this.getCapabilityNotAvailableValueInternal();
}
if (this.value_ == null) {
return this.getDefaultValueInternal();
}
return this.value_;
}
/** @return {boolean} Whether the ticket item was modified by the user. */
isUserEdited() {
return this.value_ != null;
}
/** @return {boolean} Whether the ticket item's value is valid. */
isValid() {
if (!this.isUserEdited()) {
return true;
}
return this.wouldValueBeValid(this.value_);
}
/**
* @param {?} value Value to compare to the value of this ticket item.
* @return {boolean} Whether the given value is equal to the value of the
* ticket item.
*/
isValueEqual(value) {
return this.getValue() == value;
}
/**
* @param {?} value Value to set as the value of the ticket item.
*/
updateValue(value) {
// Use comparison with capabilities for event.
const sendUpdateEvent = !this.isValueEqual(value);
// Don't lose requested value if capability is not available.
this.updateValueInternal(value);
if (this.appState_ && (this.field_ != null) &&
(this.field_ != print_preview.AppStateField.SCALING ||
this.wouldValueBeValid(value))) {
this.appState_.persistField(this.field_, value);
}
if (sendUpdateEvent)
cr.dispatchSimpleEvent(this, TicketItem.EventType.CHANGE);
}
/**
* @return {?} Default value of the ticket item if no value was set by
* the user.
* @protected
*/
getDefaultValueInternal() {
throw Error('Abstract method not overridden');
}
/**
* @return {?} Default value of the ticket item if the capability is
* not available.
* @protected
*/
getCapabilityNotAvailableValueInternal() {
throw Error('Abstract method not overridden');
}
/**
* @return {!EventTracker} Event tracker to keep track of events from
* dependencies.
* @protected
*/
getTrackerInternal() {
return this.tracker_;
}
/**
* @return {print_preview.Destination} Selected destination from the
* destination store, or {@code null} if no destination is selected.
* @protected
*/
getSelectedDestInternal() {
return this.destinationStore_ ?
this.destinationStore_.selectedDestination :
null;
}
/**
* @return {print_preview.DocumentInfo} Document data model.
* @protected
*/
getDocumentInfoInternal() {
return this.documentInfo_;
}
/**
* Dispatches a CHANGE event.
* @protected
*/
dispatchChangeEventInternal() {
cr.dispatchSimpleEvent(
this, print_preview.ticket_items.TicketItem.EventType.CHANGE);
}
/**
* Updates the value of the ticket item without dispatching any events or
* persisting the value.
* @protected
*/
updateValueInternal(value) {
this.value_ = value;
}
/**
* Adds event handlers for this class.
* @private
*/
addEventHandlers_() {
if (this.destinationStore_) {
this.tracker_.add(
this.destinationStore_,
print_preview.DestinationStore.EventType
.SELECTED_DESTINATION_CAPABILITIES_READY,
this.dispatchChangeEventInternal.bind(this));
}
if (this.documentInfo_) {
this.tracker_.add(
this.documentInfo_, print_preview.DocumentInfo.EventType.CHANGE,
this.dispatchChangeEventInternal.bind(this));
}
}
}
/**
* Event types dispatched by this class.
* @enum {string}
*/
TicketItem.EventType = {
CHANGE: 'print_preview.ticket_items.TicketItem.CHANGE'
};
// Export
return {TicketItem: TicketItem};
});
// Copyright 2014 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.ticket_items', function() {
'use strict';
class VendorItems extends cr.EventTarget {
/**
* An object that represents a user modifiable item in a print ticket. Each
* ticket item has a value which can be set by the user. Ticket items can
* also be unavailable for modifying if the print destination doesn't
* support it or if other ticket item constraints are not met.
* @param {print_preview.AppState} appState Application state model to
* update when ticket items update.
* @param {print_preview.DestinationStore} destinationStore Used listen for
* changes in the currently selected destination's capabilities. Since
* this is a common dependency of ticket items, it's handled in the
* base class.
*/
constructor(appState, destinationStore) {
super();
/**
* Application state model to update when ticket items update.
* @private {print_preview.AppState}
*/
this.appState_ = appState || null;
/**
* Used listen for changes in the currently selected destination's
* capabilities.
* @private {print_preview.DestinationStore}
*/
this.destinationStore_ = destinationStore || null;
/**
* Vendor ticket items store, maps item id to the item value.
* @private {!Object<string>}
*/
this.items_ = {};
}
/** @return {boolean} Whether vendor capabilities are available. */
isCapabilityAvailable() {
return !!this.capability;
}
/** @return {boolean} Whether the ticket item was modified by the user. */
isUserEdited() {
// If there's at least one ticket item stored in values, it was edited.
for (const key in this.items_) {
if (this.items_.hasOwnProperty(key))
return true;
}
return false;
}
/** @return {Object} Vendor capabilities of the selected destination. */
get capability() {
const destination = this.destinationStore_ ?
this.destinationStore_.selectedDestination :
null;
if (!destination)
return null;
if (destination.type == print_preview.DestinationType.MOBILE) {
return null;
}
return (destination.capabilities && destination.capabilities.printer &&
destination.capabilities.printer.vendor_capability) ||
null;
}
/**
* Vendor ticket items store, maps item id to the item value.
* @return {!Object<string>}
*/
get ticketItems() {
return this.items_;
}
/**
* @param {!Object<string>} values Values to set as the values of vendor
* ticket items. Maps vendor item id to the value.
*/
updateValue(values) {
this.items_ = {};
if (typeof values == 'object') {
for (const key in values) {
if (values.hasOwnProperty(key) && typeof values[key] == 'string') {
// Let's empirically limit each value at 2K.
this.items_[key] = values[key].substring(0, 2048);
}
}
}
if (this.appState_) {
this.appState_.persistField(
print_preview.AppStateField.VENDOR_OPTIONS, this.items_);
}
}
}
// Export
return {VendorItems: VendorItems};
});
...@@ -269,23 +269,6 @@ cr.define('print_preview', function() { ...@@ -269,23 +269,6 @@ cr.define('print_preview', function() {
return cr.sendWithPromise('signIn', addAccount); return cr.sendWithPromise('signIn', addAccount);
} }
/**
* Navigates the user to the Chrome printing setting page to manage local
* printers and Google cloud printers.
* TODO (rbpotter): Delete this when the old Print Preview page is removed.
*/
managePrinters() {
chrome.send('managePrinters');
}
/**
* Forces browser to open a new tab with the given URL address.
* TODO (rbpotter): Delete this when the old Print Preview page is removed.
*/
forceOpenNewTab(url) {
chrome.send('forceOpenNewTab', [url]);
}
/** /**
* Sends a message to the test, letting it know that an * Sends a message to the test, letting it know that an
* option has been set to a particular value and that the change has * option has been set to a particular value and that the change has
......
...@@ -593,10 +593,6 @@ void PrintPreviewHandler::RegisterMessages() { ...@@ -593,10 +593,6 @@ void PrintPreviewHandler::RegisterMessages() {
"getAccessToken", "getAccessToken",
base::BindRepeating(&PrintPreviewHandler::HandleGetAccessToken, base::BindRepeating(&PrintPreviewHandler::HandleGetAccessToken,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"managePrinters",
base::BindRepeating(&PrintPreviewHandler::HandleManagePrinters,
base::Unretained(this)));
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
"closePrintPreviewDialog", "closePrintPreviewDialog",
base::BindRepeating(&PrintPreviewHandler::HandleClosePreviewDialog, base::BindRepeating(&PrintPreviewHandler::HandleClosePreviewDialog,
...@@ -617,10 +613,6 @@ void PrintPreviewHandler::RegisterMessages() { ...@@ -617,10 +613,6 @@ void PrintPreviewHandler::RegisterMessages() {
"getInitialSettings", "getInitialSettings",
base::BindRepeating(&PrintPreviewHandler::HandleGetInitialSettings, base::BindRepeating(&PrintPreviewHandler::HandleGetInitialSettings,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"forceOpenNewTab",
base::BindRepeating(&PrintPreviewHandler::HandleForceOpenNewTab,
base::Unretained(this)));
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
"grantExtensionPrinterAccess", "grantExtensionPrinterAccess",
base::BindRepeating( base::BindRepeating(
...@@ -979,16 +971,6 @@ void PrintPreviewHandler::HandleGetAccessToken(const base::ListValue* args) { ...@@ -979,16 +971,6 @@ void PrintPreviewHandler::HandleGetAccessToken(const base::ListValue* args) {
token_service_->RequestToken(type, callback_id); token_service_->RequestToken(type, callback_id);
} }
// TODO(rbpotter): Remove this when the old Print Preview page is deleted.
void PrintPreviewHandler::HandleManagePrinters(const base::ListValue* args) {
GURL local_printers_manage_url(
chrome::GetSettingsUrl(chrome::kPrintingSettingsSubPage));
preview_web_contents()->OpenURL(
content::OpenURLParams(local_printers_manage_url, content::Referrer(),
WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui::PAGE_TRANSITION_LINK, false));
}
#if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) #if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG)
void PrintPreviewHandler::HandleShowSystemDialog( void PrintPreviewHandler::HandleShowSystemDialog(
const base::ListValue* /*args*/) { const base::ListValue* /*args*/) {
...@@ -1054,19 +1036,6 @@ void PrintPreviewHandler::HandleGetInitialSettings( ...@@ -1054,19 +1036,6 @@ void PrintPreviewHandler::HandleGetInitialSettings(
weak_factory_.GetWeakPtr(), callback_id)); weak_factory_.GetWeakPtr(), callback_id));
} }
// TODO(rbpotter): Remove this when the old Print Preview page is deleted.
void PrintPreviewHandler::HandleForceOpenNewTab(const base::ListValue* args) {
std::string url;
if (!args->GetString(0, &url))
return;
Browser* browser = chrome::FindBrowserWithWebContents(GetInitiator());
if (!browser)
return;
chrome::AddSelectedTabWithURL(browser,
GURL(url),
ui::PAGE_TRANSITION_LINK);
}
void PrintPreviewHandler::SendInitialSettings( void PrintPreviewHandler::SendInitialSettings(
const std::string& callback_id, const std::string& callback_id,
const std::string& default_printer) { const std::string& default_printer) {
......
...@@ -227,11 +227,6 @@ class PrintPreviewHandler ...@@ -227,11 +227,6 @@ class PrintPreviewHandler
// Generates new token and sends back to UI. // Generates new token and sends back to UI.
void HandleGetAccessToken(const base::ListValue* args); void HandleGetAccessToken(const base::ListValue* args);
// Brings up Chrome printing setting page to allow the user to configure local
// printers or Google Cloud printers. |args| is unused.
// TODO (rbpotter): Remove this when the old Print Preview page is deleted.
void HandleManagePrinters(const base::ListValue* args);
// Gathers UMA stats when the print preview dialog is about to close. // Gathers UMA stats when the print preview dialog is about to close.
// |args| is unused. // |args| is unused.
void HandleClosePreviewDialog(const base::ListValue* args); void HandleClosePreviewDialog(const base::ListValue* args);
...@@ -240,16 +235,6 @@ class PrintPreviewHandler ...@@ -240,16 +235,6 @@ class PrintPreviewHandler
// preview is displayed. // preview is displayed.
void HandleGetInitialSettings(const base::ListValue* args); void HandleGetInitialSettings(const base::ListValue* args);
// Forces the opening of a new tab. |args| should consist of one element: the
// URL to set the new tab to.
//
// NOTE: This is needed to open register promo for Cloud Print as a new tab.
// Javascript's "window.open" opens a new window popup (since initiated from
// async HTTP request) and worse yet, on Windows and Chrome OS, the opened
// window opens behind the initiator window.
// TODO(rbpotter): Remove this when the old Print Preview page is deleted.
void HandleForceOpenNewTab(const base::ListValue* args);
void SendInitialSettings(const std::string& callback_id, void SendInitialSettings(const std::string& callback_id,
const std::string& default_printer); const std::string& default_printer);
......
...@@ -179,8 +179,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { ...@@ -179,8 +179,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
source->AddLocalizedString("learnMore", IDS_LEARN_MORE); source->AddLocalizedString("learnMore", IDS_LEARN_MORE);
source->AddLocalizedString("loading", IDS_PRINT_PREVIEW_LOADING); source->AddLocalizedString("loading", IDS_PRINT_PREVIEW_LOADING);
source->AddLocalizedString("noPlugin", IDS_PRINT_PREVIEW_NO_PLUGIN); source->AddLocalizedString("noPlugin", IDS_PRINT_PREVIEW_NO_PLUGIN);
source->AddLocalizedString("launchNativeDialog",
IDS_PRINT_PREVIEW_NATIVE_DIALOG);
source->AddLocalizedString("previewFailed", IDS_PRINT_PREVIEW_FAILED); source->AddLocalizedString("previewFailed", IDS_PRINT_PREVIEW_FAILED);
source->AddLocalizedString("invalidPrinterSettings", source->AddLocalizedString("invalidPrinterSettings",
IDS_PRINT_INVALID_PRINTER_SETTINGS); IDS_PRINT_INVALID_PRINTER_SETTINGS);
...@@ -217,8 +215,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { ...@@ -217,8 +215,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
source->AddLocalizedString("printToPDF", IDS_PRINT_PREVIEW_PRINT_TO_PDF); source->AddLocalizedString("printToPDF", IDS_PRINT_PREVIEW_PRINT_TO_PDF);
source->AddLocalizedString("printPreviewSummaryFormatShort", source->AddLocalizedString("printPreviewSummaryFormatShort",
IDS_PRINT_PREVIEW_SUMMARY_FORMAT_SHORT); IDS_PRINT_PREVIEW_SUMMARY_FORMAT_SHORT);
source->AddLocalizedString("printPreviewSummaryFormatLong",
IDS_PRINT_PREVIEW_SUMMARY_FORMAT_LONG);
source->AddLocalizedString("printPreviewSheetsLabelSingular", source->AddLocalizedString("printPreviewSheetsLabelSingular",
IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR); IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR);
source->AddLocalizedString("printPreviewSheetsLabelPlural", source->AddLocalizedString("printPreviewSheetsLabelPlural",
...@@ -245,8 +241,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { ...@@ -245,8 +241,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
chrome::GetSettingsUrl(chrome::kPrintingSettingsSubPage).spec()); chrome::GetSettingsUrl(chrome::kPrintingSettingsSubPage).spec());
source->AddString("gcpCertificateErrorLearnMoreURL", source->AddString("gcpCertificateErrorLearnMoreURL",
chrome::kCloudPrintCertificateErrorLearnMoreURL); chrome::kCloudPrintCertificateErrorLearnMoreURL);
source->AddLocalizedString("pageRangeLimitInstruction",
IDS_PRINT_PREVIEW_PAGE_RANGE_LIMIT_INSTRUCTION);
source->AddLocalizedString( source->AddLocalizedString(
"pageRangeLimitInstructionWithValue", "pageRangeLimitInstructionWithValue",
IDS_PRINT_PREVIEW_PAGE_RANGE_LIMIT_INSTRUCTION_WITH_VALUE); IDS_PRINT_PREVIEW_PAGE_RANGE_LIMIT_INSTRUCTION_WITH_VALUE);
...@@ -299,8 +293,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { ...@@ -299,8 +293,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
IDS_PRINT_PREVIEW_SEARCH_BOX_PLACEHOLDER); IDS_PRINT_PREVIEW_SEARCH_BOX_PLACEHOLDER);
source->AddLocalizedString("noDestinationsMessage", source->AddLocalizedString("noDestinationsMessage",
IDS_PRINT_PREVIEW_NO_DESTINATIONS_MESSAGE); IDS_PRINT_PREVIEW_NO_DESTINATIONS_MESSAGE);
source->AddLocalizedString("showAllButtonText",
IDS_PRINT_PREVIEW_SHOW_ALL_BUTTON_TEXT);
source->AddLocalizedString("destinationCount", source->AddLocalizedString("destinationCount",
IDS_PRINT_PREVIEW_DESTINATION_COUNT); IDS_PRINT_PREVIEW_DESTINATION_COUNT);
source->AddLocalizedString("recentDestinationsTitle", source->AddLocalizedString("recentDestinationsTitle",
...@@ -323,8 +315,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { ...@@ -323,8 +315,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
IDS_PRINT_PREVIEW_NO_LONGER_SUPPORTED); IDS_PRINT_PREVIEW_NO_LONGER_SUPPORTED);
source->AddLocalizedString("couldNotPrint", source->AddLocalizedString("couldNotPrint",
IDS_PRINT_PREVIEW_COULD_NOT_PRINT); IDS_PRINT_PREVIEW_COULD_NOT_PRINT);
source->AddLocalizedString("registerPromoButtonText",
IDS_PRINT_PREVIEW_REGISTER_PROMO_BUTTON_TEXT);
source->AddLocalizedString( source->AddLocalizedString(
"extensionDestinationIconTooltip", "extensionDestinationIconTooltip",
IDS_PRINT_PREVIEW_EXTENSION_DESTINATION_ICON_TOOLTIP); IDS_PRINT_PREVIEW_EXTENSION_DESTINATION_ICON_TOOLTIP);
...@@ -340,10 +330,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { ...@@ -340,10 +330,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
"advancedSettingsDialogConfirm", "advancedSettingsDialogConfirm",
IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_DIALOG_CONFIRM); IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_DIALOG_CONFIRM);
source->AddLocalizedString("cancel", IDS_CANCEL); source->AddLocalizedString("cancel", IDS_CANCEL);
source->AddLocalizedString("advancedOptionsLabel",
IDS_PRINT_PREVIEW_ADVANCED_OPTIONS_LABEL);
source->AddLocalizedString("showAdvancedOptions",
IDS_PRINT_PREVIEW_SHOW_ADVANCED_OPTIONS);
source->AddLocalizedString("newShowAdvancedOptions", source->AddLocalizedString("newShowAdvancedOptions",
IDS_PRINT_PREVIEW_NEW_SHOW_ADVANCED_OPTIONS); IDS_PRINT_PREVIEW_NEW_SHOW_ADVANCED_OPTIONS);
...@@ -358,7 +344,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { ...@@ -358,7 +344,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
source->AddLocalizedString("registerPrinterInformationMessage", source->AddLocalizedString("registerPrinterInformationMessage",
IDS_CLOUD_PRINT_REGISTER_PRINTER_INFORMATION); IDS_CLOUD_PRINT_REGISTER_PRINTER_INFORMATION);
source->AddLocalizedString("moreOptionsLabel", IDS_MORE_OPTIONS_LABEL); source->AddLocalizedString("moreOptionsLabel", IDS_MORE_OPTIONS_LABEL);
source->AddLocalizedString("lessOptionsLabel", IDS_LESS_OPTIONS_LABEL);
source->AddLocalizedString("managedOption", source->AddLocalizedString("managedOption",
IDS_PRINT_PREVIEW_MANAGED_OPTION_TEXT); IDS_PRINT_PREVIEW_MANAGED_OPTION_TEXT);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment