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

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

Issue 11418123: Some refactoring in file browser notifications: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 } 647 }
648 648
649 void FileBrowserEventRouter::OnDiskRemoved( 649 void FileBrowserEventRouter::OnDiskRemoved(
650 const DiskMountManager::Disk* disk) { 650 const DiskMountManager::Disk* disk) {
651 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 651 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
652 652
653 VLOG(1) << "Disk removed: " << disk->device_path(); 653 VLOG(1) << "Disk removed: " << disk->device_path();
654 654
655 if (!disk->mount_path().empty()) { 655 if (!disk->mount_path().empty()) {
656 notifications_->ShowNotification( 656 notifications_->ShowNotification(
657 FileBrowserNotifications::DEVICE_HARD_UNPLUG, disk->device_path()); 657 FileBrowserNotifications::DEVICE_HARD_UNPLUG,
658 disk->system_path_prefix());
658 DiskMountManager::GetInstance()->UnmountPath( 659 DiskMountManager::GetInstance()->UnmountPath(
659 disk->mount_path(), chromeos::UNMOUNT_OPTIONS_LAZY); 660 disk->mount_path(), chromeos::UNMOUNT_OPTIONS_LAZY);
660 } 661 }
661 DispatchDiskEvent(disk, false); 662 DispatchDiskEvent(disk, false);
662 } 663 }
663 664
664 void FileBrowserEventRouter::OnDeviceAdded( 665 void FileBrowserEventRouter::OnDeviceAdded(
665 const std::string& device_path) { 666 const std::string& device_path) {
666 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
667 668
668 VLOG(1) << "Device added : " << device_path; 669 VLOG(1) << "Device added : " << device_path;
669 670
670 // If the policy is set instead of showing the new device notification we show 671 // If the policy is set instead of showing the new device notification we show
671 // a notification that the operation is not permitted. 672 // a notification that the operation is not permitted.
672 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { 673 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
673 notifications_->ShowNotificationWithMessage( 674 notifications_->ShowNotification(
674 FileBrowserNotifications::DEVICE_FAIL, 675 FileBrowserNotifications::DEVICE_EXTERNAL_STORAGE_DISABLED,
675 device_path, 676 device_path);
676 l10n_util::GetStringUTF16(IDS_EXTERNAL_STORAGE_DISABLED_MESSAGE));
677 return; 677 return;
678 } 678 }
679 679
680 notifications_->RegisterDevice(device_path); 680 notifications_->RegisterDevice(device_path);
681 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, 681 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE,
682 device_path, 682 device_path,
683 base::TimeDelta::FromSeconds(5)); 683 base::TimeDelta::FromSeconds(5));
684 } 684 }
685 685
686 void FileBrowserEventRouter::OnDeviceRemoved( 686 void FileBrowserEventRouter::OnDeviceRemoved(
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 return scoped_refptr<RefcountedProfileKeyedService>( 875 return scoped_refptr<RefcountedProfileKeyedService>(
876 new FileBrowserEventRouter(profile)); 876 new FileBrowserEventRouter(profile));
877 } 877 }
878 878
879 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const { 879 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const {
880 // Explicitly and always allow this router in guest login mode. see 880 // Explicitly and always allow this router in guest login mode. see
881 // chrome/browser/profiles/profile_keyed_base_factory.h comment 881 // chrome/browser/profiles/profile_keyed_base_factory.h comment
882 // for the details. 882 // for the details.
883 return true; 883 return true;
884 } 884 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698