Rename AuthType to Origin of destination.

Store AuthType in AppState.

Current Destination.Type is more suitable for selecting display styles. Origin represents better how we get this destination.

BUG=179229

Review URL: https://chromiumcodereview.appspot.com/14340003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195151 0039d316-1c4b-4281-b951-d872f2087c98
parent 264d8a3e
...@@ -350,7 +350,7 @@ cr.define('cloudprint', function() { ...@@ -350,7 +350,7 @@ cr.define('cloudprint', function() {
try { try {
printerList.push( printerList.push(
cloudprint.CloudDestinationParser.parse( cloudprint.CloudDestinationParser.parse(
printerJson, print_preview.Destination.AuthType.COOKIES)); printerJson, print_preview.Destination.Origin.COOKIES));
} catch (err) { } catch (err) {
console.error('Unable to parse cloud print destination: ' + err); console.error('Unable to parse cloud print destination: ' + err);
} }
...@@ -400,7 +400,7 @@ cr.define('cloudprint', function() { ...@@ -400,7 +400,7 @@ cr.define('cloudprint', function() {
var printer; var printer;
try { try {
printer = cloudprint.CloudDestinationParser.parse( printer = cloudprint.CloudDestinationParser.parse(
printerJson, print_preview.Destination.AuthType.COOKIES); printerJson, print_preview.Destination.Origin.COOKIES);
} catch (err) { } catch (err) {
console.error('Failed to parse cloud print destination: ' + console.error('Failed to parse cloud print destination: ' +
JSON.stringify(printerJson)); JSON.stringify(printerJson));
...@@ -414,6 +414,7 @@ cr.define('cloudprint', function() { ...@@ -414,6 +414,7 @@ cr.define('cloudprint', function() {
var errorEvent = this.createErrorEvent_( var errorEvent = this.createErrorEvent_(
CloudPrintInterface.EventType.PRINTER_FAILED, status, result); CloudPrintInterface.EventType.PRINTER_FAILED, status, result);
errorEvent.destinationId = destinationId; errorEvent.destinationId = destinationId;
errorEvent.destinationOrigin = print_preview.Destination.Origin.COOKIES;
this.dispatchEvent(errorEvent); this.dispatchEvent(errorEvent);
} }
}, },
......
...@@ -18,11 +18,11 @@ cr.define('print_preview', function() { ...@@ -18,11 +18,11 @@ cr.define('print_preview', function() {
this.selectedDestinationId_ = null; this.selectedDestinationId_ = null;
/** /**
* Whether the selected destination is a local destination. * Origin of the selected destination.
* @type {?boolean} * @type {?string}
* @private * @private
*/ */
this.isSelectedDestinationLocal_ = null; this.selectedDestinationOrigin_ = null;
/** /**
* Whether the GCP promotion has been dismissed. * Whether the GCP promotion has been dismissed.
...@@ -105,7 +105,8 @@ cr.define('print_preview', function() { ...@@ -105,7 +105,8 @@ cr.define('print_preview', function() {
AppState.Field_ = { AppState.Field_ = {
VERSION: 'version', VERSION: 'version',
SELECTED_DESTINATION_ID: 'selectedDestinationId', SELECTED_DESTINATION_ID: 'selectedDestinationId',
IS_SELECTED_DESTINATION_LOCAL: 'isSelectedDestinationLocal', SELECTED_DESTINATION_ORIGIN: 'selectedDestinationOrigin',
IS_SELECTED_DESTINATION_LOCAL: 'isSelectedDestinationLocal', // Deprecated
IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed', IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed',
MARGINS_TYPE: 'marginsType', MARGINS_TYPE: 'marginsType',
CUSTOM_MARGINS: 'customMargins', CUSTOM_MARGINS: 'customMargins',
...@@ -131,9 +132,9 @@ cr.define('print_preview', function() { ...@@ -131,9 +132,9 @@ cr.define('print_preview', function() {
return this.selectedDestinationId_; return this.selectedDestinationId_;
}, },
/** @return {?boolean} Whether the selected destination is local. */ /** @return {?string} Origin of the selected destination. */
get isSelectedDestinationLocal() { get selectedDestinationOrigin() {
return this.isSelectedDestinationLocal_; return this.selectedDestinationOrigin_;
}, },
/** @return {boolean} Whether the GCP promotion has been dismissed. */ /** @return {boolean} Whether the GCP promotion has been dismissed. */
...@@ -195,14 +196,20 @@ cr.define('print_preview', function() { ...@@ -195,14 +196,20 @@ cr.define('print_preview', function() {
} }
var state = JSON.parse(serializedAppStateStr); var state = JSON.parse(serializedAppStateStr);
if (state[AppState.Field_.VERSION] == 2) { if (state[AppState.Field_.VERSION] == AppState.VERSION_) {
this.selectedDestinationId_ = this.selectedDestinationId_ =
state[AppState.Field_.SELECTED_DESTINATION_ID] || null; state[AppState.Field_.SELECTED_DESTINATION_ID] || null;
if (state.hasOwnProperty( if (state.hasOwnProperty(
AppState.Field_.IS_SELECTED_DESTINATION_LOCAL)) { AppState.Field_.IS_SELECTED_DESTINATION_LOCAL)) {
this.isSelectedDestinationLocal_ = this.selectedDestinationOrigin_ =
state[AppState.Field_.IS_SELECTED_DESTINATION_LOCAL]; state[AppState.Field_.IS_SELECTED_DESTINATION_LOCAL] ?
print_preview.Destination.Origin.LOCAL :
print_preview.Destination.Origin.COOKIES;
} else {
this.selectedDestinationOrigin_ =
state[AppState.Field_.SELECTED_DESTINATION_ORIGIN] || null;
} }
this.isGcpPromoDismissed_ = this.isGcpPromoDismissed_ =
state[AppState.Field_.IS_GCP_PROMO_DISMISSED] || false; state[AppState.Field_.IS_GCP_PROMO_DISMISSED] || false;
if (state.hasOwnProperty(AppState.Field_.MARGINS_TYPE)) { if (state.hasOwnProperty(AppState.Field_.MARGINS_TYPE)) {
...@@ -242,7 +249,7 @@ cr.define('print_preview', function() { ...@@ -242,7 +249,7 @@ cr.define('print_preview', function() {
*/ */
persistSelectedDestination: function(dest) { persistSelectedDestination: function(dest) {
this.selectedDestinationId_ = dest.id; this.selectedDestinationId_ = dest.id;
this.isSelectedDestinationLocal_ = dest.isLocal; this.selectedDestinationOrigin_ = dest.origin;
this.persist_(); this.persist_();
}, },
...@@ -339,8 +346,8 @@ cr.define('print_preview', function() { ...@@ -339,8 +346,8 @@ cr.define('print_preview', function() {
obj[AppState.Field_.VERSION] = AppState.VERSION_; obj[AppState.Field_.VERSION] = AppState.VERSION_;
obj[AppState.Field_.SELECTED_DESTINATION_ID] = obj[AppState.Field_.SELECTED_DESTINATION_ID] =
this.selectedDestinationId_; this.selectedDestinationId_;
obj[AppState.Field_.IS_SELECTED_DESTINATION_LOCAL] = obj[AppState.Field_.SELECTED_DESTINATION_ORIGIN] =
this.isSelectedDestinationLocal_; this.selectedDestinationOrigin_;
obj[AppState.Field_.IS_GCP_PROMO_DISMISSED] = this.isGcpPromoDismissed_; obj[AppState.Field_.IS_GCP_PROMO_DISMISSED] = this.isGcpPromoDismissed_;
obj[AppState.Field_.MARGINS_TYPE] = this.marginsType_; obj[AppState.Field_.MARGINS_TYPE] = this.marginsType_;
if (this.customMargins_) { if (this.customMargins_) {
......
...@@ -56,11 +56,11 @@ cr.define('cloudprint', function() { ...@@ -56,11 +56,11 @@ cr.define('cloudprint', function() {
* response. * response.
* @param {!Object} json Object that represents a Google Cloud Print search or * @param {!Object} json Object that represents a Google Cloud Print search or
* printer response. * printer response.
* @param {!print_preview.Destination.AuthType} authType The authentication * @param {!print_preview.Destination.Origin} origin The origin of the
* type used to find printer. * response.
* @return {!print_preview.Destination} Parsed destination. * @return {!print_preview.Destination} Parsed destination.
*/ */
CloudDestinationParser.parse = function(json, authType) { CloudDestinationParser.parse = function(json, origin) {
if (!json.hasOwnProperty(CloudDestinationParser.Field_.ID) || if (!json.hasOwnProperty(CloudDestinationParser.Field_.ID) ||
!json.hasOwnProperty(CloudDestinationParser.Field_.TYPE) || !json.hasOwnProperty(CloudDestinationParser.Field_.TYPE) ||
!json.hasOwnProperty(CloudDestinationParser.Field_.DISPLAY_NAME)) { !json.hasOwnProperty(CloudDestinationParser.Field_.DISPLAY_NAME)) {
...@@ -83,7 +83,7 @@ cr.define('cloudprint', function() { ...@@ -83,7 +83,7 @@ cr.define('cloudprint', function() {
id, id,
CloudDestinationParser.parseType_( CloudDestinationParser.parseType_(
json[CloudDestinationParser.Field_.TYPE]), json[CloudDestinationParser.Field_.TYPE]),
authType, origin,
json[CloudDestinationParser.Field_.DISPLAY_NAME], json[CloudDestinationParser.Field_.DISPLAY_NAME],
arrayContains(tags, CloudDestinationParser.RECENT_TAG_) /*isRecent*/, arrayContains(tags, CloudDestinationParser.RECENT_TAG_) /*isRecent*/,
connectionStatus, connectionStatus,
......
...@@ -10,8 +10,8 @@ cr.define('print_preview', function() { ...@@ -10,8 +10,8 @@ cr.define('print_preview', function() {
* destinations. * destinations.
* @param {string} id ID of the destination. * @param {string} id ID of the destination.
* @param {!print_preview.Destination.Type} type Type of the destination. * @param {!print_preview.Destination.Type} type Type of the destination.
* @param {!print_preview.Destination.AuthType} authType Type of the * @param {!print_preview.Destination.Origin} origin Origin of the
* authentication used to access the destination. * destination.
* @param {string} displayName Display name of the destination. * @param {string} displayName Display name of the destination.
* @param {boolean} isRecent Whether the destination has been used recently. * @param {boolean} isRecent Whether the destination has been used recently.
* @param {!print_preview.Destination.ConnectionStatus} connectionStatus * @param {!print_preview.Destination.ConnectionStatus} connectionStatus
...@@ -23,7 +23,7 @@ cr.define('print_preview', function() { ...@@ -23,7 +23,7 @@ cr.define('print_preview', function() {
* destination. * destination.
* @constructor * @constructor
*/ */
function Destination(id, type, authType, displayName, isRecent, function Destination(id, type, origin, displayName, isRecent,
connectionStatus, opt_params) { connectionStatus, opt_params) {
/** /**
* ID of the destination. * ID of the destination.
...@@ -40,11 +40,11 @@ cr.define('print_preview', function() { ...@@ -40,11 +40,11 @@ cr.define('print_preview', function() {
this.type_ = type; this.type_ = type;
/** /**
* Type of authentication for the destination. * Origin of the destination.
* @type {!print_preview.Destination.AuthType} * @type {!print_preview.Destination.Origin}
* @private * @private
*/ */
this.authType_ = authType; this.origin_ = origin;
/** /**
* Display name of the destination. * Display name of the destination.
...@@ -142,10 +142,10 @@ cr.define('print_preview', function() { ...@@ -142,10 +142,10 @@ cr.define('print_preview', function() {
}; };
/** /**
* Enumeration of the authentication types for cloud destinations. * Enumeration of the origin types for cloud destinations.
* @enum {string} * @enum {string}
*/ */
Destination.AuthType = { Destination.Origin = {
LOCAL: 'local', LOCAL: 'local',
COOKIES: 'cookies', COOKIES: 'cookies',
PROFILE: 'profile', PROFILE: 'profile',
...@@ -192,11 +192,10 @@ cr.define('print_preview', function() { ...@@ -192,11 +192,10 @@ cr.define('print_preview', function() {
}, },
/** /**
* @return {!print_preview.Destination.AuthType} Type of authentication for * @return {!print_preview.Destination.Origin} Origin of the destination.
* the destination.
*/ */
get authType() { get origin() {
return this.authType_; return this.origin_;
}, },
/** @return {string} Display name of the destination. */ /** @return {string} Display name of the destination. */
...@@ -226,7 +225,7 @@ cr.define('print_preview', function() { ...@@ -226,7 +225,7 @@ cr.define('print_preview', function() {
/** @return {boolean} Whether the destination is local or cloud-based. */ /** @return {boolean} Whether the destination is local or cloud-based. */
get isLocal() { get isLocal() {
return this.type_ == Destination.Type.LOCAL; return this.origin_ == Destination.Origin.LOCAL;
}, },
/** /**
......
...@@ -39,7 +39,7 @@ cr.define('print_preview', function() { ...@@ -39,7 +39,7 @@ cr.define('print_preview', function() {
this.destinations_ = []; this.destinations_ = [];
/** /**
* Cache used for constant lookup of destinations by ID. * Cache used for constant lookup of destinations by origin and id.
* @type {object.<string, !print_preview.Destination>} * @type {object.<string, !print_preview.Destination>}
* @private * @private
*/ */
...@@ -62,11 +62,11 @@ cr.define('print_preview', function() { ...@@ -62,11 +62,11 @@ cr.define('print_preview', function() {
this.initialDestinationId_ = null; this.initialDestinationId_ = null;
/** /**
* Whether the initial destination is a local one or not. * Initial origin used to auto-select destination.
* @type {boolean} * @type {print_preview.Destination.Origin}
* @private * @private
*/ */
this.isInitialDestinationLocal_ = true; this.initialDestinationOrigin_ = print_preview.Destination.Origin.LOCAL;
/** /**
* Whether the destination store will auto select the destination that * Whether the destination store will auto select the destination that
...@@ -154,7 +154,7 @@ cr.define('print_preview', function() { ...@@ -154,7 +154,7 @@ cr.define('print_preview', function() {
var dest = new print_preview.Destination( var dest = new print_preview.Destination(
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
print_preview.Destination.Type.LOCAL, print_preview.Destination.Type.LOCAL,
print_preview.Destination.AuthType.LOCAL, print_preview.Destination.Origin.LOCAL,
localStrings.getString('printToPDF'), localStrings.getString('printToPDF'),
false /*isRecent*/, false /*isRecent*/,
print_preview.Destination.ConnectionStatus.ONLINE); print_preview.Destination.ConnectionStatus.ONLINE);
...@@ -218,25 +218,31 @@ cr.define('print_preview', function() { ...@@ -218,25 +218,31 @@ cr.define('print_preview', function() {
* @private * @private
*/ */
init: function(systemDefaultDestinationId) { init: function(systemDefaultDestinationId) {
if (this.appState_.selectedDestinationId) { if (this.appState_.selectedDestinationId &&
this.appState_.selectedDestinationOrigin) {
this.initialDestinationId_ = this.appState_.selectedDestinationId; this.initialDestinationId_ = this.appState_.selectedDestinationId;
this.isInitialDestinationLocal_ = this.initialDestinationOrigin_ =
this.appState_.isSelectedDestinationLocal; this.appState_.selectedDestinationOrigin_;
} else { } else {
this.initialDestinationId_ = systemDefaultDestinationId; this.initialDestinationId_ = systemDefaultDestinationId;
this.isInitialDestinationLocal_ = true; this.initialDestinationOrigin_ =
print_preview.Destination.Origin.LOCAL;
} }
this.isInAutoSelectMode_ = true; this.isInAutoSelectMode_ = true;
if (this.initialDestinationId_ == null) { if (this.initialDestinationId_ == null ||
this.initialDestinationOrigin_ == null) {
assert(this.destinations_.length > 0, assert(this.destinations_.length > 0,
'No destinations available to select'); 'No destinations available to select');
this.selectDestination(this.destinations_[0]); this.selectDestination(this.destinations_[0]);
} else { } else {
var candidate = this.destinationMap_[this.initialDestinationId_]; var key = this.getDestinationKey_(this.initialDestinationOrigin_,
this.initialDestinationId_);
var candidate = this.destinationMap_[key];
if (candidate != null) { if (candidate != null) {
this.selectDestination(candidate); this.selectDestination(candidate);
} else if (!cr.isChromeOS && this.isInitialDestinationLocal_) { } else if (!cr.isChromeOS &&
this.initialDestinationOrigin_ ==
print_preview.Destination.Origin.LOCAL) {
this.nativeLayer_.startGetLocalDestinationCapabilities( this.nativeLayer_.startGetLocalDestinationCapabilities(
this.initialDestinationId_); this.initialDestinationId_);
} }
...@@ -267,8 +273,10 @@ cr.define('print_preview', function() { ...@@ -267,8 +273,10 @@ cr.define('print_preview', function() {
cloudprint.CloudPrintInterface.EventType.PRINTER_FAILED, cloudprint.CloudPrintInterface.EventType.PRINTER_FAILED,
this.onCloudPrintPrinterFailed_.bind(this)); this.onCloudPrintPrinterFailed_.bind(this));
// Fetch initial destination if its a cloud destination. // Fetch initial destination if its a cloud destination.
if (this.isInAutoSelectMode_ && !this.isInitialDestinationLocal_) { var origin = this.initialDestinationOrigin_;
this.cloudPrintInterface_.printer(this.initialDestinationId_); if (this.isInAutoSelectMode_ &&
origin != print_preview.Destination.Origin.LOCAL) {
this.cloudPrintInterface_.printer(this.initialDestinationId_, origin);
} }
}, },
...@@ -313,7 +321,8 @@ cr.define('print_preview', function() { ...@@ -313,7 +321,8 @@ cr.define('print_preview', function() {
assert(this.cloudPrintInterface_ != null, assert(this.cloudPrintInterface_ != null,
'Selected destination is a cloud destination, but Google ' + 'Selected destination is a cloud destination, but Google ' +
'Cloud Print is not enabled'); 'Cloud Print is not enabled');
this.cloudPrintInterface_.printer(destination.id); this.cloudPrintInterface_.printer(destination.id,
destination.origin);
} }
} else { } else {
cr.dispatchSimpleEvent( cr.dispatchSimpleEvent(
...@@ -334,8 +343,7 @@ cr.define('print_preview', function() { ...@@ -334,8 +343,7 @@ cr.define('print_preview', function() {
cr.dispatchSimpleEvent( cr.dispatchSimpleEvent(
this, DestinationStore.EventType.DESTINATIONS_INSERTED); this, DestinationStore.EventType.DESTINATIONS_INSERTED);
if (this.isInAutoSelectMode_ && if (this.isInAutoSelectMode_ &&
(this.initialDestinationId_ == null || this.matchInitialDestination_(destination.id, destination.origin)) {
destination.id == this.initialDestinationId_)) {
this.selectDestination(destination); this.selectDestination(destination);
} }
} }
...@@ -356,8 +364,7 @@ cr.define('print_preview', function() { ...@@ -356,8 +364,7 @@ cr.define('print_preview', function() {
insertedDestination = true; insertedDestination = true;
if (this.isInAutoSelectMode_ && if (this.isInAutoSelectMode_ &&
destinationToAutoSelect == null && destinationToAutoSelect == null &&
(this.initialDestinationId_ == null || this.matchInitialDestination_(dest.id, dest.origin)) {
dest.id == this.initialDestinationId_)) {
destinationToAutoSelect = dest; destinationToAutoSelect = dest;
} }
} }
...@@ -376,15 +383,17 @@ cr.define('print_preview', function() { ...@@ -376,15 +383,17 @@ cr.define('print_preview', function() {
* the destination doesn't already exist, it will be added. * the destination doesn't already exist, it will be added.
* @param {!print_preview.Destination} destination Destination to update. * @param {!print_preview.Destination} destination Destination to update.
* @return {!print_preview.Destination} The existing destination that was * @return {!print_preview.Destination} The existing destination that was
* updated. * updated or {@code null} if it was the new destination.
*/ */
updateDestination: function(destination) { updateDestination: function(destination) {
var existingDestination = this.destinationMap_[destination.id]; var key = this.getDestinationKey_(destination.origin, destination.id);
var existingDestination = this.destinationMap_[key];
if (existingDestination != null) { if (existingDestination != null) {
existingDestination.capabilities = destination.capabilities; existingDestination.capabilities = destination.capabilities;
return existingDestination; return existingDestination;
} else { } else {
this.insertDestination(destination); this.insertDestination(destination);
return null;
} }
}, },
...@@ -418,10 +427,11 @@ cr.define('print_preview', function() { ...@@ -418,10 +427,11 @@ cr.define('print_preview', function() {
* @private * @private
*/ */
insertDestination_: function(destination) { insertDestination_: function(destination) {
var existingDestination = this.destinationMap_[destination.id]; var key = this.getDestinationKey_(destination.origin, destination.id);
var existingDestination = this.destinationMap_[key];
if (existingDestination == null) { if (existingDestination == null) {
this.destinations_.push(destination); this.destinations_.push(destination);
this.destinationMap_[destination.id] = destination; this.destinationMap_[key] = destination;
return true; return true;
} else if (existingDestination.connectionStatus == } else if (existingDestination.connectionStatus ==
print_preview.Destination.ConnectionStatus.UNKNOWN && print_preview.Destination.ConnectionStatus.UNKNOWN &&
...@@ -499,7 +509,10 @@ cr.define('print_preview', function() { ...@@ -499,7 +509,10 @@ cr.define('print_preview', function() {
*/ */
onLocalDestinationCapabilitiesSet_: function(event) { onLocalDestinationCapabilitiesSet_: function(event) {
var destinationId = event.settingsInfo['printerId']; var destinationId = event.settingsInfo['printerId'];
var destination = this.destinationMap_[destinationId]; var key =
this.getDestinationKey_(print_preview.Destination.Origin.LOCAL,
destinationId);
var destination = this.destinationMap_[key];
var capabilities = print_preview.LocalCapabilitiesParser.parse( var capabilities = print_preview.LocalCapabilitiesParser.parse(
event.settingsInfo); event.settingsInfo);
if (destination) { if (destination) {
...@@ -537,7 +550,8 @@ cr.define('print_preview', function() { ...@@ -537,7 +550,8 @@ cr.define('print_preview', function() {
console.error('Failed to get print capabilities for printer ' + console.error('Failed to get print capabilities for printer ' +
event.destinationId); event.destinationId);
if (this.isInAutoSelectMode_ && if (this.isInAutoSelectMode_ &&
this.initialDestinationId_ == event.destinationId) { this.matchInitialDestinationStrict_(event.destinationId,
event.destinationOrigin)) {
assert(this.destinations_.length > 0, assert(this.destinations_.length > 0,
'No destinations were loaded when failed to get initial ' + 'No destinations were loaded when failed to get initial ' +
'destination'); 'destination');
...@@ -593,7 +607,8 @@ cr.define('print_preview', function() { ...@@ -593,7 +607,8 @@ cr.define('print_preview', function() {
*/ */
onCloudPrintPrinterFailed_: function(event) { onCloudPrintPrinterFailed_: function(event) {
if (this.isInAutoSelectMode_ && if (this.isInAutoSelectMode_ &&
this.initialDestinationId_ == event.destinationId) { this.matchInitialDestinationStrict_(event.destinationId,
event.destinationOrigin)) {
console.error('Could not find initial printer: ' + event.destinationId); console.error('Could not find initial printer: ' + event.destinationId);
assert(this.destinations_.length > 0, assert(this.destinations_.length > 0,
'No destinations were loaded when failed to get initial ' + 'No destinations were loaded when failed to get initial ' +
...@@ -625,6 +640,41 @@ cr.define('print_preview', function() { ...@@ -625,6 +640,41 @@ cr.define('print_preview', function() {
assert(this.destinations_.length > 0, assert(this.destinations_.length > 0,
'No destinations were loaded before auto-select timeout expired'); 'No destinations were loaded before auto-select timeout expired');
this.selectDestination(this.destinations_[0]); this.selectDestination(this.destinations_[0]);
},
// TODO(vitalybuka): Remove three next functions replacing Destination.id
// and Destination.origin by complex ID.
/**
* Returns key to be used with {@code destinationMap_}.
* @param {!print_preview.Destination.Origin} origin Destination origin.
* @return {!string} id Destination id.
* @private
*/
getDestinationKey_: function(origin, id) {
return origin + '/' + id;
},
/**
* @param {?string} id Id of the destination.
* @param {?string} origin Oring of the destination.
* @return {boolean} Whether a initial destination matches provided.
* @private
*/
matchInitialDestination_: function(id, origin) {
return this.initialDestinationId_ == null ||
this.initialDestinationOrigin_ == null ||
this.matchInitialDestinationStrict_(id, origin);
},
/**
* @param {?string} id Id of the destination.
* @param {?string} origin Oring of the destination.
* @return {boolean} Whether destination is the same as initial.
* @private
*/
matchInitialDestinationStrict_: function(id, origin) {
return id == this.initialDestinationId_ &&
origin == this.initialDestinationOrigin_;
} }
}; };
......
...@@ -18,7 +18,7 @@ cr.define('print_preview', function() { ...@@ -18,7 +18,7 @@ cr.define('print_preview', function() {
return new print_preview.Destination( return new print_preview.Destination(
destinationInfo.deviceName, destinationInfo.deviceName,
print_preview.Destination.Type.LOCAL, print_preview.Destination.Type.LOCAL,
print_preview.Destination.AuthType.LOCAL, print_preview.Destination.Origin.LOCAL,
destinationInfo.printerName, destinationInfo.printerName,
false /*isRecent*/, false /*isRecent*/,
print_preview.Destination.ConnectionStatus.ONLINE); print_preview.Destination.ConnectionStatus.ONLINE);
......
...@@ -399,6 +399,8 @@ cr.define('print_preview', function() { ...@@ -399,6 +399,8 @@ cr.define('print_preview', function() {
var getCapsFailEvent = new cr.Event( var getCapsFailEvent = new cr.Event(
NativeLayer.EventType.GET_CAPABILITIES_FAIL); NativeLayer.EventType.GET_CAPABILITIES_FAIL);
getCapsFailEvent.destinationId = destinationId; getCapsFailEvent.destinationId = destinationId;
getCapsFailEvent.destinationOrigin =
print_preview.Destination.Origin.LOCAL;
this.dispatchEvent(getCapsFailEvent); this.dispatchEvent(getCapsFailEvent);
}, },
......
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