Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1939)

Unified Diff: chrome/browser/resources/options/chromeos/storage_manager.js

Issue 2041343002: Storage manager: Show overall size information and size of Downloads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and rebase on top of https://codereview.chromium.org/1995113002. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options/chromeos/storage_manager.js
diff --git a/chrome/browser/resources/options/chromeos/storage_manager.js b/chrome/browser/resources/options/chromeos/storage_manager.js
index 15d1b7389510e587446a3efe6b3c8cacf6a1157d..947645dc46a708c1de5d4a2bb9b1d2bee8228977 100644
--- a/chrome/browser/resources/options/chromeos/storage_manager.js
+++ b/chrome/browser/resources/options/chromeos/storage_manager.js
@@ -2,6 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+/**
+ * @typedef {{
+ * totalSize: string,
+ * availableSize: string,
+ * usedSize: string,
+ * usedRatio: number
+ * }}
+ */
+options.StorageSizeStat;
+
cr.define('options', function() {
var Page = cr.ui.pageManager.Page;
var PageManager = cr.ui.pageManager.PageManager;
@@ -21,12 +31,50 @@ cr.define('options', function() {
initializePage: function() {
Page.prototype.initializePage.call(this);
+ $('storage-manager-label-downloads').onclick = function() {
+ chrome.send('openDownloads');
+ };
+
$('storage-confirm').onclick = function() {
PageManager.closeOverlay();
};
- }
+ },
+
+ /** @override */
+ didShowPage: function() {
+ // Updating storage information can be expensive (e.g. computing directory
+ // sizes recursively), so we delay this operation until the page is shown.
+ chrome.send('updateStorageInfo');
+ },
+
+ /**
+ * Updates the size information (total/used/available) of the internal
+ * storage.
+ * @param {!options.StorageSizeStat} sizeStat
+ * @private
+ */
+ setSizeStat_: function(sizeStat) {
+ $('storage-manager-size-capacity').textContent = sizeStat.totalSize;
+ $('storage-manager-size-in-use').textContent = sizeStat.usedSize;
+ $('storage-manager-size-available').textContent = sizeStat.availableSize;
+ },
+
+ /**
+ * Updates the size Downloads directory.
+ * @param {string} size Formatted string of the size of Downloads.
+ * @private
+ */
+ setDownloadsSize_: function(size) {
+ $('storage-manager-size-downloads').textContent = size;
+ },
};
+ // Forward public APIs to private implementations.
+ cr.makePublic(StorageManager, [
+ 'setSizeStat',
+ 'setDownloadsSize',
+ ]);
+
return {
StorageManager: StorageManager
};

Powered by Google App Engine
This is Rietveld 408576698