| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |