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/chromeos/extensions/file_manager/event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/event_router.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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
17 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 17 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
18 #include "chrome/browser/chromeos/drive/file_system_util.h" | 18 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 19 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
19 #include "chrome/browser/chromeos/file_manager/app_id.h" | 20 #include "chrome/browser/chromeos/file_manager/app_id.h" |
20 #include "chrome/browser/chromeos/file_manager/desktop_notifications.h" | 21 #include "chrome/browser/chromeos/file_manager/desktop_notifications.h" |
21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 22 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
22 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h" | 23 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h" |
23 #include "chrome/browser/chromeos/file_manager/open_util.h" | 24 #include "chrome/browser/chromeos/file_manager/open_util.h" |
24 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 25 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
25 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 26 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
26 #include "chrome/browser/chromeos/login/screen_locker.h" | 27 #include "chrome/browser/chromeos/login/screen_locker.h" |
27 #include "chrome/browser/drive/drive_service_interface.h" | 28 #include "chrome/browser/drive/drive_service_interface.h" |
28 #include "chrome/browser/extensions/event_names.h" | 29 #include "chrome/browser/extensions/event_names.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 203 |
203 for (size_t i = 0; i < arraysize(kGooglePlusPhotosIds); ++i) { | 204 for (size_t i = 0; i < arraysize(kGooglePlusPhotosIds); ++i) { |
204 if (service->GetExtensionById(kGooglePlusPhotosIds[i], | 205 if (service->GetExtensionById(kGooglePlusPhotosIds[i], |
205 false /* include_disable */) != NULL) | 206 false /* include_disable */) != NULL) |
206 return true; | 207 return true; |
207 } | 208 } |
208 | 209 |
209 return false; | 210 return false; |
210 } | 211 } |
211 | 212 |
| 213 // This method is temporarily introduced to make a change step by step. |
| 214 // After mounting logic is moved to VolumeManager, this should be removed. |
| 215 std::string MountTypeToString(chromeos::MountType type) { |
| 216 switch (type) { |
| 217 case chromeos::MOUNT_TYPE_INVALID: |
| 218 return ""; |
| 219 case chromeos::MOUNT_TYPE_DEVICE: |
| 220 return util::VolumeTypeToStringEnum(VOLUME_TYPE_REMOVABLE_DISK_PARTITION); |
| 221 case chromeos::MOUNT_TYPE_ARCHIVE: |
| 222 return util::VolumeTypeToStringEnum(VOLUME_TYPE_MOUNTED_ARCHIVE_FILE); |
| 223 case chromeos::MOUNT_TYPE_GOOGLE_DRIVE: |
| 224 return util::VolumeTypeToStringEnum(VOLUME_TYPE_GOOGLE_DRIVE); |
| 225 } |
| 226 NOTREACHED(); |
| 227 return ""; |
| 228 } |
| 229 |
212 } // namespace | 230 } // namespace |
213 | 231 |
214 // Pass dummy value to JobInfo's constructor for make it default constructible. | 232 // Pass dummy value to JobInfo's constructor for make it default constructible. |
215 EventRouter::DriveJobInfoWithStatus::DriveJobInfoWithStatus() | 233 EventRouter::DriveJobInfoWithStatus::DriveJobInfoWithStatus() |
216 : job_info(drive::TYPE_DOWNLOAD_FILE) { | 234 : job_info(drive::TYPE_DOWNLOAD_FILE) { |
217 } | 235 } |
218 | 236 |
219 EventRouter::DriveJobInfoWithStatus::DriveJobInfoWithStatus( | 237 EventRouter::DriveJobInfoWithStatus::DriveJobInfoWithStatus( |
220 const drive::JobInfo& info, const std::string& status) | 238 const drive::JobInfo& info, const std::string& status) |
221 : job_info(info), status(status) { | 239 : job_info(info), status(status) { |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 chromeos::MountError error_code, | 701 chromeos::MountError error_code, |
684 const DiskMountManager::MountPointInfo& mount_info) { | 702 const DiskMountManager::MountPointInfo& mount_info) { |
685 scoped_ptr<ListValue> args(new ListValue()); | 703 scoped_ptr<ListValue> args(new ListValue()); |
686 DictionaryValue* mount_info_value = new DictionaryValue(); | 704 DictionaryValue* mount_info_value = new DictionaryValue(); |
687 args->Append(mount_info_value); | 705 args->Append(mount_info_value); |
688 mount_info_value->SetString( | 706 mount_info_value->SetString( |
689 "eventType", | 707 "eventType", |
690 event == DiskMountManager::MOUNTING ? "mount" : "unmount"); | 708 event == DiskMountManager::MOUNTING ? "mount" : "unmount"); |
691 mount_info_value->SetString("status", MountErrorToString(error_code)); | 709 mount_info_value->SetString("status", MountErrorToString(error_code)); |
692 mount_info_value->SetString( | 710 mount_info_value->SetString( |
693 "mountType", | 711 "volumeType", MountTypeToString(mount_info.mount_type)); |
694 DiskMountManager::MountTypeToString(mount_info.mount_type)); | |
695 | 712 |
696 // Add sourcePath to the event. | 713 // Add sourcePath to the event. |
697 mount_info_value->SetString("sourcePath", mount_info.source_path); | 714 mount_info_value->SetString("sourcePath", mount_info.source_path); |
698 | 715 |
699 base::FilePath relative_mount_path; | 716 base::FilePath relative_mount_path; |
700 | 717 |
701 // If there were no error or some special conditions occurred, add mountPath | 718 // If there were no error or some special conditions occurred, add mountPath |
702 // to the event. | 719 // to the event. |
703 if (event == DiskMountManager::UNMOUNTING || | 720 if (event == DiskMountManager::UNMOUNTING || |
704 error_code == chromeos::MOUNT_ERROR_NONE || | 721 error_code == chromeos::MOUNT_ERROR_NONE || |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 base::TimeDelta::FromSeconds(4)); | 840 base::TimeDelta::FromSeconds(4)); |
824 } else { | 841 } else { |
825 notifications_->HideNotification(DesktopNotifications::FORMAT_START, | 842 notifications_->HideNotification(DesktopNotifications::FORMAT_START, |
826 device_path); | 843 device_path); |
827 notifications_->ShowNotification(DesktopNotifications::FORMAT_FAIL, | 844 notifications_->ShowNotification(DesktopNotifications::FORMAT_FAIL, |
828 device_path); | 845 device_path); |
829 } | 846 } |
830 } | 847 } |
831 | 848 |
832 } // namespace file_manager | 849 } // namespace file_manager |
OLD | NEW |