| Index: chrome/browser/chromeos/extensions/file_browser_event_router.cc
|
| diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc
|
| index 5fabd108e6b9e39e00d53cbb47c72da14f6c2406..529d18851984385b24dfce4ddaf10b4a19a58ba0 100644
|
| --- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc
|
| +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc
|
| @@ -29,6 +29,7 @@
|
| #include "chrome/common/pref_names.h"
|
| #include "content/public/browser/notification_source.h"
|
| #include "grit/generated_resources.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
| #include "webkit/fileapi/file_system_types.h"
|
| #include "webkit/fileapi/file_system_util.h"
|
|
|
| @@ -155,6 +156,7 @@ void FileBrowserEventRouter::ObserveFileSystemEvents() {
|
| pref_change_registrar_->Add(prefs::kDisableGDataOverCellular, this);
|
| pref_change_registrar_->Add(prefs::kDisableGDataHostedFiles, this);
|
| pref_change_registrar_->Add(prefs::kDisableGData, this);
|
| + pref_change_registrar_->Add(prefs::kExternalStorageDisabled, this);
|
| }
|
|
|
| // File watch setup routines.
|
| @@ -344,9 +346,30 @@ void FileBrowserEventRouter::Observe(
|
| NOTREACHED();
|
| return;
|
| }
|
| - profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
|
| - extension_event_names::kOnFileBrowserGDataPreferencesChanged,
|
| - "[]", NULL, GURL());
|
| + if (type == chrome::NOTIFICATION_PREF_CHANGED) {
|
| + std::string* pref_name = content::Details<std::string>(details).ptr();
|
| + // If the policy just got disabled we have to unmount every device currently
|
| + // mounted. The opposite is fine - we can let the user re-plug her device to
|
| + // make it available.
|
| + if (*pref_name == prefs::kExternalStorageDisabled &&
|
| + profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
|
| + DiskMountManager *manager = DiskMountManager::GetInstance();
|
| + DiskMountManager::MountPointMap mounts(manager->mount_points());
|
| + for (DiskMountManager::MountPointMap::const_iterator it = mounts.begin();
|
| + it != mounts.end(); ++it) {
|
| + LOG(INFO) << "Unmounting " << it->second.mount_path
|
| + << " because of policy.";
|
| + manager->UnmountPath(it->second.mount_path);
|
| + }
|
| + return;
|
| + } else if (*pref_name == prefs::kDisableGDataOverCellular ||
|
| + *pref_name == prefs::kDisableGDataHostedFiles ||
|
| + *pref_name == prefs::kDisableGData) {
|
| + profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
|
| + extension_event_names::kOnFileBrowserGDataPreferencesChanged,
|
| + "[]", NULL, GURL());
|
| + }
|
| + }
|
| }
|
|
|
| void FileBrowserEventRouter::OnProgressUpdate(
|
| @@ -546,8 +569,10 @@ void FileBrowserEventRouter::OnDiskAdded(
|
| return;
|
| }
|
|
|
| - // If disk is not mounted yet and it has media, give it a try.
|
| - if (disk->mount_path().empty() && disk->has_media()) {
|
| + // If disk is not mounted yet and it has media and there is no policy
|
| + // forbidding external storage, give it a try.
|
| + if (disk->mount_path().empty() && disk->has_media() &&
|
| + !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
|
| // Initiate disk mount operation. MountPath auto-detects the filesystem
|
| // format if the second argument is empty. The third argument (mount label)
|
| // is not used in a disk mount operation.
|
| @@ -581,6 +606,16 @@ void FileBrowserEventRouter::OnDeviceAdded(
|
|
|
| VLOG(1) << "Device added : " << device_path;
|
|
|
| + // If the policy is set instead of showing the new device notification we show
|
| + // a notification that the operation is not permitted.
|
| + if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
|
| + notifications_->ShowNotificationWithMessage(
|
| + FileBrowserNotifications::DEVICE_FAIL,
|
| + device_path,
|
| + l10n_util::GetStringUTF16(IDS_EXTERNAL_STORAGE_DISABLED_MESSAGE));
|
| + return;
|
| + }
|
| +
|
| notifications_->RegisterDevice(device_path);
|
| notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE,
|
| device_path,
|
|
|