| 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/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/prefs/public/pref_change_registrar.h" | 10 #include "base/prefs/public/pref_change_registrar.h" |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 chromeos::NetworkLibrary* network_library) { | 375 chromeos::NetworkLibrary* network_library) { |
| 376 if (!profile_ || !profile_->GetExtensionEventRouter()) { | 376 if (!profile_ || !profile_->GetExtensionEventRouter()) { |
| 377 NOTREACHED(); | 377 NOTREACHED(); |
| 378 return; | 378 return; |
| 379 } | 379 } |
| 380 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 380 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 381 extensions::event_names::kOnFileBrowserNetworkConnectionChanged, | 381 extensions::event_names::kOnFileBrowserNetworkConnectionChanged, |
| 382 scoped_ptr<ListValue>(new ListValue()), NULL, GURL()); | 382 scoped_ptr<ListValue>(new ListValue()), NULL, GURL()); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void FileBrowserEventRouter::Observe( | 385 void FileBrowserEventRouter::OnPreferenceChanged(PrefServiceBase* service, |
| 386 int type, | 386 const std::string& pref_name) { |
| 387 const content::NotificationSource& source, | |
| 388 const content::NotificationDetails& details) { | |
| 389 if (!profile_ || !profile_->GetExtensionEventRouter()) { | 387 if (!profile_ || !profile_->GetExtensionEventRouter()) { |
| 390 NOTREACHED(); | 388 NOTREACHED(); |
| 391 return; | 389 return; |
| 392 } | 390 } |
| 393 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 391 |
| 394 std::string* pref_name = content::Details<std::string>(details).ptr(); | 392 // If the policy just got disabled we have to unmount every device currently |
| 395 // If the policy just got disabled we have to unmount every device currently | 393 // mounted. The opposite is fine - we can let the user re-plug her device to |
| 396 // mounted. The opposite is fine - we can let the user re-plug her device to | 394 // make it available. |
| 397 // make it available. | 395 if (pref_name == prefs::kExternalStorageDisabled && |
| 398 if (*pref_name == prefs::kExternalStorageDisabled && | 396 profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { |
| 399 profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { | 397 DiskMountManager* manager = DiskMountManager::GetInstance(); |
| 400 DiskMountManager* manager = DiskMountManager::GetInstance(); | 398 DiskMountManager::MountPointMap mounts(manager->mount_points()); |
| 401 DiskMountManager::MountPointMap mounts(manager->mount_points()); | 399 for (DiskMountManager::MountPointMap::const_iterator it = mounts.begin(); |
| 402 for (DiskMountManager::MountPointMap::const_iterator it = mounts.begin(); | 400 it != mounts.end(); ++it) { |
| 403 it != mounts.end(); ++it) { | 401 LOG(INFO) << "Unmounting " << it->second.mount_path |
| 404 LOG(INFO) << "Unmounting " << it->second.mount_path | 402 << " because of policy."; |
| 405 << " because of policy."; | 403 manager->UnmountPath(it->second.mount_path, |
| 406 manager->UnmountPath(it->second.mount_path, | 404 chromeos::UNMOUNT_OPTIONS_NONE); |
| 407 chromeos::UNMOUNT_OPTIONS_NONE); | |
| 408 } | |
| 409 return; | |
| 410 } else if (*pref_name == prefs::kDisableDriveOverCellular || | |
| 411 *pref_name == prefs::kDisableDriveHostedFiles || | |
| 412 *pref_name == prefs::kDisableDrive || | |
| 413 *pref_name == prefs::kUse24HourClock) { | |
| 414 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | |
| 415 extensions::event_names::kOnFileBrowserPreferencesChanged, | |
| 416 scoped_ptr<ListValue>(new ListValue()), NULL, GURL()); | |
| 417 } | 405 } |
| 406 return; |
| 407 } else if (pref_name == prefs::kDisableDriveOverCellular || |
| 408 pref_name == prefs::kDisableDriveHostedFiles || |
| 409 pref_name == prefs::kDisableDrive || |
| 410 pref_name == prefs::kUse24HourClock) { |
| 411 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 412 extensions::event_names::kOnFileBrowserPreferencesChanged, |
| 413 scoped_ptr<ListValue>(new ListValue()), NULL, GURL()); |
| 418 } | 414 } |
| 419 } | 415 } |
| 420 | 416 |
| 421 void FileBrowserEventRouter::OnProgressUpdate( | 417 void FileBrowserEventRouter::OnProgressUpdate( |
| 422 const google_apis::OperationProgressStatusList& list) { | 418 const google_apis::OperationProgressStatusList& list) { |
| 423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 424 | 420 |
| 425 scoped_ptr<ListValue> event_list( | 421 scoped_ptr<ListValue> event_list( |
| 426 file_manager_util::ProgressStatusVectorToListValue( | 422 file_manager_util::ProgressStatusVectorToListValue( |
| 427 profile_, | 423 profile_, |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 return scoped_refptr<RefcountedProfileKeyedService>( | 876 return scoped_refptr<RefcountedProfileKeyedService>( |
| 881 new FileBrowserEventRouter(profile)); | 877 new FileBrowserEventRouter(profile)); |
| 882 } | 878 } |
| 883 | 879 |
| 884 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const { | 880 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const { |
| 885 // Explicitly and always allow this router in guest login mode. see | 881 // Explicitly and always allow this router in guest login mode. see |
| 886 // chrome/browser/profiles/profile_keyed_base_factory.h comment | 882 // chrome/browser/profiles/profile_keyed_base_factory.h comment |
| 887 // for the details. | 883 // for the details. |
| 888 return true; | 884 return true; |
| 889 } | 885 } |
| OLD | NEW |