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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
14 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 14 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
15 #include "chrome/browser/chromeos/gdata/drive_cache.h" | 15 #include "chrome/browser/chromeos/gdata/drive_cache.h" |
16 #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h" | 16 #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h" |
17 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" | 17 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" |
18 #include "chrome/browser/chromeos/gdata/drive_system_service.h" | 18 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
19 #include "chrome/browser/google_apis/auth_service.h" | 19 #include "chrome/browser/google_apis/auth_service.h" |
20 #include "chrome/browser/google_apis/gdata_util.h" | 20 #include "chrome/browser/google_apis/gdata_util.h" |
21 #include "chrome/browser/google_apis/operation_registry.h" | |
22 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 22 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
24 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
25 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/web_ui.h" | 25 #include "content/public/browser/web_ui.h" |
27 #include "content/public/browser/web_ui_message_handler.h" | 26 #include "content/public/browser/web_ui_message_handler.h" |
28 #include "grit/browser_resources.h" | 27 #include "grit/browser_resources.h" |
29 | 28 |
30 using content::BrowserThread; | 29 using content::BrowserThread; |
31 | 30 |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 return; | 397 return; |
399 | 398 |
400 gdata::DriveServiceInterface* drive_service = system_service->drive_service(); | 399 gdata::DriveServiceInterface* drive_service = system_service->drive_service(); |
401 DCHECK(drive_service); | 400 DCHECK(drive_service); |
402 | 401 |
403 UpdateInFlightOperations(drive_service); | 402 UpdateInFlightOperations(drive_service); |
404 } | 403 } |
405 | 404 |
406 void DriveInternalsWebUIHandler::UpdateInFlightOperations( | 405 void DriveInternalsWebUIHandler::UpdateInFlightOperations( |
407 const gdata::DriveServiceInterface* drive_service) { | 406 const gdata::DriveServiceInterface* drive_service) { |
408 std::vector<gdata::OperationRegistry::ProgressStatus> | 407 gdata::OperationProgressStatusList |
409 progress_status_list = drive_service->operation_registry()-> | 408 progress_status_list = drive_service->GetProgressStatusList(); |
410 GetProgressStatusList(); | |
411 | 409 |
412 base::ListValue in_flight_operations; | 410 base::ListValue in_flight_operations; |
413 for (size_t i = 0; i < progress_status_list.size(); ++i) { | 411 for (size_t i = 0; i < progress_status_list.size(); ++i) { |
414 const gdata::OperationRegistry::ProgressStatus status = | 412 const gdata::OperationProgressStatus& status = progress_status_list[i]; |
415 progress_status_list[i]; | |
416 | 413 |
417 base::DictionaryValue* dict = new DictionaryValue; | 414 base::DictionaryValue* dict = new DictionaryValue; |
418 dict->SetInteger("operation_id", status.operation_id); | 415 dict->SetInteger("operation_id", status.operation_id); |
419 dict->SetString( | 416 dict->SetString( |
420 "operation_type", | 417 "operation_type", |
421 gdata::OperationRegistry::OperationTypeToString(status.operation_type)); | 418 gdata::OperationTypeToString(status.operation_type)); |
422 dict->SetString("file_path", status.file_path.AsUTF8Unsafe()); | 419 dict->SetString("file_path", status.file_path.AsUTF8Unsafe()); |
423 dict->SetString( | 420 dict->SetString( |
424 "transfer_state", | 421 "transfer_state", |
425 gdata::OperationRegistry::OperationTransferStateToString( | 422 gdata::OperationTransferStateToString(status.transfer_state)); |
426 status.transfer_state)); | |
427 dict->SetString( | 423 dict->SetString( |
428 "start_time", | 424 "start_time", |
429 gdata::util::FormatTimeAsStringLocaltime(status.start_time)); | 425 gdata::util::FormatTimeAsStringLocaltime(status.start_time)); |
430 dict->SetDouble("progress_current", status.progress_current); | 426 dict->SetDouble("progress_current", status.progress_current); |
431 dict->SetDouble("progress_total", status.progress_total); | 427 dict->SetDouble("progress_total", status.progress_total); |
432 in_flight_operations.Append(dict); | 428 in_flight_operations.Append(dict); |
433 } | 429 } |
434 web_ui()->CallJavascriptFunction("updateInFlightOperations", | 430 web_ui()->CallJavascriptFunction("updateInFlightOperations", |
435 in_flight_operations); | 431 in_flight_operations); |
436 } | 432 } |
437 | 433 |
438 } // namespace | 434 } // namespace |
439 | 435 |
440 DriveInternalsUI::DriveInternalsUI(content::WebUI* web_ui) | 436 DriveInternalsUI::DriveInternalsUI(content::WebUI* web_ui) |
441 : WebUIController(web_ui) { | 437 : WebUIController(web_ui) { |
442 web_ui->AddMessageHandler(new DriveInternalsWebUIHandler()); | 438 web_ui->AddMessageHandler(new DriveInternalsWebUIHandler()); |
443 | 439 |
444 ChromeWebUIDataSource* source = | 440 ChromeWebUIDataSource* source = |
445 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); | 441 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); |
446 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); | 442 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); |
447 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); | 443 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); |
448 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); | 444 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); |
449 | 445 |
450 Profile* profile = Profile::FromWebUI(web_ui); | 446 Profile* profile = Profile::FromWebUI(web_ui); |
451 ChromeURLDataManager::AddDataSource(profile, source); | 447 ChromeURLDataManager::AddDataSource(profile, source); |
452 } | 448 } |
453 | 449 |
454 } // namespace chromeos | 450 } // namespace chromeos |
OLD | NEW |