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 20 matching lines...) Expand all Loading... | |
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/browser/profiles/profile_manager.h" |
33 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
34 #include "chromeos/login/login_state.h" | 34 #include "chromeos/login/login_state.h" |
35 #include "chromeos/network/network_handler.h" | 35 #include "chromeos/network/network_handler.h" |
36 #include "chromeos/network/network_state_handler.h" | 36 #include "chromeos/network/network_state_handler.h" |
37 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
38 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
39 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
40 #include "extensions/browser/event_router.h" | 40 #include "extensions/browser/event_router.h" |
41 #include "extensions/browser/extension_prefs.h" | |
41 #include "extensions/browser/extension_system.h" | 42 #include "extensions/browser/extension_system.h" |
42 #include "webkit/common/fileapi/file_system_types.h" | 43 #include "webkit/common/fileapi/file_system_types.h" |
43 #include "webkit/common/fileapi/file_system_util.h" | 44 #include "webkit/common/fileapi/file_system_util.h" |
44 | 45 |
45 using chromeos::disks::DiskMountManager; | 46 using chromeos::disks::DiskMountManager; |
46 using chromeos::NetworkHandler; | 47 using chromeos::NetworkHandler; |
47 using content::BrowserThread; | 48 using content::BrowserThread; |
48 using drive::DriveIntegrationService; | 49 using drive::DriveIntegrationService; |
49 using drive::DriveIntegrationServiceFactory; | 50 using drive::DriveIntegrationServiceFactory; |
50 | 51 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 // JavaScript does not have 64-bit integers. Instead we use double, which | 114 // JavaScript does not have 64-bit integers. Instead we use double, which |
114 // is in IEEE 754 formant and accurate up to 52-bits in JS, and in practice | 115 // is in IEEE 754 formant and accurate up to 52-bits in JS, and in practice |
115 // in C++. Larger values are rounded. | 116 // in C++. Larger values are rounded. |
116 status->processed.reset( | 117 status->processed.reset( |
117 new double(static_cast<double>(job_info.num_completed_bytes))); | 118 new double(static_cast<double>(job_info.num_completed_bytes))); |
118 status->total.reset( | 119 status->total.reset( |
119 new double(static_cast<double>(job_info.num_total_bytes))); | 120 new double(static_cast<double>(job_info.num_total_bytes))); |
120 } | 121 } |
121 | 122 |
122 // Checks for availability of the Google+ Photos app. | 123 // Checks for availability of the Google+ Photos app. |
124 // TODO(mtomasz): Replace with crbug.com/341902 solution. | |
123 bool IsGooglePhotosInstalled(Profile *profile) { | 125 bool IsGooglePhotosInstalled(Profile *profile) { |
124 ExtensionService* service = | 126 ExtensionService* service = |
125 extensions::ExtensionSystem::Get(profile)->extension_service(); | 127 extensions::ExtensionSystem::Get(profile)->extension_service(); |
126 if (!service) | 128 if (!service) |
127 return false; | 129 return false; |
128 | 130 |
129 // Google+ Photos uses several ids for different channels. Therefore, all of | 131 // Google+ Photos uses several ids for different channels. Therefore, all of |
130 // them should be checked. | 132 // them should be checked. |
131 const std::string kGooglePlusPhotosIds[] = { | 133 const std::string kGooglePlusPhotosIds[] = { |
132 "ebpbnabdhheoknfklmpddcdijjkmklkp", // G+ Photos staging | 134 "ebpbnabdhheoknfklmpddcdijjkmklkp", // G+ Photos staging |
133 "efjnaogkjbogokcnohkmnjdojkikgobo", // G+ Photos prod | 135 "efjnaogkjbogokcnohkmnjdojkikgobo", // G+ Photos prod |
134 "ejegoaikibpmikoejfephaneibodccma" // G+ Photos dev | 136 "ejegoaikibpmikoejfephaneibodccma" // G+ Photos dev |
135 }; | 137 }; |
136 | 138 |
137 for (size_t i = 0; i < arraysize(kGooglePlusPhotosIds); ++i) { | 139 for (size_t i = 0; i < arraysize(kGooglePlusPhotosIds); ++i) { |
138 if (service->GetExtensionById(kGooglePlusPhotosIds[i], | 140 if (service->GetExtensionById(kGooglePlusPhotosIds[i], |
139 false /* include_disable */) != NULL) | 141 false /* include_disable */) != NULL) |
140 return true; | 142 return true; |
141 } | 143 } |
142 | 144 |
143 return false; | 145 return false; |
144 } | 146 } |
145 | 147 |
148 // Checks if the Recovery Tool is running. This is a temporary solution. | |
149 // TODO(mtomasz): Replace with crbug.com/341902 solution. | |
150 bool IsRecoveryToolRunning(Profile* profile) { | |
151 ExtensionService* service = | |
152 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
153 if (!service) | |
154 return false; | |
155 extensions::ExtensionPrefs* extension_prefs = service->extension_prefs(); | |
156 if (!extension_prefs) | |
157 return false; | |
158 | |
159 const std::string kRecoveryToolIds[] = { | |
160 "kkebgepbbgbcmghedmmdfcbdcodlkngh", // Recovert tool staging | |
161 "jndclpdbaamdhonoechobihbbiimdgai" // Recovery tool prod | |
162 }; | |
163 | |
164 for (size_t i = 0; i < arraysize(kRecoveryToolIds); ++i) { | |
165 const std::string extension_id = kRecoveryToolIds[i]; | |
166 if (service->GetExtensionById(extension_id, false /* include_disable */) != | |
167 NULL) { | |
168 if (extension_prefs->IsExtensionRunning(extension_id)) | |
169 return true; | |
170 } | |
171 } | |
172 | |
173 return false; | |
174 } | |
175 | |
146 // Sends an event named |event_name| with arguments |event_args| to extensions. | 176 // Sends an event named |event_name| with arguments |event_args| to extensions. |
147 void BroadcastEvent(Profile* profile, | 177 void BroadcastEvent(Profile* profile, |
148 const std::string& event_name, | 178 const std::string& event_name, |
149 scoped_ptr<base::ListValue> event_args) { | 179 scoped_ptr<base::ListValue> event_args) { |
150 extensions::ExtensionSystem::Get(profile)->event_router()-> | 180 extensions::ExtensionSystem::Get(profile)->event_router()-> |
151 BroadcastEvent(make_scoped_ptr( | 181 BroadcastEvent(make_scoped_ptr( |
152 new extensions::Event(event_name, event_args.Pass()))); | 182 new extensions::Event(event_name, event_args.Pass()))); |
153 } | 183 } |
154 | 184 |
155 file_browser_private::MountCompletedStatus | 185 file_browser_private::MountCompletedStatus |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 const base::FilePath& mount_path) { | 713 const base::FilePath& mount_path) { |
684 // Do not attempt to open File Manager while the login is in progress or | 714 // Do not attempt to open File Manager while the login is in progress or |
685 // the screen is locked or running in kiosk app mode and make sure the file | 715 // the screen is locked or running in kiosk app mode and make sure the file |
686 // manager is opened only for the active user. | 716 // manager is opened only for the active user. |
687 if (chromeos::LoginDisplayHostImpl::default_host() || | 717 if (chromeos::LoginDisplayHostImpl::default_host() || |
688 chromeos::ScreenLocker::default_screen_locker() || | 718 chromeos::ScreenLocker::default_screen_locker() || |
689 chrome::IsRunningInForcedAppMode() || | 719 chrome::IsRunningInForcedAppMode() || |
690 profile_ != ProfileManager::GetActiveUserProfile()) | 720 profile_ != ProfileManager::GetActiveUserProfile()) |
691 return; | 721 return; |
692 | 722 |
723 // Do not pop-up the File Manager, if the recovery tool is running. | |
724 if (IsRecoveryToolRunning(profile_)) | |
725 return; | |
726 | |
693 // According to DCF (Design rule of Camera File system) by JEITA / CP-3461 | 727 // According to DCF (Design rule of Camera File system) by JEITA / CP-3461 |
694 // cameras should have pictures located in the DCIM root directory. | 728 // cameras should have pictures located in the DCIM root directory. |
695 const base::FilePath dcim_path = mount_path.Append( | 729 const base::FilePath dcim_path = mount_path.Append( |
696 FILE_PATH_LITERAL("DCIM")); | 730 FILE_PATH_LITERAL("DCIM")); |
697 | 731 |
698 // If there is no DCIM folder or an external photo importer is not available, | 732 // If there is a DCIM folder and Google+ Photos is installed, then do not |
699 // then launch Files.app. | 733 // launch Files.app. Also, do not show Files app, if the recovery tool is |
734 // running. | |
kinaba
2014/02/19 09:10:20
The comment "Also, do not show Files app, if the r
mtomasz
2014/02/19 09:37:48
Done.
| |
700 DirectoryExistsOnUIThread( | 735 DirectoryExistsOnUIThread( |
701 dcim_path, | 736 dcim_path, |
702 IsGooglePhotosInstalled(profile_) ? | 737 IsGooglePhotosInstalled(profile_) |
703 base::Bind(&base::DoNothing) : | 738 ? base::Bind(&base::DoNothing) |
704 base::Bind(&util::OpenRemovableDrive, profile_, mount_path), | 739 : base::Bind(&util::OpenRemovableDrive, profile_, mount_path), |
705 base::Bind(&util::OpenRemovableDrive, profile_, mount_path)); | 740 base::Bind(&util::OpenRemovableDrive, profile_, mount_path)); |
706 } | 741 } |
707 | 742 |
708 void EventRouter::DispatchDeviceEvent( | 743 void EventRouter::DispatchDeviceEvent( |
709 file_browser_private::DeviceEventType type, | 744 file_browser_private::DeviceEventType type, |
710 const std::string& device_path) { | 745 const std::string& device_path) { |
711 file_browser_private::DeviceEvent event; | 746 file_browser_private::DeviceEvent event; |
712 event.type = type; | 747 event.type = type; |
713 event.device_path = device_path; | 748 event.device_path = device_path; |
714 BroadcastEvent(profile_, | 749 BroadcastEvent(profile_, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 } | 879 } |
845 } | 880 } |
846 | 881 |
847 void EventRouter::OnOwnerEntryChanged(aura::Window* window) { | 882 void EventRouter::OnOwnerEntryChanged(aura::Window* window) { |
848 BroadcastEvent(profile_, | 883 BroadcastEvent(profile_, |
849 file_browser_private::OnDesktopChanged::kEventName, | 884 file_browser_private::OnDesktopChanged::kEventName, |
850 file_browser_private::OnDesktopChanged::Create()); | 885 file_browser_private::OnDesktopChanged::Create()); |
851 } | 886 } |
852 | 887 |
853 } // namespace file_manager | 888 } // namespace file_manager |
OLD | NEW |