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