Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Unified Diff: chrome/browser/resources/print_preview/data/destination_store.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/data/destination_store.js
diff --git a/chrome/browser/resources/print_preview/data/destination_store.js b/chrome/browser/resources/print_preview/data/destination_store.js
index dafd6553b237f3a68c0e279e159bd63c44167ed7..ab025a60f8ccdc13bded32562b83aa47bfc24982 100644
--- a/chrome/browser/resources/print_preview/data/destination_store.js
+++ b/chrome/browser/resources/print_preview/data/destination_store.js
@@ -18,7 +18,6 @@ cr.define('print_preview', function() {
*/
function DestinationMatch(
origins, idRegExp, displayNameRegExp, skipVirtualDestinations) {
-
/** @private {!Array<!print_preview.Destination.Origin>} */
this.origins_ = origins;
@@ -48,9 +47,8 @@ cr.define('print_preview', function() {
* @return {boolean} Whether destination is the same as initial.
*/
matchIdAndOrigin: function(id, origin) {
- return this.matchOrigin(origin) &&
- this.idRegExp_ &&
- this.idRegExp_.test(id);
+ return this.matchOrigin(origin) && this.idRegExp_ &&
+ this.idRegExp_.test(id);
},
/**
@@ -89,8 +87,10 @@ cr.define('print_preview', function() {
destination.id);
}
return arrayContains(
- [print_preview.Destination.GooglePromotedId.DOCS,
- print_preview.Destination.GooglePromotedId.FEDEX],
+ [
+ print_preview.Destination.GooglePromotedId.DOCS,
+ print_preview.Destination.GooglePromotedId.FEDEX
+ ],
destination.id);
}
};
@@ -519,10 +519,8 @@ cr.define('print_preview', function() {
for (var i = 0, media; media = mediaSize.option[i]; i++) {
// No need to patch capabilities with localized names provided.
if (!media.custom_display_name_localized) {
- media.custom_display_name =
- media.custom_display_name ||
- DestinationStore.MEDIA_DISPLAY_NAMES_[media.name] ||
- media.name;
+ media.custom_display_name = media.custom_display_name ||
+ DestinationStore.MEDIA_DISPLAY_NAMES_[media.name] || media.name;
}
}
return capabilities;
@@ -574,9 +572,10 @@ cr.define('print_preview', function() {
var category;
if (name.startsWith('NA_')) {
category = categoryStandardNA;
- } else if (name.startsWith('PRC_') || name.startsWith('ROC_') ||
- name == 'OM_DAI_PA_KAI' || name == 'OM_JUURO_KU_KAI' ||
- name == 'OM_PA_KAI') {
+ } else if (
+ name.startsWith('PRC_') || name.startsWith('ROC_') ||
+ name == 'OM_DAI_PA_KAI' || name == 'OM_JUURO_KU_KAI' ||
+ name == 'OM_PA_KAI') {
category = categoryStandardCN;
} else if (name.startsWith('ISO_')) {
category = categoryStandardISO;
@@ -601,8 +600,9 @@ cr.define('print_preview', function() {
// Then put it all back together.
mediaSize.option = categoryStandardNA;
- mediaSize.option.push(...categoryStandardCN, ...categoryStandardISO,
- ...categoryStandardJP, ...categoryStandardMisc, ...categoryCustom);
+ mediaSize.option.push(
+ ...categoryStandardCN, ...categoryStandardISO, ...categoryStandardJP,
+ ...categoryStandardMisc, ...categoryCustom);
return capabilities;
};
@@ -643,8 +643,8 @@ cr.define('print_preview', function() {
*/
get isLocalDestinationSearchInProgress() {
return this.isLocalDestinationSearchInProgress_ ||
- this.isPrivetDestinationSearchInProgress_ ||
- this.isExtensionDestinationSearchInProgress_;
+ this.isPrivetDestinationSearchInProgress_ ||
+ this.isExtensionDestinationSearchInProgress_;
},
/**
@@ -652,7 +652,7 @@ cr.define('print_preview', function() {
*/
get isCloudDestinationSearchInProgress() {
return !!this.cloudPrintInterface_ &&
- this.cloudPrintInterface_.isCloudDestinationSearchInProgress;
+ this.cloudPrintInterface_.isCloudDestinationSearchInProgress;
},
/*
@@ -668,8 +668,7 @@ cr.define('print_preview', function() {
* default destination selection rules.
*/
init: function(
- isInAppKioskMode,
- systemDefaultDestinationId,
+ isInAppKioskMode, systemDefaultDestinationId,
serializedDefaultDestinationSelectionRulesStr) {
this.pdfPrinterEnabled_ = !isInAppKioskMode;
this.systemDefaultDestinationId_ = systemDefaultDestinationId;
@@ -710,13 +709,11 @@ cr.define('print_preview', function() {
account = this.appState_.recentDestinations[i].account || '';
name = this.appState_.recentDestinations[i].name || '';
capabilities = this.appState_.recentDestinations[i].capabilities;
- extensionId = this.appState_.recentDestinations[i].extensionId ||
- '';
+ extensionId = this.appState_.recentDestinations[i].extensionId || '';
extensionName =
this.appState_.recentDestinations[i].extensionName || '';
- var candidate =
- this.destinationMap_[this.getDestinationKey_(origin,
- id, account)];
+ var candidate = this.destinationMap_[this.getDestinationKey_(
+ origin, id, account)];
if (candidate != null) {
if (!foundDestination)
this.selectDestination(candidate);
@@ -724,17 +721,13 @@ cr.define('print_preview', function() {
foundDestination = true;
} else if (!foundDestination) {
foundDestination = this.fetchPreselectedDestination_(
- origin,
- id,
- account,
- name,
- capabilities,
- extensionId,
- extensionName);
+ origin, id, account, name, capabilities, extensionId,
+ extensionName);
}
}
}
- if (foundDestination) return;
+ if (foundDestination)
+ return;
// Try the system default
var candidate =
this.destinationMap_[this.getDestinationKey_(origin, id, account)];
@@ -744,12 +737,7 @@ cr.define('print_preview', function() {
}
if (this.fetchPreselectedDestination_(
- origin,
- id,
- account,
- name,
- capabilities,
- extensionId,
+ origin, id, account, name, capabilities, extensionId,
extensionName)) {
return;
}
@@ -797,17 +785,14 @@ cr.define('print_preview', function() {
// destination store. When the real destination is created, this
// destination will be overwritten.
this.selectedDestination_ = new print_preview.Destination(
- id,
- print_preview.Destination.Type.LOCAL,
- print_preview.Destination.Origin.PRIVET,
- name,
- false /*isRecent*/,
+ id, print_preview.Destination.Type.LOCAL,
+ print_preview.Destination.Origin.PRIVET, name, false /*isRecent*/,
print_preview.Destination.ConnectionStatus.ONLINE);
this.selectedDestination_.capabilities = capabilities;
cr.dispatchSimpleEvent(
- this,
- DestinationStore.EventType.CACHED_SELECTED_DESTINATION_INFO_READY);
+ this,
+ DestinationStore.EventType.CACHED_SELECTED_DESTINATION_INFO_READY);
return true;
}
@@ -828,9 +813,8 @@ cr.define('print_preview', function() {
this.selectedDestination_.capabilities = capabilities;
cr.dispatchSimpleEvent(
- this,
- DestinationStore.EventType
- .CACHED_SELECTED_DESTINATION_INFO_READY);
+ this, DestinationStore.EventType
+ .CACHED_SELECTED_DESTINATION_INFO_READY);
}
return true;
}
@@ -847,23 +831,23 @@ cr.define('print_preview', function() {
this.autoSelectMatchingDestination_ = destinationMatch;
if (destinationMatch.matchOrigin(
- print_preview.Destination.Origin.LOCAL)) {
+ print_preview.Destination.Origin.LOCAL)) {
this.startLoadLocalDestinations();
}
if (destinationMatch.matchOrigin(
- print_preview.Destination.Origin.PRIVET)) {
+ print_preview.Destination.Origin.PRIVET)) {
this.startLoadPrivetDestinations();
}
if (destinationMatch.matchOrigin(
- print_preview.Destination.Origin.EXTENSION)) {
+ print_preview.Destination.Origin.EXTENSION)) {
this.startLoadExtensionDestinations();
}
if (destinationMatch.matchOrigin(
- print_preview.Destination.Origin.COOKIES) ||
+ print_preview.Destination.Origin.COOKIES) ||
destinationMatch.matchOrigin(
- print_preview.Destination.Origin.DEVICE) ||
+ print_preview.Destination.Origin.DEVICE) ||
destinationMatch.matchOrigin(
- print_preview.Destination.Origin.PROFILE)) {
+ print_preview.Destination.Origin.PROFILE)) {
this.startLoadCloudDestinations();
}
},
@@ -883,9 +867,8 @@ cr.define('print_preview', function() {
matchRules =
JSON.parse(serializedDefaultDestinationSelectionRulesStr);
}
- } catch(e) {
- console.error(
- 'Failed to parse defaultDestinationSelectionRules: ' + e);
+ } catch (e) {
+ console.error('Failed to parse defaultDestinationSelectionRules: ' + e);
}
if (!matchRules)
return;
@@ -928,9 +911,7 @@ cr.define('print_preview', function() {
}
return new DestinationMatch(
- origins,
- idRegExp,
- displayNameRegExp,
+ origins, idRegExp, displayNameRegExp,
true /*skipVirtualDestinations*/);
},
@@ -964,8 +945,7 @@ cr.define('print_preview', function() {
return new DestinationMatch(
[origin],
new RegExp('^' + id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '$'),
- null /*displayNameRegExp*/,
- false /*skipVirtualDestinations*/);
+ null /*displayNameRegExp*/, false /*skipVirtualDestinations*/);
},
/**
@@ -1030,16 +1010,18 @@ cr.define('print_preview', function() {
return;
}
- assert(!destination.isProvisional,
- 'Unable to select provisonal destinations');
+ assert(
+ !destination.isProvisional,
+ 'Unable to select provisonal destinations');
// Update and persist selected destination.
this.selectedDestination_ = destination;
this.selectedDestination_.isRecent = true;
if (destination.id == print_preview.Destination.GooglePromotedId.FEDEX &&
!destination.isTosAccepted) {
- assert(this.cloudPrintInterface_ != null,
- 'Selected FedEx destination, but GCP API is not available');
+ assert(
+ this.cloudPrintInterface_ != null,
+ 'Selected FedEx destination, but GCP API is not available');
destination.isTosAccepted = true;
this.cloudPrintInterface_.updatePrinterTosAcceptance(destination, true);
}
@@ -1050,11 +1032,12 @@ cr.define('print_preview', function() {
return otherDestination.cloudID == destination.cloudID &&
otherDestination != destination;
})) {
- this.metrics_.record(destination.isPrivet ?
- print_preview.Metrics.DestinationSearchBucket.
- PRIVET_DUPLICATE_SELECTED :
- print_preview.Metrics.DestinationSearchBucket.
- CLOUD_DUPLICATE_SELECTED);
+ this.metrics_.record(
+ destination.isPrivet ?
+ print_preview.Metrics.DestinationSearchBucket
+ .PRIVET_DUPLICATE_SELECTED :
+ print_preview.Metrics.DestinationSearchBucket
+ .CLOUD_DUPLICATE_SELECTED);
}
// Notify about selected destination change.
cr.dispatchSimpleEvent(
@@ -1071,8 +1054,9 @@ cr.define('print_preview', function() {
this.nativeLayer_.startGetLocalDestinationCapabilities(
destination.id);
} else {
- assert(this.cloudPrintInterface_ != null,
- 'Cloud destination selected, but GCP is not enabled');
+ assert(
+ this.cloudPrintInterface_ != null,
+ 'Cloud destination selected, but GCP is not enabled');
this.cloudPrintInterface_.printer(
destination.id, destination.origin, destination.account);
}
@@ -1103,8 +1087,7 @@ cr.define('print_preview', function() {
selectPdfDestination_: function() {
var saveToPdfKey = this.getDestinationKey_(
print_preview.Destination.Origin.LOCAL,
- print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
- '');
+ print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, '');
this.selectDestination(
this.destinationMap_[saveToPdfKey] || this.destinations_[0] || null);
},
@@ -1121,13 +1104,10 @@ cr.define('print_preview', function() {
this.systemDefaultDestinationId_,
print_preview.Destination.Origin.LOCAL)) {
if (this.fetchPreselectedDestination_(
- print_preview.Destination.Origin.LOCAL,
- this.systemDefaultDestinationId_,
- '' /*account*/,
- '' /*name*/,
- null /*capabilities*/,
- '' /*extensionId*/,
- '' /*extensionName*/)) {
+ print_preview.Destination.Origin.LOCAL,
+ this.systemDefaultDestinationId_, '' /*account*/, '' /*name*/,
+ null /*capabilities*/, '' /*extensionId*/,
+ '' /*extensionName*/)) {
return;
}
}
@@ -1333,10 +1313,10 @@ cr.define('print_preview', function() {
*/
updateDestination_: function(destination) {
assert(destination.constructor !== Array, 'Single printer expected');
- destination.capabilities_ = DestinationStore.localizeCapabilities_(
- destination.capabilities_);
- destination.capabilities_ = DestinationStore.sortMediaSizes_(
- destination.capabilities_);
+ destination.capabilities_ =
+ DestinationStore.localizeCapabilities_(destination.capabilities_);
+ destination.capabilities_ =
+ DestinationStore.sortMediaSizes_(destination.capabilities_);
var existingDestination = this.destinationMap_[this.getKey_(destination)];
if (existingDestination != null) {
existingDestination.capabilities = destination.capabilities;
@@ -1380,8 +1360,7 @@ cr.define('print_preview', function() {
if (this.autoSelectMatchingDestination_ &&
this.autoSelectMatchingDestination_.matchOrigin(
print_preview.Destination.Origin.EXTENSION) &&
- this.selectedDestination_ &&
- this.selectedDestination_.isExtension) {
+ this.selectedDestination_ && this.selectedDestination_.isExtension) {
this.selectDefaultDestination_();
}
},
@@ -1396,18 +1375,20 @@ cr.define('print_preview', function() {
var key = this.getKey_(destination);
var existingDestination = this.destinationMap_[key];
if (existingDestination == null) {
- destination.isRecent |= this.appState_.recentDestinations.some(
- function(recent) {
- return (destination.id == recent.id &&
- destination.origin == recent.origin);
+ destination.isRecent |=
+ this.appState_.recentDestinations.some(function(recent) {
+ return (
+ destination.id == recent.id &&
+ destination.origin == recent.origin);
}, this);
this.destinations_.push(destination);
this.destinationMap_[key] = destination;
return true;
- } else if (existingDestination.connectionStatus ==
- print_preview.Destination.ConnectionStatus.UNKNOWN &&
- destination.connectionStatus !=
- print_preview.Destination.ConnectionStatus.UNKNOWN) {
+ } else if (
+ existingDestination.connectionStatus ==
+ print_preview.Destination.ConnectionStatus.UNKNOWN &&
+ destination.connectionStatus !=
+ print_preview.Destination.ConnectionStatus.UNKNOWN) {
existingDestination.connectionStatus = destination.connectionStatus;
return true;
} else {
@@ -1471,8 +1452,7 @@ cr.define('print_preview', function() {
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
print_preview.Destination.Type.LOCAL,
print_preview.Destination.Origin.LOCAL,
- loadTimeData.getString('printToPDF'),
- false /*isRecent*/,
+ loadTimeData.getString('printToPDF'), false /*isRecent*/,
print_preview.Destination.ConnectionStatus.ONLINE));
}
},
@@ -1525,9 +1505,7 @@ cr.define('print_preview', function() {
var printerName = event.settingsInfo['printerName'];
var printerDescription = event.settingsInfo['printerDescription'];
var key = this.getDestinationKey_(
- print_preview.Destination.Origin.LOCAL,
- destinationId,
- '');
+ print_preview.Destination.Origin.LOCAL, destinationId, '');
var destination = this.destinationMap_[key];
var capabilities = DestinationStore.localizeCapabilities_(
event.settingsInfo.capabilities);
@@ -1547,10 +1525,11 @@ cr.define('print_preview', function() {
}
destination.capabilities = capabilities;
} else {
- destination = print_preview.LocalDestinationParser.parse(
- {deviceName: destinationId,
- printerName: printerName,
- printerDescription: printerDescription});
+ destination = print_preview.LocalDestinationParser.parse({
+ deviceName: destinationId,
+ printerName: printerName,
+ printerDescription: printerDescription
+ });
destination.capabilities = capabilities;
this.insertDestination_(destination);
}
@@ -1571,8 +1550,9 @@ cr.define('print_preview', function() {
* @private
*/
onGetCapabilitiesFail_: function(event) {
- console.error('Failed to get print capabilities for printer ' +
- event.destinationId);
+ console.error(
+ 'Failed to get print capabilities for printer ' +
+ event.destinationId);
if (this.autoSelectMatchingDestination_ &&
this.autoSelectMatchingDestination_.matchIdAndOrigin(
event.destinationId, event.destinationOrigin)) {
@@ -1700,8 +1680,7 @@ cr.define('print_preview', function() {
*/
onExtensionCapabilitiesSet_: function(event) {
var destinationKey = this.getDestinationKey_(
- print_preview.Destination.Origin.EXTENSION,
- event.printerId,
+ print_preview.Destination.Origin.EXTENSION, event.printerId,
'' /* account */);
var destination = this.destinationMap_[destinationKey];
if (!destination)
@@ -1748,7 +1727,5 @@ cr.define('print_preview', function() {
};
// Export
- return {
- DestinationStore: DestinationStore
- };
+ return {DestinationStore: DestinationStore};
});

Powered by Google App Engine
This is Rietveld 408576698