Index: chrome/browser/resources/print_preview/search/destination_search.js |
diff --git a/chrome/browser/resources/print_preview/search/destination_search.js b/chrome/browser/resources/print_preview/search/destination_search.js |
index c791bf68d3db28ea6279e0aff16149d741dc786e..fcdca6c6331b950064835883847e7615ab527f49 100644 |
--- a/chrome/browser/resources/print_preview/search/destination_search.js |
+++ b/chrome/browser/resources/print_preview/search/destination_search.js |
@@ -102,10 +102,10 @@ cr.define('print_preview', function() { |
* @private |
*/ |
this.localList_ = new print_preview.DestinationList( |
- this, |
- loadTimeData.getString('localDestinationsTitle'), |
+ this, loadTimeData.getString('localDestinationsTitle'), |
loadTimeData.getBoolean('showLocalManageButton') ? |
- loadTimeData.getString('manage') : null); |
+ loadTimeData.getString('manage') : |
+ null); |
this.addChild(this.localList_); |
/** |
@@ -179,8 +179,8 @@ cr.define('print_preview', function() { |
/** @override */ |
onCancelInternal: function() { |
- this.metrics_.record(print_preview.Metrics.DestinationSearchBucket. |
- DESTINATION_CLOSED_UNCHANGED); |
+ this.metrics_.record(print_preview.Metrics.DestinationSearchBucket |
+ .DESTINATION_CLOSED_UNCHANGED); |
}, |
/** Shows the Google Cloud Print promotion banner. */ |
@@ -201,46 +201,38 @@ cr.define('print_preview', function() { |
print_preview.Overlay.prototype.enterDocument.call(this); |
this.tracker.add( |
- this.getChildElement('.account-select'), |
- 'change', |
+ this.getChildElement('.account-select'), 'change', |
this.onAccountChange_.bind(this)); |
this.tracker.add( |
- this.getChildElement('.sign-in'), |
- 'click', |
+ this.getChildElement('.sign-in'), 'click', |
this.onSignInActivated_.bind(this)); |
this.tracker.add( |
- this.getChildElement('.invitation-accept-button'), |
- 'click', |
+ this.getChildElement('.invitation-accept-button'), 'click', |
this.onInvitationProcessButtonClick_.bind(this, true /*accept*/)); |
this.tracker.add( |
- this.getChildElement('.invitation-reject-button'), |
- 'click', |
+ this.getChildElement('.invitation-reject-button'), 'click', |
this.onInvitationProcessButtonClick_.bind(this, false /*accept*/)); |
this.tracker.add( |
- this.getChildElement('.cloudprint-promo > .close-button'), |
- 'click', |
+ this.getChildElement('.cloudprint-promo > .close-button'), 'click', |
this.onCloudprintPromoCloseButtonClick_.bind(this)); |
this.tracker.add( |
- this.searchBox_, |
- print_preview.SearchBox.EventType.SEARCH, |
+ this.searchBox_, print_preview.SearchBox.EventType.SEARCH, |
this.onSearch_.bind(this)); |
this.tracker.add( |
- this, |
- print_preview.DestinationListItem.EventType.CONFIGURE_REQUEST, |
+ this, print_preview.DestinationListItem.EventType.CONFIGURE_REQUEST, |
this.onDestinationConfigureRequest_.bind(this)); |
this.tracker.add( |
- this, |
- print_preview.DestinationListItem.EventType.SELECT, |
+ this, print_preview.DestinationListItem.EventType.SELECT, |
this.onDestinationSelect_.bind(this)); |
this.tracker.add( |
this, |
print_preview.DestinationListItem.EventType.REGISTER_PROMO_CLICKED, |
function() { |
- this.metrics_.record(print_preview.Metrics.DestinationSearchBucket. |
- REGISTER_PROMO_SELECTED); |
+ this.metrics_.record(print_preview.Metrics.DestinationSearchBucket |
+ .REGISTER_PROMO_SELECTED); |
}.bind(this)); |
this.tracker.add( |
@@ -284,13 +276,11 @@ cr.define('print_preview', function() { |
this.onManageCloudDestinationsActivated_.bind(this)); |
this.tracker.add( |
- this.userInfo_, |
- print_preview.UserInfo.EventType.USERS_CHANGED, |
+ this.userInfo_, print_preview.UserInfo.EventType.USERS_CHANGED, |
this.onUsersChanged_.bind(this)); |
this.tracker.add( |
- this.getChildElement('.button-strip .cancel-button'), |
- 'click', |
+ this.getChildElement('.button-strip .cancel-button'), 'click', |
this.cancel.bind(this)); |
this.tracker.add(window, 'resize', this.onWindowResize_.bind(this)); |
@@ -308,8 +298,7 @@ cr.define('print_preview', function() { |
this.localList_.render(this.getChildElement('.local-list')); |
this.cloudList_.render(this.getChildElement('.cloud-list')); |
this.getChildElement('.promo-text').innerHTML = loadTimeData.getStringF( |
- 'cloudPrintPromotion', |
- '<a is="action-link" class="sign-in">', |
+ 'cloudPrintPromotion', '<a is="action-link" class="sign-in">', |
'</a>'); |
this.getChildElement('.account-select-label').textContent = |
loadTimeData.getString('accountSelectTitle'); |
@@ -371,7 +360,7 @@ cr.define('print_preview', function() { |
localDestinations.push(destination); |
} else { |
if (destination.connectionStatus == |
- print_preview.DestinationConnectionStatus.UNREGISTERED) { |
+ print_preview.DestinationConnectionStatus.UNREGISTERED) { |
unregisteredCloudDestinations.push(destination); |
} else { |
cloudDestinations.push(destination); |
@@ -386,11 +375,13 @@ cr.define('print_preview', function() { |
this.registerPromoShownMetricRecorded_ = true; |
} |
- var finalCloudDestinations = unregisteredCloudDestinations.slice( |
- 0, DestinationSearch.MAX_PROMOTED_UNREGISTERED_PRINTERS_).concat( |
- cloudDestinations, |
- unregisteredCloudDestinations.slice( |
- DestinationSearch.MAX_PROMOTED_UNREGISTERED_PRINTERS_)); |
+ var finalCloudDestinations = |
+ unregisteredCloudDestinations |
+ .slice(0, DestinationSearch.MAX_PROMOTED_UNREGISTERED_PRINTERS_) |
+ .concat( |
+ cloudDestinations, |
+ unregisteredCloudDestinations.slice( |
+ DestinationSearch.MAX_PROMOTED_UNREGISTERED_PRINTERS_)); |
this.recentList_.updateDestinations(recentDestinations); |
this.localList_.updateDestinations(localDestinations); |
@@ -420,7 +411,9 @@ cr.define('print_preview', function() { |
}, 0); |
}; |
var getCounts = function(lists, count) { |
- return lists.map(function(list) { return count; }); |
+ return lists.map(function(list) { |
+ return count; |
+ }); |
}; |
var availableHeight = this.getAvailableListsHeight_(); |
@@ -488,11 +481,12 @@ cr.define('print_preview', function() { |
*/ |
updateInvitations_: function() { |
var invitations = this.userInfo_.activeUser ? |
- this.invitationStore_.invitations(this.userInfo_.activeUser) : []; |
+ this.invitationStore_.invitations(this.userInfo_.activeUser) : |
+ []; |
if (invitations.length > 0) { |
if (this.invitation_ != invitations[0]) { |
- this.metrics_.record(print_preview.Metrics.DestinationSearchBucket. |
- INVITATION_AVAILABLE); |
+ this.metrics_.record(print_preview.Metrics.DestinationSearchBucket |
+ .INVITATION_AVAILABLE); |
} |
this.invitation_ = invitations[0]; |
this.showInvitation_(this.invitation_); |
@@ -512,14 +506,12 @@ cr.define('print_preview', function() { |
var invitationText = ''; |
if (invitation.asGroupManager) { |
invitationText = loadTimeData.getStringF( |
- 'groupPrinterSharingInviteText', |
- HTMLEscape(invitation.sender), |
+ 'groupPrinterSharingInviteText', HTMLEscape(invitation.sender), |
HTMLEscape(invitation.destination.displayName), |
HTMLEscape(invitation.receiver)); |
} else { |
invitationText = loadTimeData.getStringF( |
- 'printerSharingInviteText', |
- HTMLEscape(invitation.sender), |
+ 'printerSharingInviteText', HTMLEscape(invitation.sender), |
HTMLEscape(invitation.destination.displayName)); |
} |
this.getChildElement('.invitation-text').innerHTML = invitationText; |
@@ -556,7 +548,8 @@ cr.define('print_preview', function() { |
accountSelectEl.add(option); |
accountSelectEl.selectedIndex = this.userInfo_.activeUser ? |
- this.userInfo_.users.indexOf(this.userInfo_.activeUser) : -1; |
+ this.userInfo_.users.indexOf(this.userInfo_.activeUser) : |
+ -1; |
} |
setIsVisible(this.getChildElement('.user-info'), loggedIn); |
@@ -591,10 +584,11 @@ cr.define('print_preview', function() { |
var destinationItem = |
(destination.isLocal || |
destination.origin == print_preview.DestinationOrigin.DEVICE) ? |
- this.localList_.getDestinationItem(destination.id) : |
- this.cloudList_.getDestinationItem(destination.id); |
- assert(destinationItem != null, |
- 'User does not select a valid destination item.'); |
+ this.localList_.getDestinationItem(destination.id) : |
+ this.cloudList_.getDestinationItem(destination.id); |
+ assert( |
+ destinationItem != null, |
+ 'User does not select a valid destination item.'); |
// Another printer setup is in process or the printer doesn't need to be |
// set up. Reject the setup request directly. |
@@ -616,24 +610,26 @@ cr.define('print_preview', function() { |
* @private |
*/ |
handleConfigureDestination_: function(destination) { |
- assert(destination.origin == print_preview.DestinationOrigin.CROS, |
- 'Only local printer on Chrome OS requires setup.'); |
+ assert( |
+ destination.origin == print_preview.DestinationOrigin.CROS, |
+ 'Only local printer on Chrome OS requires setup.'); |
this.destinationInConfiguring_ = destination; |
- this.destinationStore_.resolveCrosDestination(destination).then( |
- /** |
- * @param {!print_preview.PrinterSetupResponse} response |
- */ |
- function(response) { |
- this.destinationInConfiguring_ = null; |
- this.localList_.getDestinationItem(destination.id) |
- .onConfigureResolved(response); |
- }.bind(this), |
- function() { |
- this.destinationInConfiguring_ = null; |
- this.localList_.getDestinationItem(destination.id) |
- .onConfigureResolved({printerId: destination.id, |
- success: false}); |
- }.bind(this)); |
+ this.destinationStore_.resolveCrosDestination(destination) |
+ .then( |
+ /** |
+ * @param {!print_preview.PrinterSetupResponse} response |
+ */ |
+ function(response) { |
+ this.destinationInConfiguring_ = null; |
+ this.localList_.getDestinationItem(destination.id) |
+ .onConfigureResolved(response); |
+ }.bind(this), |
+ function() { |
+ this.destinationInConfiguring_ = null; |
+ this.localList_.getDestinationItem(destination.id) |
+ .onConfigureResolved( |
+ {printerId: destination.id, success: false}); |
+ }.bind(this)); |
}, |
/** |
@@ -655,18 +651,20 @@ cr.define('print_preview', function() { |
*/ |
handleOnDestinationSelect_: function(destination) { |
if (destination.isProvisional) { |
- assert(!this.provisionalDestinationResolver_, |
- 'Provisional destination resolver already exists.'); |
+ assert( |
+ !this.provisionalDestinationResolver_, |
+ 'Provisional destination resolver already exists.'); |
this.provisionalDestinationResolver_ = |
print_preview.ProvisionalDestinationResolver.create( |
this.destinationStore_, destination); |
- assert(!!this.provisionalDestinationResolver_, |
- 'Unable to create provisional destination resolver'); |
+ assert( |
+ !!this.provisionalDestinationResolver_, |
+ 'Unable to create provisional destination resolver'); |
var lastFocusedElement = document.activeElement; |
this.addChild(this.provisionalDestinationResolver_); |
- this.provisionalDestinationResolver_.run(this.getElement()). |
- then( |
+ this.provisionalDestinationResolver_.run(this.getElement()) |
+ .then( |
/** |
* @param {!print_preview.Destination} resolvedDestination |
* Destination to which the provisional destination was |
@@ -674,34 +672,31 @@ cr.define('print_preview', function() { |
*/ |
function(resolvedDestination) { |
this.handleOnDestinationSelect_(resolvedDestination); |
- }.bind(this)). |
- catch( |
- function() { |
- console.error('Failed to resolve provisional destination: ' + |
- destination.id); |
- }). |
- then( |
- function() { |
- this.removeChild( |
- assert(this.provisionalDestinationResolver_)); |
- this.provisionalDestinationResolver_ = null; |
- |
- // Restore focus to the previosly focused element if it's |
- // still shown in the search. |
- if (lastFocusedElement && |
- this.getIsVisible() && |
- getIsVisible(lastFocusedElement) && |
- this.getElement().contains(lastFocusedElement)) { |
- lastFocusedElement.focus(); |
- } |
- }.bind(this)); |
+ }.bind(this)) |
+ .catch(function() { |
+ console.error( |
+ 'Failed to resolve provisional destination: ' + |
+ destination.id); |
+ }) |
+ .then(function() { |
+ this.removeChild(assert(this.provisionalDestinationResolver_)); |
+ this.provisionalDestinationResolver_ = null; |
+ |
+ // Restore focus to the previosly focused element if it's |
+ // still shown in the search. |
+ if (lastFocusedElement && this.getIsVisible() && |
+ getIsVisible(lastFocusedElement) && |
+ this.getElement().contains(lastFocusedElement)) { |
+ lastFocusedElement.focus(); |
+ } |
+ }.bind(this)); |
return; |
} |
this.setIsVisible(false); |
this.destinationStore_.selectDestination(destination); |
- this.metrics_.record(print_preview.Metrics.DestinationSearchBucket. |
- DESTINATION_CLOSED_CHANGED); |
+ this.metrics_.record(print_preview.Metrics.DestinationSearchBucket |
+ .DESTINATION_CLOSED_CHANGED); |
}, |
/** |
@@ -812,9 +807,11 @@ cr.define('print_preview', function() { |
* @private |
*/ |
onInvitationProcessButtonClick_: function(accept) { |
- this.metrics_.record(accept ? |
- print_preview.Metrics.DestinationSearchBucket.INVITATION_ACCEPTED : |
- print_preview.Metrics.DestinationSearchBucket.INVITATION_REJECTED); |
+ this.metrics_.record( |
+ accept ? print_preview.Metrics.DestinationSearchBucket |
+ .INVITATION_ACCEPTED : |
+ print_preview.Metrics.DestinationSearchBucket |
+ .INVITATION_REJECTED); |
this.invitationStore_.processInvitation(assert(this.invitation_), accept); |
this.updateInvitations_(); |
}, |
@@ -839,7 +836,5 @@ cr.define('print_preview', function() { |
}; |
// Export |
- return { |
- DestinationSearch: DestinationSearch |
- }; |
+ return {DestinationSearch: DestinationSearch}; |
}); |