| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * Enumeration for device state about remaining space. | 6 * Enumeration for device state about remaining space. |
| 7 * These values must be kept in sync with | 7 * These values must be kept in sync with |
| 8 * StorageManagerHandler::StorageSpaceState in C++ code. | 8 * StorageManagerHandler::StorageSpaceState in C++ code. |
| 9 * @enum {number} | 9 * @enum {number} |
| 10 * @const | 10 * @const |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * spaceState: options.StorageSpaceState, | 24 * spaceState: options.StorageSpaceState, |
| 25 * }} | 25 * }} |
| 26 */ | 26 */ |
| 27 options.StorageSizeStat; | 27 options.StorageSizeStat; |
| 28 | 28 |
| 29 cr.define('options', function() { | 29 cr.define('options', function() { |
| 30 var Page = cr.ui.pageManager.Page; | 30 var Page = cr.ui.pageManager.Page; |
| 31 var PageManager = cr.ui.pageManager.PageManager; | 31 var PageManager = cr.ui.pageManager.PageManager; |
| 32 | 32 |
| 33 function StorageManager() { | 33 function StorageManager() { |
| 34 Page.call(this, 'storage', | 34 Page.call( |
| 35 loadTimeData.getString('storageManagerPageTabTitle'), | 35 this, 'storage', loadTimeData.getString('storageManagerPageTabTitle'), |
| 36 'storageManagerPage'); | 36 'storageManagerPage'); |
| 37 } | 37 } |
| 38 | 38 |
| 39 cr.addSingletonGetter(StorageManager); | 39 cr.addSingletonGetter(StorageManager); |
| 40 | 40 |
| 41 StorageManager.prototype = { | 41 StorageManager.prototype = { |
| 42 __proto__: Page.prototype, | 42 __proto__: Page.prototype, |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Timer ID for periodical update. | 45 * Timer ID for periodical update. |
| 46 * @private {number} | 46 * @private {number} |
| 47 */ | 47 */ |
| 48 updateTimerId_: -1, | 48 updateTimerId_: -1, |
| 49 | 49 |
| 50 /** @override */ | 50 /** @override */ |
| 51 initializePage: function() { | 51 initializePage: function() { |
| 52 Page.prototype.initializePage.call(this); | 52 Page.prototype.initializePage.call(this); |
| 53 | 53 |
| 54 $('storage-manager-label-downloads').onclick = function() { | 54 $('storage-manager-label-downloads').onclick = function() { |
| 55 chrome.send('openDownloads'); | 55 chrome.send('openDownloads'); |
| 56 chrome.send('coreOptionsUserMetricsAction', | 56 chrome.send( |
| 57 ['Options_StorageOpenDownloads']); | 57 'coreOptionsUserMetricsAction', ['Options_StorageOpenDownloads']); |
| 58 }; | 58 }; |
| 59 $('storage-manager-label-drive-cache').onclick = function() { | 59 $('storage-manager-label-drive-cache').onclick = function() { |
| 60 PageManager.showPageByName('storageClearDriveCache'); | 60 PageManager.showPageByName('storageClearDriveCache'); |
| 61 chrome.send('coreOptionsUserMetricsAction', | 61 chrome.send( |
| 62 ['Options_StorageOpenClearDriveCache']); | 62 'coreOptionsUserMetricsAction', |
| 63 ['Options_StorageOpenClearDriveCache']); |
| 63 }; | 64 }; |
| 64 $('storage-manager-label-browsing-data').onclick = function() { | 65 $('storage-manager-label-browsing-data').onclick = function() { |
| 65 PageManager.showPageByName('clearBrowserData'); | 66 PageManager.showPageByName('clearBrowserData'); |
| 66 chrome.send('coreOptionsUserMetricsAction', | 67 chrome.send( |
| 67 ['Options_StorageOpenClearBrowsingData']); | 68 'coreOptionsUserMetricsAction', |
| 69 ['Options_StorageOpenClearBrowsingData']); |
| 68 }; | 70 }; |
| 69 $('storage-manager-label-arc').onclick = function() { | 71 $('storage-manager-label-arc').onclick = function() { |
| 70 chrome.send('openArcStorage'); | 72 chrome.send('openArcStorage'); |
| 71 chrome.send('coreOptionsUserMetricsAction', | 73 chrome.send( |
| 72 ['Options_StorageOpenAndroidStorage']); | 74 'coreOptionsUserMetricsAction', |
| 75 ['Options_StorageOpenAndroidStorage']); |
| 73 }; | 76 }; |
| 74 $('storage-manager-label-other-users').onclick = function() { | 77 $('storage-manager-label-other-users').onclick = function() { |
| 75 PageManager.showPageByName('accounts'); | 78 PageManager.showPageByName('accounts'); |
| 76 chrome.send('coreOptionsUserMetricsAction', | 79 chrome.send( |
| 77 ['Options_StorageOpenAccounts']); | 80 'coreOptionsUserMetricsAction', ['Options_StorageOpenAccounts']); |
| 78 }; | 81 }; |
| 79 | 82 |
| 80 $('storage-confirm').onclick = function() { | 83 $('storage-confirm').onclick = function() { |
| 81 PageManager.closeOverlay(); | 84 PageManager.closeOverlay(); |
| 82 }; | 85 }; |
| 83 }, | 86 }, |
| 84 | 87 |
| 85 /** @override */ | 88 /** @override */ |
| 86 didShowPage: function() { | 89 didShowPage: function() { |
| 87 // Updating storage information can be expensive (e.g. computing directory | 90 // Updating storage information can be expensive (e.g. computing directory |
| (...skipping 12 matching lines...) Expand all Loading... |
| 100 * Updates the size information (total/used/available) of the internal | 103 * Updates the size information (total/used/available) of the internal |
| 101 * storage. | 104 * storage. |
| 102 * @param {!options.StorageSizeStat} sizeStat | 105 * @param {!options.StorageSizeStat} sizeStat |
| 103 * @private | 106 * @private |
| 104 */ | 107 */ |
| 105 setSizeStat_: function(sizeStat) { | 108 setSizeStat_: function(sizeStat) { |
| 106 $('storage-manager-size-capacity').textContent = sizeStat.totalSize; | 109 $('storage-manager-size-capacity').textContent = sizeStat.totalSize; |
| 107 $('storage-manager-size-in-use').textContent = sizeStat.usedSize; | 110 $('storage-manager-size-in-use').textContent = sizeStat.usedSize; |
| 108 $('storage-manager-size-available').textContent = sizeStat.availableSize; | 111 $('storage-manager-size-available').textContent = sizeStat.availableSize; |
| 109 $('storage-bar-progress').setAttribute('value', sizeStat.usedRatio); | 112 $('storage-bar-progress').setAttribute('value', sizeStat.usedRatio); |
| 110 $('storageManagerPage').classList.toggle('low-space', | 113 $('storageManagerPage') |
| 111 sizeStat.spaceState == | 114 .classList.toggle( |
| 112 options.StorageSpaceState.STORAGE_SPACE_LOW); | 115 'low-space', |
| 113 $('storageManagerPage').classList.toggle('critically-low-space', | 116 sizeStat.spaceState == |
| 114 sizeStat.spaceState == | 117 options.StorageSpaceState.STORAGE_SPACE_LOW); |
| 115 options.StorageSpaceState.STORAGE_SPACE_CRITICALLY_LOW); | 118 $('storageManagerPage') |
| 119 .classList.toggle( |
| 120 'critically-low-space', |
| 121 sizeStat.spaceState == |
| 122 options.StorageSpaceState.STORAGE_SPACE_CRITICALLY_LOW); |
| 116 }, | 123 }, |
| 117 | 124 |
| 118 /** | 125 /** |
| 119 * Updates the size Downloads directory. | 126 * Updates the size Downloads directory. |
| 120 * @param {string} size Formatted string of the size of Downloads. | 127 * @param {string} size Formatted string of the size of Downloads. |
| 121 * @private | 128 * @private |
| 122 */ | 129 */ |
| 123 setDownloadsSize_: function(size) { | 130 setDownloadsSize_: function(size) { |
| 124 $('storage-manager-size-downloads').textContent = size; | 131 $('storage-manager-size-downloads').textContent = size; |
| 125 }, | 132 }, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 'setArcSize', | 217 'setArcSize', |
| 211 'setBrowsingDataSize', | 218 'setBrowsingDataSize', |
| 212 'setDownloadsSize', | 219 'setDownloadsSize', |
| 213 'setDriveCacheSize', | 220 'setDriveCacheSize', |
| 214 'setOtherUsersSize', | 221 'setOtherUsersSize', |
| 215 'setSizeStat', | 222 'setSizeStat', |
| 216 'showArcItem', | 223 'showArcItem', |
| 217 'showDriveCacheItem', | 224 'showDriveCacheItem', |
| 218 ]); | 225 ]); |
| 219 | 226 |
| 220 return { | 227 return {StorageManager: StorageManager}; |
| 221 StorageManager: StorageManager | |
| 222 }; | |
| 223 }); | 228 }); |
| OLD | NEW |