OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/drive_internals_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // Called when the page is first loaded. | 185 // Called when the page is first loaded. |
186 void OnPageLoaded(const base::ListValue* args); | 186 void OnPageLoaded(const base::ListValue* args); |
187 | 187 |
188 // Updates respective sections. | 188 // Updates respective sections. |
189 void UpdateDriveRelatedFlagsSection(); | 189 void UpdateDriveRelatedFlagsSection(); |
190 void UpdateDriveRelatedPreferencesSection(); | 190 void UpdateDriveRelatedPreferencesSection(); |
191 void UpdateAuthStatusSection( | 191 void UpdateAuthStatusSection( |
192 google_apis::DriveServiceInterface* drive_service); | 192 google_apis::DriveServiceInterface* drive_service); |
193 void UpdateAccountMetadataSection( | 193 void UpdateAccountMetadataSection( |
194 google_apis::DriveServiceInterface* drive_service); | 194 google_apis::DriveServiceInterface* drive_service); |
| 195 void UpdateDeltaUpdateStatusSection(); |
195 void UpdateInFlightOperationsSection( | 196 void UpdateInFlightOperationsSection( |
196 google_apis::DriveServiceInterface* drive_service); | 197 google_apis::DriveServiceInterface* drive_service); |
197 void UpdateGCacheContentsSection(); | 198 void UpdateGCacheContentsSection(); |
198 void UpdateFileSystemContentsSection( | 199 void UpdateFileSystemContentsSection( |
199 google_apis::DriveServiceInterface* drive_service); | 200 google_apis::DriveServiceInterface* drive_service); |
200 void UpdateLocalStorageUsageSection(); | 201 void UpdateLocalStorageUsageSection(); |
201 void UpdateCacheContentsSection(drive::DriveCache* cache); | 202 void UpdateCacheContentsSection(drive::DriveCache* cache); |
202 | 203 |
203 // Called when GetGCacheContents() is complete. | 204 // Called when GetGCacheContents() is complete. |
204 void OnGetGCacheContents(base::ListValue* gcache_contents, | 205 void OnGetGCacheContents(base::ListValue* gcache_contents, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 google_apis::DriveServiceInterface* drive_service = | 321 google_apis::DriveServiceInterface* drive_service = |
321 system_service->drive_service(); | 322 system_service->drive_service(); |
322 DCHECK(drive_service); | 323 DCHECK(drive_service); |
323 drive::DriveCache* cache = system_service->cache(); | 324 drive::DriveCache* cache = system_service->cache(); |
324 DCHECK(cache); | 325 DCHECK(cache); |
325 | 326 |
326 UpdateDriveRelatedFlagsSection(); | 327 UpdateDriveRelatedFlagsSection(); |
327 UpdateDriveRelatedPreferencesSection(); | 328 UpdateDriveRelatedPreferencesSection(); |
328 UpdateAuthStatusSection(drive_service); | 329 UpdateAuthStatusSection(drive_service); |
329 UpdateAccountMetadataSection(drive_service); | 330 UpdateAccountMetadataSection(drive_service); |
| 331 UpdateDeltaUpdateStatusSection(); |
330 UpdateInFlightOperationsSection(drive_service); | 332 UpdateInFlightOperationsSection(drive_service); |
331 UpdateGCacheContentsSection(); | 333 UpdateGCacheContentsSection(); |
332 UpdateFileSystemContentsSection(drive_service); | 334 UpdateFileSystemContentsSection(drive_service); |
333 UpdateCacheContentsSection(cache); | 335 UpdateCacheContentsSection(cache); |
334 UpdateLocalStorageUsageSection(); | 336 UpdateLocalStorageUsageSection(); |
335 } | 337 } |
336 | 338 |
337 void DriveInternalsWebUIHandler::UpdateDriveRelatedFlagsSection() { | 339 void DriveInternalsWebUIHandler::UpdateDriveRelatedFlagsSection() { |
338 const char* kDriveRelatedFlags[] = { | 340 const char* kDriveRelatedFlags[] = { |
339 switches::kDisableDrive, | 341 switches::kDisableDrive, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 398 |
397 void DriveInternalsWebUIHandler::UpdateAccountMetadataSection( | 399 void DriveInternalsWebUIHandler::UpdateAccountMetadataSection( |
398 google_apis::DriveServiceInterface* drive_service) { | 400 google_apis::DriveServiceInterface* drive_service) { |
399 DCHECK(drive_service); | 401 DCHECK(drive_service); |
400 | 402 |
401 drive_service->GetAccountMetadata( | 403 drive_service->GetAccountMetadata( |
402 base::Bind(&DriveInternalsWebUIHandler::OnGetAccountMetadata, | 404 base::Bind(&DriveInternalsWebUIHandler::OnGetAccountMetadata, |
403 weak_ptr_factory_.GetWeakPtr())); | 405 weak_ptr_factory_.GetWeakPtr())); |
404 } | 406 } |
405 | 407 |
| 408 void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection() { |
| 409 const drive::DriveFileSystemMetadata metadata = |
| 410 GetSystemService()->file_system()->GetMetadata(); |
| 411 |
| 412 base::DictionaryValue delta_update_status; |
| 413 delta_update_status.SetBoolean("push-notification-enabled", |
| 414 metadata.push_notification_enabled); |
| 415 delta_update_status.SetInteger("polling-interval-sec", |
| 416 metadata.polling_interval_sec); |
| 417 delta_update_status.SetString( |
| 418 "last-update-check-time", |
| 419 google_apis::util::FormatTimeAsStringLocaltime( |
| 420 metadata.last_update_check_time)); |
| 421 delta_update_status.SetString( |
| 422 "last-update-check-error", |
| 423 drive::DriveFileErrorToString(metadata.last_update_check_error)); |
| 424 |
| 425 web_ui()->CallJavascriptFunction("updateDeltaUpdateStatus", |
| 426 delta_update_status); |
| 427 |
| 428 } |
| 429 |
406 void DriveInternalsWebUIHandler::UpdateInFlightOperationsSection( | 430 void DriveInternalsWebUIHandler::UpdateInFlightOperationsSection( |
407 google_apis::DriveServiceInterface* drive_service) { | 431 google_apis::DriveServiceInterface* drive_service) { |
408 google_apis::OperationProgressStatusList | 432 google_apis::OperationProgressStatusList |
409 progress_status_list = drive_service->GetProgressStatusList(); | 433 progress_status_list = drive_service->GetProgressStatusList(); |
410 | 434 |
411 base::ListValue in_flight_operations; | 435 base::ListValue in_flight_operations; |
412 for (size_t i = 0; i < progress_status_list.size(); ++i) { | 436 for (size_t i = 0; i < progress_status_list.size(); ++i) { |
413 const google_apis::OperationProgressStatus& status = | 437 const google_apis::OperationProgressStatus& status = |
414 progress_status_list[i]; | 438 progress_status_list[i]; |
415 | 439 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); | 633 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); |
610 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); | 634 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); |
611 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); | 635 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); |
612 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); | 636 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); |
613 | 637 |
614 Profile* profile = Profile::FromWebUI(web_ui); | 638 Profile* profile = Profile::FromWebUI(web_ui); |
615 ChromeURLDataManager::AddDataSource(profile, source); | 639 ChromeURLDataManager::AddDataSource(profile, source); |
616 } | 640 } |
617 | 641 |
618 } // namespace chromeos | 642 } // namespace chromeos |
OLD | NEW |