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

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

Issue 150943006: Show destination offline status in the print preview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 6 years, 10 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.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_ = '';
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.

Powered by Google App Engine
This is Rietveld 408576698