| 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_browser_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_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/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 // mounted. The opposite is fine - we can let the user re-plug her device to | 552 // mounted. The opposite is fine - we can let the user re-plug her device to |
| 553 // make it available. | 553 // make it available. |
| 554 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { | 554 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { |
| 555 DiskMountManager* manager = DiskMountManager::GetInstance(); | 555 DiskMountManager* manager = DiskMountManager::GetInstance(); |
| 556 DiskMountManager::MountPointMap mounts(manager->mount_points()); | 556 DiskMountManager::MountPointMap mounts(manager->mount_points()); |
| 557 for (DiskMountManager::MountPointMap::const_iterator it = mounts.begin(); | 557 for (DiskMountManager::MountPointMap::const_iterator it = mounts.begin(); |
| 558 it != mounts.end(); ++it) { | 558 it != mounts.end(); ++it) { |
| 559 LOG(INFO) << "Unmounting " << it->second.mount_path | 559 LOG(INFO) << "Unmounting " << it->second.mount_path |
| 560 << " because of policy."; | 560 << " because of policy."; |
| 561 manager->UnmountPath(it->second.mount_path, | 561 manager->UnmountPath(it->second.mount_path, |
| 562 chromeos::UNMOUNT_OPTIONS_NONE); | 562 chromeos::UNMOUNT_OPTIONS_NONE, |
| 563 DiskMountManager::UnmountPathCallback()); |
| 563 } | 564 } |
| 564 } | 565 } |
| 565 } | 566 } |
| 566 | 567 |
| 567 void FileBrowserEventRouter::OnFileBrowserPrefsChanged() { | 568 void FileBrowserEventRouter::OnFileBrowserPrefsChanged() { |
| 568 if (!profile_ || | 569 if (!profile_ || |
| 569 !extensions::ExtensionSystem::Get(profile_)->event_router()) { | 570 !extensions::ExtensionSystem::Get(profile_)->event_router()) { |
| 570 NOTREACHED(); | 571 NOTREACHED(); |
| 571 return; | 572 return; |
| 572 } | 573 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 | 791 |
| 791 VLOG(1) << "Disk removed: " << disk->device_path(); | 792 VLOG(1) << "Disk removed: " << disk->device_path(); |
| 792 | 793 |
| 793 if (!disk->mount_path().empty()) { | 794 if (!disk->mount_path().empty()) { |
| 794 if (!suspend_state_delegate_->SystemIsResuming()) { | 795 if (!suspend_state_delegate_->SystemIsResuming()) { |
| 795 notifications_->ShowNotification( | 796 notifications_->ShowNotification( |
| 796 FileBrowserNotifications::DEVICE_HARD_UNPLUG, | 797 FileBrowserNotifications::DEVICE_HARD_UNPLUG, |
| 797 disk->system_path_prefix()); | 798 disk->system_path_prefix()); |
| 798 } | 799 } |
| 799 DiskMountManager::GetInstance()->UnmountPath( | 800 DiskMountManager::GetInstance()->UnmountPath( |
| 800 disk->mount_path(), chromeos::UNMOUNT_OPTIONS_LAZY); | 801 disk->mount_path(), |
| 802 chromeos::UNMOUNT_OPTIONS_LAZY, |
| 803 DiskMountManager::UnmountPathCallback()); |
| 801 } | 804 } |
| 802 } | 805 } |
| 803 | 806 |
| 804 void FileBrowserEventRouter::OnDeviceAdded( | 807 void FileBrowserEventRouter::OnDeviceAdded( |
| 805 const std::string& device_path) { | 808 const std::string& device_path) { |
| 806 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 809 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 807 | 810 |
| 808 VLOG(1) << "Device added : " << device_path; | 811 VLOG(1) << "Device added : " << device_path; |
| 809 | 812 |
| 810 // If the policy is set instead of showing the new device notification we show | 813 // If the policy is set instead of showing the new device notification we show |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 } | 954 } |
| 952 | 955 |
| 953 bool FileBrowserEventRouter::FileWatcherExtensions::Watch( | 956 bool FileBrowserEventRouter::FileWatcherExtensions::Watch( |
| 954 const base::FilePath& path, | 957 const base::FilePath& path, |
| 955 const base::FilePathWatcher::Callback& callback) { | 958 const base::FilePathWatcher::Callback& callback) { |
| 956 if (is_remote_file_system_) | 959 if (is_remote_file_system_) |
| 957 return true; | 960 return true; |
| 958 | 961 |
| 959 return file_watcher_->Watch(path, false, callback); | 962 return file_watcher_->Watch(path, false, callback); |
| 960 } | 963 } |
| OLD | NEW |