| 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/settings/chromeos/device_storage_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/device_storage_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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 return; | 199 return; |
| 200 | 200 |
| 201 drive::FileSystemInterface* const file_system = | 201 drive::FileSystemInterface* const file_system = |
| 202 drive::util::GetFileSystemByProfile(Profile::FromWebUI(web_ui())); | 202 drive::util::GetFileSystemByProfile(Profile::FromWebUI(web_ui())); |
| 203 if (!file_system) | 203 if (!file_system) |
| 204 return; | 204 return; |
| 205 | 205 |
| 206 // Shows the item "Offline cache" and start calculating size. | 206 // Shows the item "Offline cache" and start calculating size. |
| 207 CallJavascriptFunction("cr.webUIListenerCallback", | 207 CallJavascriptFunction("cr.webUIListenerCallback", |
| 208 base::StringValue("storage-drive-enabled-changed"), | 208 base::StringValue("storage-drive-enabled-changed"), |
| 209 base::FundamentalValue(true)); | 209 base::Value(true)); |
| 210 updating_drive_cache_size_ = true; | 210 updating_drive_cache_size_ = true; |
| 211 file_system->CalculateCacheSize( | 211 file_system->CalculateCacheSize( |
| 212 base::Bind(&StorageHandler::OnGetDriveCacheSize, base::Unretained(this))); | 212 base::Bind(&StorageHandler::OnGetDriveCacheSize, base::Unretained(this))); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void StorageHandler::OnGetDriveCacheSize(int64_t size) { | 215 void StorageHandler::OnGetDriveCacheSize(int64_t size) { |
| 216 updating_drive_cache_size_ = false; | 216 updating_drive_cache_size_ = false; |
| 217 CallJavascriptFunction("cr.webUIListenerCallback", | 217 CallJavascriptFunction("cr.webUIListenerCallback", |
| 218 base::StringValue("storage-drive-cache-size-changed"), | 218 base::StringValue("storage-drive-cache-size-changed"), |
| 219 base::StringValue(ui::FormatBytes(size)), | 219 base::StringValue(ui::FormatBytes(size)), |
| 220 base::FundamentalValue(size > 0)); | 220 base::Value(size > 0)); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void StorageHandler::UpdateBrowsingDataSize() { | 223 void StorageHandler::UpdateBrowsingDataSize() { |
| 224 if (updating_browsing_data_size_) | 224 if (updating_browsing_data_size_) |
| 225 return; | 225 return; |
| 226 updating_browsing_data_size_ = true; | 226 updating_browsing_data_size_ = true; |
| 227 | 227 |
| 228 has_browser_cache_size_ = false; | 228 has_browser_cache_size_ = false; |
| 229 has_browser_site_data_size_ = false; | 229 has_browser_site_data_size_ = false; |
| 230 Profile* const profile = Profile::FromWebUI(web_ui()); | 230 Profile* const profile = Profile::FromWebUI(web_ui()); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 347 |
| 348 Profile* const profile = Profile::FromWebUI(web_ui()); | 348 Profile* const profile = Profile::FromWebUI(web_ui()); |
| 349 if (!arc::IsArcPlayStoreEnabledForProfile(profile) || | 349 if (!arc::IsArcPlayStoreEnabledForProfile(profile) || |
| 350 arc::IsArcOptInVerificationDisabled()) { | 350 arc::IsArcOptInVerificationDisabled()) { |
| 351 return; | 351 return; |
| 352 } | 352 } |
| 353 | 353 |
| 354 // Shows the item "Android apps and cache" and start calculating size. | 354 // Shows the item "Android apps and cache" and start calculating size. |
| 355 CallJavascriptFunction("cr.webUIListenerCallback", | 355 CallJavascriptFunction("cr.webUIListenerCallback", |
| 356 base::StringValue("storage-android-enabled-changed"), | 356 base::StringValue("storage-android-enabled-changed"), |
| 357 base::FundamentalValue(true)); | 357 base::Value(true)); |
| 358 bool success = arc::ArcStorageManager::Get()->GetApplicationsSize( | 358 bool success = arc::ArcStorageManager::Get()->GetApplicationsSize( |
| 359 base::Bind(&StorageHandler::OnGetAndroidSize, | 359 base::Bind(&StorageHandler::OnGetAndroidSize, |
| 360 base::Unretained(this))); | 360 base::Unretained(this))); |
| 361 if (!success) | 361 if (!success) |
| 362 updating_android_size_ = false; | 362 updating_android_size_ = false; |
| 363 } | 363 } |
| 364 | 364 |
| 365 void StorageHandler::OnGetAndroidSize(bool succeeded, | 365 void StorageHandler::OnGetAndroidSize(bool succeeded, |
| 366 arc::mojom::ApplicationsSizePtr size) { | 366 arc::mojom::ApplicationsSizePtr size) { |
| 367 base::string16 size_string; | 367 base::string16 size_string; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 379 base::StringValue("storage-android-size-changed"), | 379 base::StringValue("storage-android-size-changed"), |
| 380 base::StringValue(size_string)); | 380 base::StringValue(size_string)); |
| 381 } | 381 } |
| 382 | 382 |
| 383 void StorageHandler::OnClearDriveCacheDone(bool success) { | 383 void StorageHandler::OnClearDriveCacheDone(bool success) { |
| 384 UpdateDriveCacheSize(); | 384 UpdateDriveCacheSize(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace settings | 387 } // namespace settings |
| 388 } // namespace chromeos | 388 } // namespace chromeos |
| OLD | NEW |