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

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

Issue 2133063002: Storage manager: Show "0 B" as the total size of other users when there is no other user. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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 | « no previous file | 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 <algorithm> 7 #include <algorithm>
8 #include <numeric> 8 #include <numeric>
9 #include <string> 9 #include <string>
10 10
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 user_manager::UserManager::Get()->GetUsers(); 364 user_manager::UserManager::Get()->GetUsers();
365 for (const auto& user : users) { 365 for (const auto& user : users) {
366 if (user->is_active()) 366 if (user->is_active())
367 continue; 367 continue;
368 other_users_.push_back(user); 368 other_users_.push_back(user);
369 cryptohome::HomedirMethods::GetInstance()->GetAccountDiskUsage( 369 cryptohome::HomedirMethods::GetInstance()->GetAccountDiskUsage(
370 cryptohome::Identification(user->GetAccountId()), 370 cryptohome::Identification(user->GetAccountId()),
371 base::Bind(&StorageManagerHandler::OnGetOtherUserSize, 371 base::Bind(&StorageManagerHandler::OnGetOtherUserSize,
372 weak_ptr_factory_.GetWeakPtr())); 372 weak_ptr_factory_.GetWeakPtr()));
373 } 373 }
374 // We should show "0 B" if there is no other user.
375 if (other_users_.empty()) {
376 updating_other_users_size_ = false;
377 web_ui()->CallJavascriptFunctionUnsafe(
378 "options.StorageManager.setOtherUsersSize",
379 base::StringValue(ui::FormatBytes(0)));
380 }
374 } 381 }
375 382
376 void StorageManagerHandler::OnGetOtherUserSize(bool success, int64_t size) { 383 void StorageManagerHandler::OnGetOtherUserSize(bool success, int64_t size) {
377 user_sizes_.push_back(success ? size : -1); 384 user_sizes_.push_back(success ? size : -1);
378 if (user_sizes_.size() == other_users_.size()) { 385 if (user_sizes_.size() == other_users_.size()) {
379 base::string16 size_string; 386 base::string16 size_string;
380 // If all the requests succeed, shows the total bytes in the UI. 387 // If all the requests succeed, shows the total bytes in the UI.
381 if (std::count(user_sizes_.begin(), user_sizes_.end(), -1) == 0) { 388 if (std::count(user_sizes_.begin(), user_sizes_.end(), -1) == 0) {
382 size_string = ui::FormatBytes( 389 size_string = ui::FormatBytes(
383 std::accumulate(user_sizes_.begin(), user_sizes_.end(), 0LL)); 390 std::accumulate(user_sizes_.begin(), user_sizes_.end(), 0LL));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize", 437 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize",
431 base::StringValue(size_string)); 438 base::StringValue(size_string));
432 } 439 }
433 440
434 void StorageManagerHandler::OnClearDriveCacheDone(bool success) { 441 void StorageManagerHandler::OnClearDriveCacheDone(bool success) {
435 UpdateDriveCacheSize(); 442 UpdateDriveCacheSize();
436 } 443 }
437 444
438 } // namespace options 445 } // namespace options
439 } // namespace chromeos 446 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698