| 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 // This variable is checked in SelectFileDialogExtensionBrowserTest. | 5 // This variable is checked in SelectFileDialogExtensionBrowserTest. |
| 6 var JSErrorCount = 0; | 6 var JSErrorCount = 0; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Count uncaught exceptions. | 9 * Count uncaught exceptions. |
| 10 */ | 10 */ |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 /** | 120 /** |
| 121 * List of reasons of DriveConnectionType. | 121 * List of reasons of DriveConnectionType. |
| 122 * | 122 * |
| 123 * Keep this in sync with the kDriveConnectionReason constants in | 123 * Keep this in sync with the kDriveConnectionReason constants in |
| 124 * file_browser_private_api.cc. | 124 * file_browser_private_api.cc. |
| 125 * | 125 * |
| 126 * @enum {string} | 126 * @enum {string} |
| 127 */ | 127 */ |
| 128 var DriveConnectionReason = { | 128 var DriveConnectionReason = { |
| 129 NOT_READY: 'not_ready', // Drive is not ready or authentication is failed. | 129 NOT_READY: 'not_ready', // Drive is not ready or authentication is failed. |
| 130 NO_NETWORK: 'no_network', // Network connection is unavailable. | 130 NO_NETWORK: 'no_network', // Network connection is unavailable. |
| 131 NO_SERVICE: 'no_service' // Drive service is unavailable. |
| 131 }; | 132 }; |
| 132 | 133 |
| 133 /** | 134 /** |
| 134 * @param {string} type Dialog type. | 135 * @param {string} type Dialog type. |
| 135 * @return {boolean} Whether the type is modal. | 136 * @return {boolean} Whether the type is modal. |
| 136 */ | 137 */ |
| 137 DialogType.isModal = function(type) { | 138 DialogType.isModal = function(type) { |
| 138 return type == DialogType.SELECT_FOLDER || | 139 return type == DialogType.SELECT_FOLDER || |
| 139 type == DialogType.SELECT_SAVEAS_FILE || | 140 type == DialogType.SELECT_SAVEAS_FILE || |
| 140 type == DialogType.SELECT_OPEN_FILE || | 141 type == DialogType.SELECT_OPEN_FILE || |
| (...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 var done = function() { | 1679 var done = function() { |
| 1679 if (--downcount == 0) | 1680 if (--downcount == 0) |
| 1680 callback(); | 1681 callback(); |
| 1681 }; | 1682 }; |
| 1682 | 1683 |
| 1683 chrome.fileBrowserPrivate.getPreferences(function(prefs) { | 1684 chrome.fileBrowserPrivate.getPreferences(function(prefs) { |
| 1684 self.preferences_ = prefs; | 1685 self.preferences_ = prefs; |
| 1685 done(); | 1686 done(); |
| 1686 }); | 1687 }); |
| 1687 | 1688 |
| 1688 chrome.fileBrowserPrivate.getDriveConnectionState(function(networkState) { | 1689 chrome.fileBrowserPrivate.getDriveConnectionState(function(state) { |
| 1689 self.networkState_ = networkState; | 1690 self.driveConnectionState_ = state; |
| 1690 done(); | 1691 done(); |
| 1691 }); | 1692 }); |
| 1692 }; | 1693 }; |
| 1693 | 1694 |
| 1694 FileManager.prototype.onNetworkStateOrPreferencesChanged_ = function() { | 1695 FileManager.prototype.onNetworkStateOrPreferencesChanged_ = function() { |
| 1695 var self = this; | 1696 var self = this; |
| 1696 this.updateNetworkStateAndPreferences_(function() { | 1697 this.updateNetworkStateAndPreferences_(function() { |
| 1697 var drive = self.preferences_; | 1698 var drive = self.preferences_; |
| 1698 var network = self.networkState_; | 1699 var connection = self.driveConnectionState_; |
| 1699 | 1700 |
| 1700 self.initDateTimeFormatters_(); | 1701 self.initDateTimeFormatters_(); |
| 1701 self.refreshCurrentDirectoryMetadata_(); | 1702 self.refreshCurrentDirectoryMetadata_(); |
| 1702 | 1703 |
| 1703 self.directoryModel_.setDriveEnabled(self.isDriveEnabled()); | 1704 self.directoryModel_.setDriveEnabled(self.isDriveEnabled()); |
| 1704 self.directoryModel_.setDriveOffline(network.type == 'offline'); | 1705 self.directoryModel_.setDriveOffline(connection.type == 'offline'); |
| 1705 | 1706 |
| 1706 if (drive.cellularDisabled) | 1707 if (drive.cellularDisabled) |
| 1707 self.syncButton.setAttribute('checked', ''); | 1708 self.syncButton.setAttribute('checked', ''); |
| 1708 else | 1709 else |
| 1709 self.syncButton.removeAttribute('checked'); | 1710 self.syncButton.removeAttribute('checked'); |
| 1710 | 1711 |
| 1711 if (self.hostedButton.hasAttribute('checked') != | 1712 if (self.hostedButton.hasAttribute('checked') != |
| 1712 drive.hostedFilesDisabled && self.isOnDrive()) { | 1713 drive.hostedFilesDisabled && self.isOnDrive()) { |
| 1713 self.directoryModel_.rescan(); | 1714 self.directoryModel_.rescan(); |
| 1714 } | 1715 } |
| 1715 | 1716 |
| 1716 if (!drive.hostedFilesDisabled) | 1717 if (!drive.hostedFilesDisabled) |
| 1717 self.hostedButton.setAttribute('checked', ''); | 1718 self.hostedButton.setAttribute('checked', ''); |
| 1718 else | 1719 else |
| 1719 self.hostedButton.removeAttribute('checked'); | 1720 self.hostedButton.removeAttribute('checked'); |
| 1720 | 1721 |
| 1721 switch (network.type) { | 1722 switch (connection.type) { |
| 1722 case DriveConnectionType.ONLINE: | 1723 case DriveConnectionType.ONLINE: |
| 1723 self.dialogContainer_.removeAttribute('connection'); | 1724 self.dialogContainer_.removeAttribute('connection'); |
| 1724 break; | 1725 break; |
| 1725 case DriveConnectionType.METERED: | 1726 case DriveConnectionType.METERED: |
| 1726 self.dialogContainer_.setAttribute('connection', 'metered'); | 1727 self.dialogContainer_.setAttribute('connection', 'metered'); |
| 1727 break; | 1728 break; |
| 1728 case DriveConnectionType.OFFLINE: | 1729 case DriveConnectionType.OFFLINE: |
| 1729 self.dialogContainer_.setAttribute('connection', 'offline'); | 1730 self.dialogContainer_.setAttribute('connection', 'offline'); |
| 1730 break; | 1731 break; |
| 1731 default: | 1732 default: |
| 1732 console.assert(true, 'unknown connection type.'); | 1733 console.assert(true, 'unknown connection type.'); |
| 1733 } | 1734 } |
| 1734 }); | 1735 }); |
| 1735 }; | 1736 }; |
| 1736 | 1737 |
| 1737 /** | 1738 /** |
| 1738 * Get the metered status of network. | 1739 * Get the metered status of Drive connection. |
| 1739 * | 1740 * |
| 1740 * @return {boolean} Returns true if drive should limit the traffic because | 1741 * @return {boolean} Returns true if drive should limit the traffic because |
| 1741 * the connection is metered and the 'disable-sync-on-metered' setting is | 1742 * the connection is metered and the 'disable-sync-on-metered' setting is |
| 1742 * enabled. Otherwise, returns false. | 1743 * enabled. Otherwise, returns false. |
| 1743 */ | 1744 */ |
| 1744 FileManager.prototype.isDriveOnMeteredConnection = function() { | 1745 FileManager.prototype.isDriveOnMeteredConnection = function() { |
| 1745 return this.networkState_.type == DriveConnectionType.METERED; | 1746 return this.driveConnectionState_.type == DriveConnectionType.METERED; |
| 1746 }; | 1747 }; |
| 1747 | 1748 |
| 1748 /** | 1749 /** |
| 1749 * Get the online/offline status of drive. | 1750 * Get the online/offline status of drive. |
| 1750 * | 1751 * |
| 1751 * @return {boolean} Returns true if the connection is offline. Otherwise, | 1752 * @return {boolean} Returns true if the connection is offline. Otherwise, |
| 1752 * returns false. | 1753 * returns false. |
| 1753 */ | 1754 */ |
| 1754 FileManager.prototype.isDriveOffline = function() { | 1755 FileManager.prototype.isDriveOffline = function() { |
| 1755 return this.networkState_.type == DriveConnectionType.OFFLINE; | 1756 return this.driveConnectionState_.type == DriveConnectionType.OFFLINE; |
| 1756 }; | 1757 }; |
| 1757 | 1758 |
| 1758 FileManager.prototype.isDriveEnabled = function() { | 1759 FileManager.prototype.isDriveEnabled = function() { |
| 1759 return !this.params_.disableDrive && | 1760 return !this.params_.disableDrive && |
| 1760 (!('driveEnabled' in this.preferences_) || | 1761 (!('driveEnabled' in this.preferences_) || |
| 1761 this.preferences_.driveEnabled); | 1762 this.preferences_.driveEnabled); |
| 1762 }; | 1763 }; |
| 1763 | 1764 |
| 1764 FileManager.prototype.isOnReadonlyDirectory = function() { | 1765 FileManager.prototype.isOnReadonlyDirectory = function() { |
| 1765 return this.directoryModel_.isReadOnly(); | 1766 return this.directoryModel_.isReadOnly(); |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2954 return this.directoryModel_.getFileList(); | 2955 return this.directoryModel_.getFileList(); |
| 2955 }; | 2956 }; |
| 2956 | 2957 |
| 2957 /** | 2958 /** |
| 2958 * @return {cr.ui.List} Current list object. | 2959 * @return {cr.ui.List} Current list object. |
| 2959 */ | 2960 */ |
| 2960 FileManager.prototype.getCurrentList = function() { | 2961 FileManager.prototype.getCurrentList = function() { |
| 2961 return this.currentList_; | 2962 return this.currentList_; |
| 2962 }; | 2963 }; |
| 2963 })(); | 2964 })(); |
| OLD | NEW |