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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Responsible for showing following banners in the file list. | 8 * Responsible for showing following banners in the file list. |
9 * - WelcomeBanner | 9 * - WelcomeBanner |
10 * - AuthFailBanner | 10 * - AuthFailBanner |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 parseInt(values[WELCOME_HEADER_COUNTER_KEY]) || 0; | 47 parseInt(values[WELCOME_HEADER_COUNTER_KEY]) || 0; |
48 this.warningDismissedCounter_ = | 48 this.warningDismissedCounter_ = |
49 parseInt(values[WARNING_DISMISSED_KEY]) || 0; | 49 parseInt(values[WARNING_DISMISSED_KEY]) || 0; |
50 }.bind(this)); | 50 }.bind(this)); |
51 | 51 |
52 this.authFailedBanner_ = | 52 this.authFailedBanner_ = |
53 this.document_.querySelector('#drive-auth-failed-warning'); | 53 this.document_.querySelector('#drive-auth-failed-warning'); |
54 var authFailedText = this.authFailedBanner_.querySelector('.drive-text'); | 54 var authFailedText = this.authFailedBanner_.querySelector('.drive-text'); |
55 authFailedText.innerHTML = util.htmlUnescape(str('DRIVE_NOT_REACHED')); | 55 authFailedText.innerHTML = util.htmlUnescape(str('DRIVE_NOT_REACHED')); |
56 authFailedText.querySelector('a').addEventListener('click', function(e) { | 56 authFailedText.querySelector('a').addEventListener('click', function(e) { |
57 chrome.fileBrowserPrivate.logoutUserForReauthentication(); | 57 chrome.fileManagerPrivate.logoutUserForReauthentication(); |
58 e.preventDefault(); | 58 e.preventDefault(); |
59 }); | 59 }); |
60 this.maybeShowAuthFailBanner_(); | 60 this.maybeShowAuthFailBanner_(); |
61 } | 61 } |
62 | 62 |
63 /** | 63 /** |
64 * FileListBannerController extends cr.EventTarget. | 64 * FileListBannerController extends cr.EventTarget. |
65 */ | 65 */ |
66 FileListBannerController.prototype.__proto__ = cr.EventTarget.prototype; | 66 FileListBannerController.prototype.__proto__ = cr.EventTarget.prototype; |
67 | 67 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 onCompleted(); | 340 onCompleted(); |
341 }.bind(this)); | 341 }.bind(this)); |
342 }.bind(this)); | 342 }.bind(this)); |
343 | 343 |
344 if (this.usePromoWelcomeBanner_) { | 344 if (this.usePromoWelcomeBanner_) { |
345 // getSizeStats for Drive file system accesses to the server, so we should | 345 // getSizeStats for Drive file system accesses to the server, so we should |
346 // minimize the invocation. | 346 // minimize the invocation. |
347 group.add(function(onCompleted) { | 347 group.add(function(onCompleted) { |
348 // Current directory must be set, since this code is called after | 348 // Current directory must be set, since this code is called after |
349 // scanning is completed. However, the volumeInfo may be gone. | 349 // scanning is completed. However, the volumeInfo may be gone. |
350 chrome.fileBrowserPrivate.getSizeStats( | 350 chrome.fileManagerPrivate.getSizeStats( |
351 driveVolume.volumeId, | 351 driveVolume.volumeId, |
352 function(result) { | 352 function(result) { |
353 if (result && result.totalSize >= offerSize * 1024 * 1024 * 1024) | 353 if (result && result.totalSize >= offerSize * 1024 * 1024 * 1024) |
354 this.usePromoWelcomeBanner_ = false; | 354 this.usePromoWelcomeBanner_ = false; |
355 onCompleted(); | 355 onCompleted(); |
356 }.bind(this)); | 356 }.bind(this)); |
357 }.bind(this)); | 357 }.bind(this)); |
358 } | 358 } |
359 | 359 |
360 group.run(this.maybeShowWelcomeBanner_.bind(this)); | 360 group.run(this.maybeShowWelcomeBanner_.bind(this)); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 this.volumeManager_.getVolumeInfo(event.previousDirEntry) : null; | 428 this.volumeManager_.getVolumeInfo(event.previousDirEntry) : null; |
429 | 429 |
430 // Show (or hide) the low space warning. | 430 // Show (or hide) the low space warning. |
431 this.maybeShowLowSpaceWarning_(rootVolume); | 431 this.maybeShowLowSpaceWarning_(rootVolume); |
432 | 432 |
433 // Add or remove listener to show low space warning, if necessary. | 433 // Add or remove listener to show low space warning, if necessary. |
434 var isLowSpaceWarningTarget = this.isLowSpaceWarningTarget_(rootVolume); | 434 var isLowSpaceWarningTarget = this.isLowSpaceWarningTarget_(rootVolume); |
435 if (isLowSpaceWarningTarget !== | 435 if (isLowSpaceWarningTarget !== |
436 this.isLowSpaceWarningTarget_(previousRootVolume)) { | 436 this.isLowSpaceWarningTarget_(previousRootVolume)) { |
437 if (isLowSpaceWarningTarget) { | 437 if (isLowSpaceWarningTarget) { |
438 chrome.fileBrowserPrivate.onDirectoryChanged.addListener( | 438 chrome.fileManagerPrivate.onDirectoryChanged.addListener( |
439 this.privateOnDirectoryChangedBound_); | 439 this.privateOnDirectoryChangedBound_); |
440 } else { | 440 } else { |
441 chrome.fileBrowserPrivate.onDirectoryChanged.removeListener( | 441 chrome.fileManagerPrivate.onDirectoryChanged.removeListener( |
442 this.privateOnDirectoryChangedBound_); | 442 this.privateOnDirectoryChangedBound_); |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 if (!this.isOnCurrentProfileDrive()) { | 446 if (!this.isOnCurrentProfileDrive()) { |
447 this.cleanupWelcomeBanner_(); | 447 this.cleanupWelcomeBanner_(); |
448 this.authFailedBanner_.hidden = true; | 448 this.authFailedBanner_.hidden = true; |
449 } | 449 } |
450 | 450 |
451 this.updateDriveUnmountedPanel_(); | 451 this.updateDriveUnmountedPanel_(); |
(...skipping 12 matching lines...) Expand all Loading... |
464 FileListBannerController.prototype.isLowSpaceWarningTarget_ = | 464 FileListBannerController.prototype.isLowSpaceWarningTarget_ = |
465 function(volumeInfo) { | 465 function(volumeInfo) { |
466 return volumeInfo && | 466 return volumeInfo && |
467 volumeInfo.profile.isCurrentProfile && | 467 volumeInfo.profile.isCurrentProfile && |
468 (volumeInfo.volumeType === VolumeManagerCommon.VolumeType.DOWNLOADS || | 468 (volumeInfo.volumeType === VolumeManagerCommon.VolumeType.DOWNLOADS || |
469 volumeInfo.volumeType === VolumeManagerCommon.VolumeType.DRIVE); | 469 volumeInfo.volumeType === VolumeManagerCommon.VolumeType.DRIVE); |
470 }; | 470 }; |
471 | 471 |
472 /** | 472 /** |
473 * Callback which is invoked when the file system has been changed. | 473 * Callback which is invoked when the file system has been changed. |
474 * @param {Object} event chrome.fileBrowserPrivate.onDirectoryChanged event. | 474 * @param {Object} event chrome.fileManagerPrivate.onDirectoryChanged event. |
475 * @private | 475 * @private |
476 */ | 476 */ |
477 FileListBannerController.prototype.privateOnDirectoryChanged_ = function( | 477 FileListBannerController.prototype.privateOnDirectoryChanged_ = function( |
478 event) { | 478 event) { |
479 if (!this.directoryModel_.getCurrentDirEntry()) | 479 if (!this.directoryModel_.getCurrentDirEntry()) |
480 return; | 480 return; |
481 | 481 |
482 var currentDirEntry = this.directoryModel_.getCurrentDirEntry(); | 482 var currentDirEntry = this.directoryModel_.getCurrentDirEntry(); |
483 var currentVolume = currentDirEntry && | 483 var currentVolume = currentDirEntry && |
484 this.volumeManager_.getVolumeInfo(currentDirEntry); | 484 this.volumeManager_.getVolumeInfo(currentDirEntry); |
(...skipping 28 matching lines...) Expand all Loading... |
513 // just hide the warning. | 513 // just hide the warning. |
514 this.showLowDownloadsSpaceWarning_(false); | 514 this.showLowDownloadsSpaceWarning_(false); |
515 this.showLowDriveSpaceWarning_(false); | 515 this.showLowDriveSpaceWarning_(false); |
516 return; | 516 return; |
517 } | 517 } |
518 | 518 |
519 // If not mounted correctly, then do not continue. | 519 // If not mounted correctly, then do not continue. |
520 if (!volume.fileSystem) | 520 if (!volume.fileSystem) |
521 return; | 521 return; |
522 | 522 |
523 chrome.fileBrowserPrivate.getSizeStats( | 523 chrome.fileManagerPrivate.getSizeStats( |
524 volume.volumeId, | 524 volume.volumeId, |
525 function(sizeStats) { | 525 function(sizeStats) { |
526 var currentVolume = this.volumeManager_.getVolumeInfo( | 526 var currentVolume = this.volumeManager_.getVolumeInfo( |
527 this.directoryModel_.getCurrentDirEntry()); | 527 this.directoryModel_.getCurrentDirEntry()); |
528 if (volume !== currentVolume) { | 528 if (volume !== currentVolume) { |
529 // This happens when the current directory is moved during requesting | 529 // This happens when the current directory is moved during requesting |
530 // the file system size. Just ignore it. | 530 // the file system size. Just ignore it. |
531 return; | 531 return; |
532 } | 532 } |
533 // sizeStats is undefined, if some error occurs. | 533 // sizeStats is undefined, if some error occurs. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 * @private | 660 * @private |
661 */ | 661 */ |
662 FileListBannerController.prototype.maybeShowAuthFailBanner_ = function() { | 662 FileListBannerController.prototype.maybeShowAuthFailBanner_ = function() { |
663 var connection = this.volumeManager_.getDriveConnectionState(); | 663 var connection = this.volumeManager_.getDriveConnectionState(); |
664 var showDriveNotReachedMessage = | 664 var showDriveNotReachedMessage = |
665 this.isOnCurrentProfileDrive() && | 665 this.isOnCurrentProfileDrive() && |
666 connection.type == VolumeManagerCommon.DriveConnectionType.OFFLINE && | 666 connection.type == VolumeManagerCommon.DriveConnectionType.OFFLINE && |
667 connection.reason == VolumeManagerCommon.DriveConnectionReason.NOT_READY; | 667 connection.reason == VolumeManagerCommon.DriveConnectionReason.NOT_READY; |
668 this.authFailedBanner_.hidden = !showDriveNotReachedMessage; | 668 this.authFailedBanner_.hidden = !showDriveNotReachedMessage; |
669 }; | 669 }; |
OLD | NEW |