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