Chromium Code Reviews| 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 /** | |
| 6 * @typedef {{ | |
| 7 * totalSize: string, | |
| 8 * availableSize: string, | |
| 9 * usedSize: string, | |
| 10 * usedRatio: number | |
| 11 * }} | |
| 12 */ | |
| 13 options.StorageSizeStat; | |
| 14 | |
| 5 cr.define('options', function() { | 15 cr.define('options', function() { |
| 6 var Page = cr.ui.pageManager.Page; | 16 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; | 17 var PageManager = cr.ui.pageManager.PageManager; |
| 8 | 18 |
| 9 function StorageManager() { | 19 function StorageManager() { |
| 10 Page.call(this, 'storage', | 20 Page.call(this, 'storage', |
| 11 loadTimeData.getString('storageManagerPageTabTitle'), | 21 loadTimeData.getString('storageManagerPageTabTitle'), |
| 12 'storageManagerPage'); | 22 'storageManagerPage'); |
| 13 } | 23 } |
| 14 | 24 |
| 15 cr.addSingletonGetter(StorageManager); | 25 cr.addSingletonGetter(StorageManager); |
| 16 | 26 |
| 17 StorageManager.prototype = { | 27 StorageManager.prototype = { |
| 18 __proto__: Page.prototype, | 28 __proto__: Page.prototype, |
| 19 | 29 |
| 20 /** @override */ | 30 /** @override */ |
| 21 initializePage: function() { | 31 initializePage: function() { |
| 22 Page.prototype.initializePage.call(this); | 32 Page.prototype.initializePage.call(this); |
| 23 | 33 |
| 34 $('storage-manager-label-downloads').onclick = function() { | |
| 35 chrome.send('openDownloads'); | |
| 36 }; | |
| 37 | |
| 24 $('storage-confirm').onclick = function() { | 38 $('storage-confirm').onclick = function() { |
| 25 PageManager.closeOverlay(); | 39 PageManager.closeOverlay(); |
| 26 }; | 40 }; |
| 27 } | 41 }, |
| 42 | |
| 43 /** @override */ | |
| 44 didShowPage: function() { | |
| 45 // Updating storage information can be expensive (e.g. computing directory | |
| 46 // sizes recursively), so we delay this operation until the page is shown. | |
| 47 chrome.send('updateStorageInfo'); | |
| 48 }, | |
| 49 | |
| 50 /** | |
| 51 * Updates the size information (total/used/available) of the internal | |
| 52 * storage. | |
| 53 * @param {!options.StorageSizeStat} sizeStat | |
| 54 * @private | |
| 55 */ | |
| 56 setSizeStat_: function(sizeStat) { | |
| 57 $('storage-manager-size-capacity').innerHTML = sizeStat.totalSize; | |
|
Dan Beam
2016/06/09 04:49:40
can you use textContent instead?
fukino
2016/06/09 15:39:38
Done.
| |
| 58 $('storage-manager-size-in-use').innerHTML = sizeStat.usedSize; | |
| 59 $('storage-manager-size-available').innerHTML = sizeStat.availableSize; | |
| 60 }, | |
| 61 | |
| 62 /** | |
| 63 * Updates the size Downloads directory. | |
| 64 * @param {string} size Formatted string of the size of Downloads. | |
| 65 * @private | |
| 66 */ | |
| 67 setDownloadsSize_: function(size) { | |
| 68 $('storage-manager-size-downloads').innerHTML = size; | |
| 69 }, | |
| 28 }; | 70 }; |
| 29 | 71 |
| 72 // Forward public APIs to private implementations. | |
| 73 cr.makePublic(StorageManager, [ | |
| 74 'setSizeStat', | |
| 75 'setDownloadsSize', | |
| 76 ]); | |
| 77 | |
| 30 return { | 78 return { |
| 31 StorageManager: StorageManager | 79 StorageManager: StorageManager |
| 32 }; | 80 }; |
| 33 }); | 81 }); |
| OLD | NEW |