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

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: Load roboto.css if chromeos 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
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 15 matching lines...) Expand all
26 int64_t* total_size, 26 int64_t* total_size,
27 int64_t* available_size) { 27 int64_t* available_size) {
28 int64_t size = base::SysInfo::AmountOfTotalDiskSpace(mount_path); 28 int64_t size = base::SysInfo::AmountOfTotalDiskSpace(mount_path);
29 if (size >= 0) 29 if (size >= 0)
30 *total_size = size; 30 *total_size = size;
31 size = base::SysInfo::AmountOfFreeDiskSpace(mount_path); 31 size = base::SysInfo::AmountOfFreeDiskSpace(mount_path);
32 if (size >= 0) 32 if (size >= 0)
33 *available_size = size; 33 *available_size = size;
34 } 34 }
35 35
36 // Threshold to show a message indicatiog space is critically low (512 MB).
Dan Beam 2016/06/21 01:39:56 indicatiog -> indicating
fukino 2016/06/21 22:21:50 Done.
37 const int64_t kSpaceCriticallyLowBytes = 512LL << 20;
Dan Beam 2016/06/21 01:39:56 512 * 1024 * 1024 would probably be more explana
fukino 2016/06/21 22:21:49 Done.
38
39 // Threshold to show a message indicatiog space is low (1 GB).
40 const int64_t kSpaceLowBytes = 1LL << 30;
Dan Beam 2016/06/21 01:39:56 same here: 1 * 1024 * 1024 * 1024
fukino 2016/06/21 22:21:49 Done.
41
36 } // namespace 42 } // namespace
37 43
38 StorageManagerHandler::StorageManagerHandler() : weak_ptr_factory_(this) { 44 StorageManagerHandler::StorageManagerHandler() : weak_ptr_factory_(this) {
39 } 45 }
40 46
41 StorageManagerHandler::~StorageManagerHandler() { 47 StorageManagerHandler::~StorageManagerHandler() {
42 } 48 }
43 49
44 void StorageManagerHandler::GetLocalizedValues( 50 void StorageManagerHandler::GetLocalizedValues(
45 base::DictionaryValue* localized_strings) { 51 base::DictionaryValue* localized_strings) {
(...skipping 13 matching lines...) Expand all
59 IDS_OPTIONS_SETTINGS_STORAGE_ITEM_LABEL_AVAILABLE)); 65 IDS_OPTIONS_SETTINGS_STORAGE_ITEM_LABEL_AVAILABLE));
60 localized_strings->SetString( 66 localized_strings->SetString(
61 "storageSubitemLabelDownloads", l10n_util::GetStringUTF16( 67 "storageSubitemLabelDownloads", l10n_util::GetStringUTF16(
62 IDS_OPTIONS_SETTINGS_STORAGE_SUBITEM_LABEL_DOWNLOADS)); 68 IDS_OPTIONS_SETTINGS_STORAGE_SUBITEM_LABEL_DOWNLOADS));
63 localized_strings->SetString( 69 localized_strings->SetString(
64 "storageSubitemLabelArc", l10n_util::GetStringUTF16( 70 "storageSubitemLabelArc", l10n_util::GetStringUTF16(
65 IDS_OPTIONS_SETTINGS_STORAGE_SUBITEM_LABEL_ARC)); 71 IDS_OPTIONS_SETTINGS_STORAGE_SUBITEM_LABEL_ARC));
66 localized_strings->SetString( 72 localized_strings->SetString(
67 "storageSizeCalculating", l10n_util::GetStringUTF16( 73 "storageSizeCalculating", l10n_util::GetStringUTF16(
68 IDS_OPTIONS_SETTINGS_STORAGE_SIZE_CALCULATING)); 74 IDS_OPTIONS_SETTINGS_STORAGE_SIZE_CALCULATING));
75 localized_strings->SetString(
76 "storageLowMessageTitle", l10n_util::GetStringUTF16(
77 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_LOW_MESSAGE_TITLE));
78 localized_strings->SetString(
79 "storageLowMessageLine1", l10n_util::GetStringUTF16(
80 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_LOW_MESSAGE_LINE_1));
81 localized_strings->SetString(
82 "storageLowMessageLine2", l10n_util::GetStringUTF16(
83 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_LOW_MESSAGE_LINE_2));
84 localized_strings->SetString(
85 "storageCriticallyLowMessageTitle", l10n_util::GetStringUTF16(
86 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_CRITICALLY_LOW_MESSAGE_TITLE));
87 localized_strings->SetString(
88 "storageCriticallyLowMessageLine1", l10n_util::GetStringUTF16(
89 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_CRITICALLY_LOW_MESSAGE_LINE_1));
90 localized_strings->SetString(
91 "storageCriticallyLowMessageLine2", l10n_util::GetStringUTF16(
92 IDS_OPTIONS_SETTINGS_STORAGE_SPACE_CRITICALLY_LOW_MESSAGE_LINE_2));
69 } 93 }
70 94
71 void StorageManagerHandler::InitializePage() { 95 void StorageManagerHandler::InitializePage() {
72 DCHECK(web_ui()); 96 DCHECK(web_ui());
73 } 97 }
74 98
75 void StorageManagerHandler::RegisterMessages() { 99 void StorageManagerHandler::RegisterMessages() {
76 DCHECK(web_ui()); 100 DCHECK(web_ui());
77 101
78 web_ui()->RegisterMessageCallback( 102 web_ui()->RegisterMessageCallback(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 158
135 void StorageManagerHandler::OnGetSizeStat(int64_t* total_size, 159 void StorageManagerHandler::OnGetSizeStat(int64_t* total_size,
136 int64_t* available_size) { 160 int64_t* available_size) {
137 int64_t used_size = *total_size - *available_size; 161 int64_t used_size = *total_size - *available_size;
138 base::DictionaryValue size_stat; 162 base::DictionaryValue size_stat;
139 size_stat.SetString("totalSize", ui::FormatBytes(*total_size)); 163 size_stat.SetString("totalSize", ui::FormatBytes(*total_size));
140 size_stat.SetString("availableSize", ui::FormatBytes(*available_size)); 164 size_stat.SetString("availableSize", ui::FormatBytes(*available_size));
141 size_stat.SetString("usedSize", ui::FormatBytes(used_size)); 165 size_stat.SetString("usedSize", ui::FormatBytes(used_size));
142 size_stat.SetDouble("usedRatio", 166 size_stat.SetDouble("usedRatio",
143 static_cast<double>(used_size) / *total_size); 167 static_cast<double>(used_size) / *total_size);
168 size_stat.SetBoolean("isSpaceLow", *available_size < kSpaceLowBytes);
Dan Beam 2016/06/21 01:39:56 nit: maybe make an enum?
fukino 2016/06/21 22:21:49 Done.
169 size_stat.SetBoolean("isSpaceCriticallyLow",
170 *available_size < kSpaceCriticallyLowBytes);
144 web_ui()->CallJavascriptFunctionUnsafe( 171 web_ui()->CallJavascriptFunctionUnsafe(
145 "options.StorageManager.setSizeStat", size_stat); 172 "options.StorageManager.setSizeStat", size_stat);
146 } 173 }
147 174
148 void StorageManagerHandler::UpdateDownloadsSize() { 175 void StorageManagerHandler::UpdateDownloadsSize() {
149 Profile* const profile = Profile::FromWebUI(web_ui()); 176 Profile* const profile = Profile::FromWebUI(web_ui());
150 const base::FilePath downloads_path = 177 const base::FilePath downloads_path =
151 file_manager::util::GetDownloadsFolderForProfile(profile); 178 file_manager::util::GetDownloadsFolderForProfile(profile);
152 179
153 base::PostTaskAndReplyWithResult( 180 base::PostTaskAndReplyWithResult(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 size->total_data_bytes + 224 size->total_data_bytes +
198 size->total_cache_bytes; 225 size->total_cache_bytes;
199 arc_size = base::StringValue(ui::FormatBytes(total_bytes)); 226 arc_size = base::StringValue(ui::FormatBytes(total_bytes));
200 } 227 }
201 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize", 228 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize",
202 arc_size); 229 arc_size);
203 } 230 }
204 231
205 } // namespace options 232 } // namespace options
206 } // namespace chromeos 233 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698