Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_event_router.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 !extensions::ExtensionSystem::Get(profile_)->event_router()) { 378 !extensions::ExtensionSystem::Get(profile_)->event_router()) {
379 NOTREACHED(); 379 NOTREACHED();
380 return; 380 return;
381 } 381 }
382 extensions::ExtensionSystem::Get(profile_)->event_router()-> 382 extensions::ExtensionSystem::Get(profile_)->event_router()->
383 DispatchEventToRenderers( 383 DispatchEventToRenderers(
384 extensions::event_names::kOnFileBrowserNetworkConnectionChanged, 384 extensions::event_names::kOnFileBrowserNetworkConnectionChanged,
385 scoped_ptr<ListValue>(new ListValue()), NULL, GURL()); 385 scoped_ptr<ListValue>(new ListValue()), NULL, GURL());
386 } 386 }
387 387
388 void FileBrowserEventRouter::Observe( 388 void FileBrowserEventRouter::OnPreferenceChanged(PrefServiceBase* service,
389 int type, 389 const std::string& pref_name) {
390 const content::NotificationSource& source,
391 const content::NotificationDetails& details) {
392 if (!profile_ || 390 if (!profile_ ||
393 !extensions::ExtensionSystem::Get(profile_)->event_router()) { 391 !extensions::ExtensionSystem::Get(profile_)->event_router()) {
394 NOTREACHED(); 392 NOTREACHED();
395 return; 393 return;
396 } 394 }
397 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 395
398 std::string* pref_name = content::Details<std::string>(details).ptr(); 396 // If the policy just got disabled we have to unmount every device currently
399 // If the policy just got disabled we have to unmount every device currently 397 // mounted. The opposite is fine - we can let the user re-plug her device to
400 // mounted. The opposite is fine - we can let the user re-plug her device to 398 // make it available.
401 // make it available. 399 if (pref_name == prefs::kExternalStorageDisabled &&
402 if (*pref_name == prefs::kExternalStorageDisabled && 400 profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
403 profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { 401 DiskMountManager* manager = DiskMountManager::GetInstance();
404 DiskMountManager* manager = DiskMountManager::GetInstance(); 402 DiskMountManager::MountPointMap mounts(manager->mount_points());
405 DiskMountManager::MountPointMap mounts(manager->mount_points()); 403 for (DiskMountManager::MountPointMap::const_iterator it = mounts.begin();
406 for (DiskMountManager::MountPointMap::const_iterator it = mounts.begin(); 404 it != mounts.end(); ++it) {
407 it != mounts.end(); ++it) { 405 LOG(INFO) << "Unmounting " << it->second.mount_path
408 LOG(INFO) << "Unmounting " << it->second.mount_path 406 << " because of policy.";
409 << " because of policy."; 407 manager->UnmountPath(it->second.mount_path,
410 manager->UnmountPath(it->second.mount_path, 408 chromeos::UNMOUNT_OPTIONS_NONE);
411 chromeos::UNMOUNT_OPTIONS_NONE);
412 }
413 return;
414 } else if (*pref_name == prefs::kDisableDriveOverCellular ||
415 *pref_name == prefs::kDisableDriveHostedFiles ||
416 *pref_name == prefs::kDisableDrive ||
417 *pref_name == prefs::kUse24HourClock) {
418 extensions::ExtensionSystem::Get(profile_)->event_router()->
419 DispatchEventToRenderers(
420 extensions::event_names::kOnFileBrowserPreferencesChanged,
421 scoped_ptr<ListValue>(new ListValue()), NULL, GURL());
422 } 409 }
410 return;
411 } else if (pref_name == prefs::kDisableDriveOverCellular ||
412 pref_name == prefs::kDisableDriveHostedFiles ||
413 pref_name == prefs::kDisableDrive ||
414 pref_name == prefs::kUse24HourClock) {
415 extensions::ExtensionSystem::Get(profile_)->event_router()->
416 DispatchEventToRenderers(
417 extensions::event_names::kOnFileBrowserPreferencesChanged,
418 scoped_ptr<ListValue>(new ListValue()), NULL, GURL());
423 } 419 }
424 } 420 }
425 421
426 void FileBrowserEventRouter::OnProgressUpdate( 422 void FileBrowserEventRouter::OnProgressUpdate(
427 const google_apis::OperationProgressStatusList& list) { 423 const google_apis::OperationProgressStatusList& list) {
428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 424 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
429 425
430 scoped_ptr<ListValue> event_list( 426 scoped_ptr<ListValue> event_list(
431 file_manager_util::ProgressStatusVectorToListValue( 427 file_manager_util::ProgressStatusVectorToListValue(
432 profile_, 428 profile_,
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 return scoped_refptr<RefcountedProfileKeyedService>( 885 return scoped_refptr<RefcountedProfileKeyedService>(
890 new FileBrowserEventRouter(profile)); 886 new FileBrowserEventRouter(profile));
891 } 887 }
892 888
893 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const { 889 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const {
894 // Explicitly and always allow this router in guest login mode. see 890 // Explicitly and always allow this router in guest login mode. see
895 // chrome/browser/profiles/profile_keyed_base_factory.h comment 891 // chrome/browser/profiles/profile_keyed_base_factory.h comment
896 // for the details. 892 // for the details.
897 return true; 893 return true;
898 } 894 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698