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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/event_router.cc

Issue 251593005: Files.app auto pop up for MTP storage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months 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_manager/event_router.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_change_registrar.h" 10 #include "base/prefs/pref_change_registrar.h"
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 "fileFullPath", "/" + entry_definition.full_path.value()); 752 "fileFullPath", "/" + entry_definition.full_path.value());
753 event.entry.additional_properties.SetBoolean("fileIsDirectory", 753 event.entry.additional_properties.SetBoolean("fileIsDirectory",
754 entry_definition.is_directory); 754 entry_definition.is_directory);
755 755
756 BroadcastEvent(profile_, 756 BroadcastEvent(profile_,
757 file_browser_private::OnDirectoryChanged::kEventName, 757 file_browser_private::OnDirectoryChanged::kEventName,
758 file_browser_private::OnDirectoryChanged::Create(event)); 758 file_browser_private::OnDirectoryChanged::Create(event));
759 } 759 }
760 760
761 void EventRouter::ShowRemovableDeviceInFileManager( 761 void EventRouter::ShowRemovableDeviceInFileManager(
762 VolumeType type,
762 const base::FilePath& mount_path) { 763 const base::FilePath& mount_path) {
763 // Do not attempt to open File Manager while the login is in progress or 764 // Do not attempt to open File Manager while the login is in progress or
764 // the screen is locked or running in kiosk app mode and make sure the file 765 // the screen is locked or running in kiosk app mode and make sure the file
765 // manager is opened only for the active user. 766 // manager is opened only for the active user.
766 if (chromeos::LoginDisplayHostImpl::default_host() || 767 if (chromeos::LoginDisplayHostImpl::default_host() ||
767 chromeos::ScreenLocker::default_screen_locker() || 768 chromeos::ScreenLocker::default_screen_locker() ||
768 chrome::IsRunningInForcedAppMode() || 769 chrome::IsRunningInForcedAppMode() ||
769 profile_ != ProfileManager::GetActiveUserProfile()) 770 profile_ != ProfileManager::GetActiveUserProfile())
770 return; 771 return;
771 772
772 // Do not pop-up the File Manager, if the recovery tool is running. 773 // Do not pop-up the File Manager, if the recovery tool is running.
773 if (IsRecoveryToolRunning(profile_)) 774 if (IsRecoveryToolRunning(profile_))
774 return; 775 return;
775 776
776 // According to DCF (Design rule of Camera File system) by JEITA / CP-3461 777 // Do not pop-up the File Manager, if Google+ Photos may be launched.
777 // cameras should have pictures located in the DCIM root directory. 778 if (IsGooglePhotosInstalled(profile_)) {
778 const base::FilePath dcim_path = mount_path.Append( 779 // MTP device is handled by Photos app.
779 FILE_PATH_LITERAL("DCIM")); 780 if (type == VOLUME_TYPE_MTP)
781 return;
782 // According to DCF (Design rule of Camera File system) by JEITA / CP-3461
783 // cameras should have pictures located in the DCIM root directory.
784 // Such removable disks are handled by Photos app.
785 if (type == VOLUME_TYPE_REMOVABLE_DISK_PARTITION) {
786 DirectoryExistsOnUIThread(
787 mount_path.AppendASCII("DCIM"),
788 base::Bind(&base::DoNothing),
789 base::Bind(&util::OpenRemovableDrive, profile_, mount_path));
790 return;
791 }
792 }
780 793
781 // If there is a DCIM folder and Google+ Photos is installed, then do not 794 util::OpenRemovableDrive(profile_, mount_path);
782 // launch Files.app.
783 DirectoryExistsOnUIThread(
784 dcim_path,
785 IsGooglePhotosInstalled(profile_)
786 ? base::Bind(&base::DoNothing)
787 : base::Bind(&util::OpenRemovableDrive, profile_, mount_path),
788 base::Bind(&util::OpenRemovableDrive, profile_, mount_path));
789 } 795 }
790 796
791 void EventRouter::DispatchDeviceEvent( 797 void EventRouter::DispatchDeviceEvent(
792 file_browser_private::DeviceEventType type, 798 file_browser_private::DeviceEventType type,
793 const std::string& device_path) { 799 const std::string& device_path) {
794 file_browser_private::DeviceEvent event; 800 file_browser_private::DeviceEvent event;
795 event.type = type; 801 event.type = type;
796 event.device_path = device_path; 802 event.device_path = device_path;
797 BroadcastEvent(profile_, 803 BroadcastEvent(profile_,
798 file_browser_private::OnDeviceChanged::kEventName, 804 file_browser_private::OnDeviceChanged::kEventName,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 if (!profile_) 865 if (!profile_)
860 return; 866 return;
861 867
862 BroadcastMountCompletedEvent( 868 BroadcastMountCompletedEvent(
863 profile_, 869 profile_,
864 file_browser_private::MOUNT_COMPLETED_EVENT_TYPE_MOUNT, 870 file_browser_private::MOUNT_COMPLETED_EVENT_TYPE_MOUNT,
865 error_code, 871 error_code,
866 volume_info, 872 volume_info,
867 is_remounting); 873 is_remounting);
868 874
869 if (volume_info.type == VOLUME_TYPE_REMOVABLE_DISK_PARTITION && 875 if ((volume_info.type == VOLUME_TYPE_MTP ||
876 volume_info.type == VOLUME_TYPE_REMOVABLE_DISK_PARTITION) &&
870 !is_remounting) { 877 !is_remounting) {
871 // If a new device was mounted, a new File manager window may need to be 878 // If a new device was mounted, a new File manager window may need to be
872 // opened. 879 // opened.
873 if (error_code == chromeos::MOUNT_ERROR_NONE) 880 if (error_code == chromeos::MOUNT_ERROR_NONE)
874 ShowRemovableDeviceInFileManager(volume_info.mount_path); 881 ShowRemovableDeviceInFileManager(volume_info.type,
882 volume_info.mount_path);
875 } 883 }
876 } 884 }
877 885
878 void EventRouter::OnVolumeUnmounted(chromeos::MountError error_code, 886 void EventRouter::OnVolumeUnmounted(chromeos::MountError error_code,
879 const VolumeInfo& volume_info) { 887 const VolumeInfo& volume_info) {
880 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 888 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
881 BroadcastMountCompletedEvent( 889 BroadcastMountCompletedEvent(
882 profile_, 890 profile_,
883 file_browser_private::MOUNT_COMPLETED_EVENT_TYPE_UNMOUNT, 891 file_browser_private::MOUNT_COMPLETED_EVENT_TYPE_UNMOUNT,
884 error_code, 892 error_code,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 } 941 }
934 } 942 }
935 943
936 void EventRouter::OnOwnerEntryChanged(aura::Window* window) { 944 void EventRouter::OnOwnerEntryChanged(aura::Window* window) {
937 BroadcastEvent(profile_, 945 BroadcastEvent(profile_,
938 file_browser_private::OnDesktopChanged::kEventName, 946 file_browser_private::OnDesktopChanged::kEventName,
939 file_browser_private::OnDesktopChanged::Create()); 947 file_browser_private::OnDesktopChanged::Create());
940 } 948 }
941 949
942 } // namespace file_manager 950 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698