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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc

Issue 2078153002: Storage manager: Add conditional messages for disk low situation and update design. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments and rebase. 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
(...skipping 17 matching lines...) Expand all
28 int64_t* total_size, 28 int64_t* total_size,
29 int64_t* available_size) { 29 int64_t* available_size) {
30 int64_t size = base::SysInfo::AmountOfTotalDiskSpace(mount_path); 30 int64_t size = base::SysInfo::AmountOfTotalDiskSpace(mount_path);
31 if (size >= 0) 31 if (size >= 0)
32 *total_size = size; 32 *total_size = size;
33 size = base::SysInfo::AmountOfFreeDiskSpace(mount_path); 33 size = base::SysInfo::AmountOfFreeDiskSpace(mount_path);
34 if (size >= 0) 34 if (size >= 0)
35 *available_size = size; 35 *available_size = size;
36 } 36 }
37 37
38 // Threshold to show a message indicating space is critically low (512 MB).
39 const int64_t kSpaceCriticallyLowBytes = 512LL * 1024 * 1024;
40
41 // Threshold to show a message indicating space is low (1 GB).
42 const int64_t kSpaceLowBytes = 1LL * 1024 * 1024 * 1024;
43
38 } // namespace 44 } // namespace
39 45
40 StorageManagerHandler::StorageManagerHandler() : weak_ptr_factory_(this) { 46 StorageManagerHandler::StorageManagerHandler() : weak_ptr_factory_(this) {
41 } 47 }
42 48
43 StorageManagerHandler::~StorageManagerHandler() { 49 StorageManagerHandler::~StorageManagerHandler() {
44 } 50 }
45 51
46 void StorageManagerHandler::GetLocalizedValues( 52 void StorageManagerHandler::GetLocalizedValues(
47 base::DictionaryValue* localized_strings) { 53 base::DictionaryValue* localized_strings) {
(...skipping 24 matching lines...) Expand all
72 IDS_OPTIONS_SETTINGS_STORAGE_SUBITEM_LABEL_ARC)); 78 IDS_OPTIONS_SETTINGS_STORAGE_SUBITEM_LABEL_ARC));
73 localized_strings->SetString( 79 localized_strings->SetString(
74 "storageSizeCalculating", l10n_util::GetStringUTF16( 80 "storageSizeCalculating", l10n_util::GetStringUTF16(
75 IDS_OPTIONS_SETTINGS_STORAGE_SIZE_CALCULATING)); 81 IDS_OPTIONS_SETTINGS_STORAGE_SIZE_CALCULATING));
76 localized_strings->SetString( 82 localized_strings->SetString(
77 "storageClearDriveCacheDescription", l10n_util::GetStringUTF16( 83 "storageClearDriveCacheDescription", l10n_util::GetStringUTF16(
78 IDS_OPTIONS_SETTINGS_STORAGE_CLEAR_DRIVE_CACHE_DESCRIPTION)); 84 IDS_OPTIONS_SETTINGS_STORAGE_CLEAR_DRIVE_CACHE_DESCRIPTION));
79 localized_strings->SetString( 85 localized_strings->SetString(
80 "storageDeleteAllButtonTitle", l10n_util::GetStringUTF16( 86 "storageDeleteAllButtonTitle", l10n_util::GetStringUTF16(
81 IDS_OPTIONS_SETTINGS_STORAGE_DELETE_ALL_BUTTON_TITLE)); 87 IDS_OPTIONS_SETTINGS_STORAGE_DELETE_ALL_BUTTON_TITLE));
88 localized_strings->SetString(
89 "storageLowMessageTitle", l10n_util::GetStringUTF16(
90 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_LOW_MESSAGE_TITLE));
91 localized_strings->SetString(
92 "storageLowMessageLine1", l10n_util::GetStringUTF16(
93 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_LOW_MESSAGE_LINE_1));
94 localized_strings->SetString(
95 "storageLowMessageLine2", l10n_util::GetStringUTF16(
96 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_LOW_MESSAGE_LINE_2));
97 localized_strings->SetString(
98 "storageCriticallyLowMessageTitle", l10n_util::GetStringUTF16(
99 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_CRITICALLY_LOW_MESSAGE_TITLE));
100 localized_strings->SetString(
101 "storageCriticallyLowMessageLine1", l10n_util::GetStringUTF16(
102 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_CRITICALLY_LOW_MESSAGE_LINE_1));
103 localized_strings->SetString(
104 "storageCriticallyLowMessageLine2", l10n_util::GetStringUTF16(
105 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_CRITICALLY_LOW_MESSAGE_LINE_2));
82 } 106 }
83 107
84 void StorageManagerHandler::InitializePage() { 108 void StorageManagerHandler::InitializePage() {
85 DCHECK(web_ui()); 109 DCHECK(web_ui());
86 } 110 }
87 111
88 void StorageManagerHandler::RegisterMessages() { 112 void StorageManagerHandler::RegisterMessages() {
89 DCHECK(web_ui()); 113 DCHECK(web_ui());
90 114
91 web_ui()->RegisterMessageCallback( 115 web_ui()->RegisterMessageCallback(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 186
163 void StorageManagerHandler::OnGetSizeStat(int64_t* total_size, 187 void StorageManagerHandler::OnGetSizeStat(int64_t* total_size,
164 int64_t* available_size) { 188 int64_t* available_size) {
165 int64_t used_size = *total_size - *available_size; 189 int64_t used_size = *total_size - *available_size;
166 base::DictionaryValue size_stat; 190 base::DictionaryValue size_stat;
167 size_stat.SetString("totalSize", ui::FormatBytes(*total_size)); 191 size_stat.SetString("totalSize", ui::FormatBytes(*total_size));
168 size_stat.SetString("availableSize", ui::FormatBytes(*available_size)); 192 size_stat.SetString("availableSize", ui::FormatBytes(*available_size));
169 size_stat.SetString("usedSize", ui::FormatBytes(used_size)); 193 size_stat.SetString("usedSize", ui::FormatBytes(used_size));
170 size_stat.SetDouble("usedRatio", 194 size_stat.SetDouble("usedRatio",
171 static_cast<double>(used_size) / *total_size); 195 static_cast<double>(used_size) / *total_size);
196 int storage_space_state = STORAGE_SPACE_NORMAL;
197 if (*available_size < kSpaceCriticallyLowBytes) {
198 storage_space_state = STORAGE_SPACE_CRITICALLY_LOW;
199 } else if (*available_size < kSpaceLowBytes) {
200 storage_space_state = STORAGE_SPACE_LOW;
201 }
Dan Beam 2016/06/22 00:11:27 nit: no curlies
fukino 2016/06/22 03:12:24 Done.
202 size_stat.SetInteger("spaceState", storage_space_state);
203
172 web_ui()->CallJavascriptFunctionUnsafe( 204 web_ui()->CallJavascriptFunctionUnsafe(
173 "options.StorageManager.setSizeStat", size_stat); 205 "options.StorageManager.setSizeStat", size_stat);
174 } 206 }
175 207
176 void StorageManagerHandler::UpdateDownloadsSize() { 208 void StorageManagerHandler::UpdateDownloadsSize() {
177 Profile* const profile = Profile::FromWebUI(web_ui()); 209 Profile* const profile = Profile::FromWebUI(web_ui());
178 const base::FilePath downloads_path = 210 const base::FilePath downloads_path =
179 file_manager::util::GetDownloadsFolderForProfile(profile); 211 file_manager::util::GetDownloadsFolderForProfile(profile);
180 212
181 base::PostTaskAndReplyWithResult( 213 base::PostTaskAndReplyWithResult(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize", 275 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize",
244 arc_size); 276 arc_size);
245 } 277 }
246 278
247 void StorageManagerHandler::OnClearDriveCacheDone(bool success) { 279 void StorageManagerHandler::OnClearDriveCacheDone(bool success) {
248 UpdateDriveCacheSize(); 280 UpdateDriveCacheSize();
249 } 281 }
250 282
251 } // namespace options 283 } // namespace options
252 } // namespace chromeos 284 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698