Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Print destination data object that holds data for both local and cloud | 9 * Print destination data object that holds data for both local and cloud |
| 10 * destinations. | 10 * destinations. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 get isPrivet() { | 245 get isPrivet() { |
| 246 return this.origin_ == Destination.Origin.PRIVET; | 246 return this.origin_ == Destination.Origin.PRIVET; |
| 247 }, | 247 }, |
| 248 | 248 |
| 249 /** | 249 /** |
| 250 * @return {string} The location of the destination, or an empty string if | 250 * @return {string} The location of the destination, or an empty string if |
| 251 * the location is unknown. | 251 * the location is unknown. |
| 252 */ | 252 */ |
| 253 get location() { | 253 get location() { |
| 254 if (this.location_ == null) { | 254 if (this.location_ == null) { |
| 255 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
| |
| 255 for (var tag, i = 0; tag = this.tags_[i]; i++) { | 256 for (var tag, i = 0; tag = this.tags_[i]; i++) { |
| 256 if (tag.indexOf(Destination.LOCATION_TAG_PREFIX) == 0) { | 257 if (tag.indexOf(Destination.LOCATION_TAG_PREFIX) == 0) { |
| 257 this.location_ = tag.substring( | 258 this.location_ = tag.substring( |
| 258 Destination.LOCATION_TAG_PREFIX.length) || ''; | 259 Destination.LOCATION_TAG_PREFIX.length) || ''; |
| 259 break; | 260 break; |
| 260 } | 261 } |
| 261 } | 262 } |
| 262 } | 263 } |
| 263 return this.location_; | 264 return this.location_; |
| 264 }, | 265 }, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 295 }, | 296 }, |
| 296 | 297 |
| 297 /** | 298 /** |
| 298 * @param {!print_preview.Destination.ConnectionStatus} status Connection | 299 * @param {!print_preview.Destination.ConnectionStatus} status Connection |
| 299 * status of the print destination. | 300 * status of the print destination. |
| 300 */ | 301 */ |
| 301 set connectionStatus(status) { | 302 set connectionStatus(status) { |
| 302 this.connectionStatus_ = status; | 303 this.connectionStatus_ = status; |
| 303 }, | 304 }, |
| 304 | 305 |
| 306 /** @return {boolean} Whether the destination is considered offline. */ | |
| 307 get isOffline() { | |
| 308 return arrayContains([print_preview.Destination.ConnectionStatus.OFFLINE, | |
| 309 print_preview.Destination.ConnectionStatus.DORMANT], | |
| 310 this.connectionStatus_); | |
| 311 }, | |
| 312 | |
| 313 /** @return {string} Human readable status for offline destination. */ | |
| 314 get offlineStatusText() { | |
| 315 if (!this.isOffline) { | |
| 316 return ''; | |
| 317 } | |
| 318 var offlineDurationMs = Date.now() - this.lastAccessTime_; | |
| 319 var offlineMessageId; | |
| 320 if (offlineDurationMs > 31622400000.0) { // One year. | |
| 321 offlineMessageId = 'offlineForYear'; | |
| 322 } else if (offlineDurationMs > 2678400000.0) { // One month. | |
| 323 offlineMessageId = 'offlineForMonth'; | |
| 324 } else if (offlineDurationMs > 604800000.0) { // One week. | |
| 325 offlineMessageId = 'offlineForWeek'; | |
| 326 } else { | |
| 327 offlineMessageId = 'offline'; | |
| 328 } | |
| 329 return localStrings.getString(offlineMessageId); | |
| 330 }, | |
| 331 | |
| 305 /** | 332 /** |
| 306 * @return {number} Number of milliseconds since the epoch when the printer | 333 * @return {number} Number of milliseconds since the epoch when the printer |
| 307 * was last accessed. | 334 * was last accessed. |
| 308 */ | 335 */ |
| 309 get lastAccessTime() { | 336 get lastAccessTime() { |
| 310 return this.lastAccessTime_; | 337 return this.lastAccessTime_; |
| 311 }, | 338 }, |
| 312 | 339 |
| 313 /** @return {string} Relative URL of the destination's icon. */ | 340 /** @return {string} Relative URL of the destination's icon. */ |
| 314 get iconUrl() { | 341 get iconUrl() { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 * }} | 414 * }} |
| 388 */ | 415 */ |
| 389 var Cdd = Object; | 416 var Cdd = Object; |
| 390 | 417 |
| 391 // Export | 418 // Export |
| 392 return { | 419 return { |
| 393 Destination: Destination, | 420 Destination: Destination, |
| 394 Cdd: Cdd | 421 Cdd: Cdd |
| 395 }; | 422 }; |
| 396 }); | 423 }); |
| OLD | NEW |