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_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 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 22 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
23 #include "chrome/browser/chromeos/file_manager/open_util.h" | 23 #include "chrome/browser/chromeos/file_manager/open_util.h" |
24 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 24 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
25 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 25 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
26 #include "chrome/browser/chromeos/login/screen_locker.h" | 26 #include "chrome/browser/chromeos/login/screen_locker.h" |
27 #include "chrome/browser/drive/drive_service_interface.h" | 27 #include "chrome/browser/drive/drive_service_interface.h" |
28 #include "chrome/browser/extensions/event_names.h" | 28 #include "chrome/browser/extensions/event_names.h" |
29 #include "chrome/browser/extensions/extension_service.h" | 29 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/extensions/extension_system.h" | 30 #include "chrome/browser/extensions/extension_system.h" |
31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/profiles/profile_manager.h" |
32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
33 #include "chromeos/login/login_state.h" | 34 #include "chromeos/login/login_state.h" |
34 #include "chromeos/network/network_handler.h" | 35 #include "chromeos/network/network_handler.h" |
35 #include "chromeos/network/network_state_handler.h" | 36 #include "chromeos/network/network_state_handler.h" |
36 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
38 #include "extensions/browser/event_router.h" | 39 #include "extensions/browser/event_router.h" |
39 #include "webkit/common/fileapi/file_system_types.h" | 40 #include "webkit/common/fileapi/file_system_types.h" |
40 #include "webkit/common/fileapi/file_system_util.h" | 41 #include "webkit/common/fileapi/file_system_util.h" |
41 | 42 |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 scoped_ptr<extensions::Event> event(new extensions::Event( | 619 scoped_ptr<extensions::Event> event(new extensions::Event( |
619 extensions::event_names::kOnDirectoryChanged, args.Pass())); | 620 extensions::event_names::kOnDirectoryChanged, args.Pass())); |
620 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 621 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
621 DispatchEventToExtension(extension_id, event.Pass()); | 622 DispatchEventToExtension(extension_id, event.Pass()); |
622 } | 623 } |
623 } | 624 } |
624 | 625 |
625 void EventRouter::ShowRemovableDeviceInFileManager( | 626 void EventRouter::ShowRemovableDeviceInFileManager( |
626 const base::FilePath& mount_path) { | 627 const base::FilePath& mount_path) { |
627 // Do not attempt to open File Manager while the login is in progress or | 628 // Do not attempt to open File Manager while the login is in progress or |
628 // the screen is locked. | 629 // the screen is locked and make sure the file manager is opened only for the |
| 630 // active user. |
629 if (chromeos::LoginDisplayHostImpl::default_host() || | 631 if (chromeos::LoginDisplayHostImpl::default_host() || |
630 chromeos::ScreenLocker::default_screen_locker()) | 632 chromeos::ScreenLocker::default_screen_locker() || |
| 633 profile_ != ProfileManager::GetActiveUserProfile()) |
631 return; | 634 return; |
632 | 635 |
633 // According to DCF (Design rule of Camera File system) by JEITA / CP-3461 | 636 // According to DCF (Design rule of Camera File system) by JEITA / CP-3461 |
634 // cameras should have pictures located in the DCIM root directory. | 637 // cameras should have pictures located in the DCIM root directory. |
635 const base::FilePath dcim_path = mount_path.Append( | 638 const base::FilePath dcim_path = mount_path.Append( |
636 FILE_PATH_LITERAL("DCIM")); | 639 FILE_PATH_LITERAL("DCIM")); |
637 | 640 |
638 // If there is no DCIM folder or an external photo importer is not available, | 641 // If there is no DCIM folder or an external photo importer is not available, |
639 // then launch Files.app. | 642 // then launch Files.app. |
640 DirectoryExistsOnUIThread( | 643 DirectoryExistsOnUIThread( |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 void EventRouter::OnFormatCompleted(const std::string& device_path, | 759 void EventRouter::OnFormatCompleted(const std::string& device_path, |
757 bool success) { | 760 bool success) { |
758 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 761 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
759 DispatchDeviceEvent(success ? | 762 DispatchDeviceEvent(success ? |
760 file_browser_private::DEVICE_EVENT_TYPE_FORMAT_SUCCESS : | 763 file_browser_private::DEVICE_EVENT_TYPE_FORMAT_SUCCESS : |
761 file_browser_private::DEVICE_EVENT_TYPE_FORMAT_FAIL, | 764 file_browser_private::DEVICE_EVENT_TYPE_FORMAT_FAIL, |
762 device_path); | 765 device_path); |
763 } | 766 } |
764 | 767 |
765 } // namespace file_manager | 768 } // namespace file_manager |
OLD | NEW |