Chromium Code Reviews| Index: chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc b/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc |
| index d8214542295d0f302e500b5faf02ec2891c37112..55993c697242023aed2ed7e3c1de7aa74aa2f220 100644 |
| --- a/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc |
| +++ b/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc |
| @@ -35,6 +35,12 @@ void GetSizeStatOnBlockingPool(const base::FilePath& mount_path, |
| *available_size = size; |
| } |
| +// Threshold to show a message indicating space is critically low (512 MB). |
| +const int64_t kSpaceCriticallyLowBytes = 512LL * 1024 * 1024; |
| + |
| +// Threshold to show a message indicating space is low (1 GB). |
| +const int64_t kSpaceLowBytes = 1LL * 1024 * 1024 * 1024; |
| + |
| } // namespace |
| StorageManagerHandler::StorageManagerHandler() : weak_ptr_factory_(this) { |
| @@ -79,6 +85,24 @@ void StorageManagerHandler::GetLocalizedValues( |
| localized_strings->SetString( |
| "storageDeleteAllButtonTitle", l10n_util::GetStringUTF16( |
| IDS_OPTIONS_SETTINGS_STORAGE_DELETE_ALL_BUTTON_TITLE)); |
| + localized_strings->SetString( |
| + "storageLowMessageTitle", l10n_util::GetStringUTF16( |
| + IDS_OPTIONS_SETTINGS_STORAGE_SPACE_LOW_MESSAGE_TITLE)); |
| + localized_strings->SetString( |
| + "storageLowMessageLine1", l10n_util::GetStringUTF16( |
| + IDS_OPTIONS_SETTINGS_STORAGE_SPACE_LOW_MESSAGE_LINE_1)); |
| + localized_strings->SetString( |
| + "storageLowMessageLine2", l10n_util::GetStringUTF16( |
| + IDS_OPTIONS_SETTINGS_STORAGE_SPACE_LOW_MESSAGE_LINE_2)); |
| + localized_strings->SetString( |
| + "storageCriticallyLowMessageTitle", l10n_util::GetStringUTF16( |
| + IDS_OPTIONS_SETTINGS_STORAGE_SPACE_CRITICALLY_LOW_MESSAGE_TITLE)); |
| + localized_strings->SetString( |
| + "storageCriticallyLowMessageLine1", l10n_util::GetStringUTF16( |
| + IDS_OPTIONS_SETTINGS_STORAGE_SPACE_CRITICALLY_LOW_MESSAGE_LINE_1)); |
| + localized_strings->SetString( |
| + "storageCriticallyLowMessageLine2", l10n_util::GetStringUTF16( |
| + IDS_OPTIONS_SETTINGS_STORAGE_SPACE_CRITICALLY_LOW_MESSAGE_LINE_2)); |
| } |
| void StorageManagerHandler::InitializePage() { |
| @@ -169,6 +193,14 @@ void StorageManagerHandler::OnGetSizeStat(int64_t* total_size, |
| size_stat.SetString("usedSize", ui::FormatBytes(used_size)); |
| size_stat.SetDouble("usedRatio", |
| static_cast<double>(used_size) / *total_size); |
| + int storage_space_state = STORAGE_SPACE_NORMAL; |
| + if (*available_size < kSpaceCriticallyLowBytes) { |
| + storage_space_state = STORAGE_SPACE_CRITICALLY_LOW; |
| + } else if (*available_size < kSpaceLowBytes) { |
| + storage_space_state = STORAGE_SPACE_LOW; |
| + } |
|
Dan Beam
2016/06/22 00:11:27
nit: no curlies
fukino
2016/06/22 03:12:24
Done.
|
| + size_stat.SetInteger("spaceState", storage_space_state); |
| + |
| web_ui()->CallJavascriptFunctionUnsafe( |
| "options.StorageManager.setSizeStat", size_stat); |
| } |