| 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" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
| 17 #include "chrome/browser/chromeos/drive/drive.pb.h" | 17 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 18 #include "chrome/browser/chromeos/drive/drive_cache.h" | 18 #include "chrome/browser/chromeos/drive/drive_cache.h" |
| 19 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" | 19 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" |
| 20 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 20 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
| 21 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | 21 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
| 22 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 22 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
| 23 #include "chrome/browser/chromeos/drive/event_logger.h" | 23 #include "chrome/browser/chromeos/drive/event_logger.h" |
| 24 #include "chrome/browser/google_apis/auth_service.h" | 24 #include "chrome/browser/google_apis/auth_service.h" |
| 25 #include "chrome/browser/google_apis/drive_api_parser.h" | 25 #include "chrome/browser/google_apis/drive_api_parser.h" |
| 26 #include "chrome/browser/google_apis/drive_api_util.h" | 26 #include "chrome/browser/google_apis/drive_api_util.h" |
| 27 #include "chrome/browser/google_apis/drive_notification_manager.h" | |
| 28 #include "chrome/browser/google_apis/drive_notification_manager_factory.h" | |
| 29 #include "chrome/browser/google_apis/drive_service_interface.h" | 27 #include "chrome/browser/google_apis/drive_service_interface.h" |
| 30 #include "chrome/browser/google_apis/drive_switches.h" | 28 #include "chrome/browser/google_apis/drive_switches.h" |
| 31 #include "chrome/browser/google_apis/gdata_errorcode.h" | 29 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 32 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 30 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
| 33 #include "chrome/browser/google_apis/time_util.h" | 31 #include "chrome/browser/google_apis/time_util.h" |
| 34 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 35 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 37 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 38 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 | 507 |
| 510 GetSystemService()->file_system()->GetMetadata( | 508 GetSystemService()->file_system()->GetMetadata( |
| 511 base::Bind( | 509 base::Bind( |
| 512 &DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate, | 510 &DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate, |
| 513 weak_ptr_factory_.GetWeakPtr())); | 511 weak_ptr_factory_.GetWeakPtr())); |
| 514 } | 512 } |
| 515 | 513 |
| 516 void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate( | 514 void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate( |
| 517 const drive::DriveFileSystemMetadata& metadata) { | 515 const drive::DriveFileSystemMetadata& metadata) { |
| 518 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 516 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 519 Profile* profile = Profile::FromWebUI(web_ui()); | 517 drive::DriveSystemService* const system_service = GetSystemService(); |
| 520 google_apis::DriveNotificationManager* drive_notification_manager = | 518 if (!system_service) |
| 521 google_apis::DriveNotificationManagerFactory::GetForProfile(profile); | |
| 522 if (!drive_notification_manager) | |
| 523 return; | 519 return; |
| 524 | 520 |
| 525 base::DictionaryValue delta_update_status; | 521 base::DictionaryValue delta_update_status; |
| 526 delta_update_status.SetBoolean( | 522 delta_update_status.SetBoolean("push-notification-enabled", |
| 527 "push-notification-enabled", | 523 system_service->PushNotificationEnabled()); |
| 528 drive_notification_manager->IsPushNotificationEnabled()); | |
| 529 delta_update_status.SetString( | 524 delta_update_status.SetString( |
| 530 "last-update-check-time", | 525 "last-update-check-time", |
| 531 google_apis::util::FormatTimeAsStringLocaltime( | 526 google_apis::util::FormatTimeAsStringLocaltime( |
| 532 metadata.last_update_check_time)); | 527 metadata.last_update_check_time)); |
| 533 delta_update_status.SetString( | 528 delta_update_status.SetString( |
| 534 "last-update-check-error", | 529 "last-update-check-error", |
| 535 drive::DriveFileErrorToString(metadata.last_update_check_error)); | 530 drive::DriveFileErrorToString(metadata.last_update_check_error)); |
| 536 | 531 |
| 537 web_ui()->CallJavascriptFunction("updateDeltaUpdateStatus", | 532 web_ui()->CallJavascriptFunction("updateDeltaUpdateStatus", |
| 538 delta_update_status); | 533 delta_update_status); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); | 756 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); |
| 762 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); | 757 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); |
| 763 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); | 758 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); |
| 764 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); | 759 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); |
| 765 | 760 |
| 766 Profile* profile = Profile::FromWebUI(web_ui); | 761 Profile* profile = Profile::FromWebUI(web_ui); |
| 767 content::WebUIDataSource::Add(profile, source); | 762 content::WebUIDataSource::Add(profile, source); |
| 768 } | 763 } |
| 769 | 764 |
| 770 } // namespace chromeos | 765 } // namespace chromeos |
| OLD | NEW |