Index: chrome/browser/resources/print_preview/data/destination.js |
diff --git a/chrome/browser/resources/print_preview/data/destination.js b/chrome/browser/resources/print_preview/data/destination.js |
index f97266428f915f666c751461fd5791208681cb13..e37427ce3cc5d757c585ad99476143acb836a114 100644 |
--- a/chrome/browser/resources/print_preview/data/destination.js |
+++ b/chrome/browser/resources/print_preview/data/destination.js |
@@ -252,6 +252,7 @@ cr.define('print_preview', function() { |
*/ |
get location() { |
if (this.location_ == null) { |
+ this.location_ = ''; |
Vitaly Buka (NO REVIEWS)
2014/02/12 00:39:19
Why do we initialize this in null in first place?
Toscano
2014/02/12 22:10:29
Agreed, I think that would be simpler.
Aleksey Shlyapnikov
2014/02/13 19:10:18
Null indicates that we have not tried to look it u
|
for (var tag, i = 0; tag = this.tags_[i]; i++) { |
if (tag.indexOf(Destination.LOCATION_TAG_PREFIX) == 0) { |
this.location_ = tag.substring( |
@@ -302,6 +303,32 @@ cr.define('print_preview', function() { |
this.connectionStatus_ = status; |
}, |
+ /** @return {boolean} Whether the destination is considered offline. */ |
+ get isOffline() { |
+ return arrayContains([print_preview.Destination.ConnectionStatus.OFFLINE, |
+ print_preview.Destination.ConnectionStatus.DORMANT], |
+ this.connectionStatus_); |
+ }, |
+ |
+ /** @return {string} Human readable status for offline destination. */ |
+ get offlineStatusText() { |
+ if (!this.isOffline) { |
+ return ''; |
+ } |
+ var offlineDurationMs = Date.now() - this.lastAccessTime_; |
+ var offlineMessageId; |
+ if (offlineDurationMs > 31622400000.0) { // One year. |
+ offlineMessageId = 'offlineForYear'; |
+ } else if (offlineDurationMs > 2678400000.0) { // One month. |
+ offlineMessageId = 'offlineForMonth'; |
+ } else if (offlineDurationMs > 604800000.0) { // One week. |
+ offlineMessageId = 'offlineForWeek'; |
+ } else { |
+ offlineMessageId = 'offline'; |
+ } |
+ return localStrings.getString(offlineMessageId); |
+ }, |
+ |
/** |
* @return {number} Number of milliseconds since the epoch when the printer |
* was last accessed. |