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_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/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 const std::string& extension_id) { | 165 const std::string& extension_id) { |
166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
167 | 167 |
168 base::AutoLock lock(lock_); | 168 base::AutoLock lock(lock_); |
169 FilePath watch_path = local_path; | 169 FilePath watch_path = local_path; |
170 bool is_remote_watch = false; | 170 bool is_remote_watch = false; |
171 // Tweak watch path for remote sources - we need to drop leading /special | 171 // Tweak watch path for remote sources - we need to drop leading /special |
172 // directory from there in order to be able to pair these events with | 172 // directory from there in order to be able to pair these events with |
173 // their change notifications. | 173 // their change notifications. |
174 if (gdata::util::GetSpecialRemoteRootPath().IsParent(watch_path)) { | 174 if (gdata::util::GetSpecialRemoteRootPath().IsParent(watch_path)) { |
175 watch_path = gdata::util::ExtractGDataPath(watch_path); | 175 watch_path = gdata::util::ExtractDrivePath(watch_path); |
176 is_remote_watch = true; | 176 is_remote_watch = true; |
177 BrowserThread::PostTask( | 177 BrowserThread::PostTask( |
178 BrowserThread::UI, FROM_HERE, | 178 BrowserThread::UI, FROM_HERE, |
179 base::Bind(&FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread, | 179 base::Bind(&FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread, |
180 this, true)); | 180 this, true)); |
181 } | 181 } |
182 | 182 |
183 WatcherMap::iterator iter = file_watchers_.find(watch_path); | 183 WatcherMap::iterator iter = file_watchers_.find(watch_path); |
184 if (iter == file_watchers_.end()) { | 184 if (iter == file_watchers_.end()) { |
185 scoped_ptr<FileWatcherExtensions> | 185 scoped_ptr<FileWatcherExtensions> |
(...skipping 15 matching lines...) Expand all Loading... |
201 const FilePath& local_path, | 201 const FilePath& local_path, |
202 const std::string& extension_id) { | 202 const std::string& extension_id) { |
203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
204 | 204 |
205 base::AutoLock lock(lock_); | 205 base::AutoLock lock(lock_); |
206 FilePath watch_path = local_path; | 206 FilePath watch_path = local_path; |
207 // Tweak watch path for remote sources - we need to drop leading /special | 207 // Tweak watch path for remote sources - we need to drop leading /special |
208 // directory from there in order to be able to pair these events with | 208 // directory from there in order to be able to pair these events with |
209 // their change notifications. | 209 // their change notifications. |
210 if (gdata::util::GetSpecialRemoteRootPath().IsParent(watch_path)) { | 210 if (gdata::util::GetSpecialRemoteRootPath().IsParent(watch_path)) { |
211 watch_path = gdata::util::ExtractGDataPath(watch_path); | 211 watch_path = gdata::util::ExtractDrivePath(watch_path); |
212 BrowserThread::PostTask( | 212 BrowserThread::PostTask( |
213 BrowserThread::UI, FROM_HERE, | 213 BrowserThread::UI, FROM_HERE, |
214 base::Bind(&FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread, | 214 base::Bind(&FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread, |
215 this, false)); | 215 this, false)); |
216 } | 216 } |
217 WatcherMap::iterator iter = file_watchers_.find(watch_path); | 217 WatcherMap::iterator iter = file_watchers_.find(watch_path); |
218 if (iter == file_watchers_.end()) | 218 if (iter == file_watchers_.end()) |
219 return; | 219 return; |
220 // Remove the renderer process for this watch. | 220 // Remove the renderer process for this watch. |
221 iter->second->RemoveExtension(extension_id); | 221 iter->second->RemoveExtension(extension_id); |
(...skipping 24 matching lines...) Expand all Loading... |
246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
247 | 247 |
248 chromeos::MountError error_code; | 248 chromeos::MountError error_code; |
249 // For the file manager to work offline, GDATA_NO_CONNECTION is allowed. | 249 // For the file manager to work offline, GDATA_NO_CONNECTION is allowed. |
250 if (error == gdata::HTTP_SUCCESS || error == gdata::GDATA_NO_CONNECTION) | 250 if (error == gdata::HTTP_SUCCESS || error == gdata::GDATA_NO_CONNECTION) |
251 error_code = chromeos::MOUNT_ERROR_NONE; | 251 error_code = chromeos::MOUNT_ERROR_NONE; |
252 else | 252 else |
253 error_code = chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; | 253 error_code = chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; |
254 | 254 |
255 // Pass back the gdata mount point path as source path. | 255 // Pass back the gdata mount point path as source path. |
256 const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); | 256 const std::string& gdata_path = gdata::util::GetDriveMountPointPathAsString(); |
257 DiskMountManager::MountPointInfo mount_info( | 257 DiskMountManager::MountPointInfo mount_info( |
258 gdata_path, | 258 gdata_path, |
259 gdata_path, | 259 gdata_path, |
260 chromeos::MOUNT_TYPE_GDATA, | 260 chromeos::MOUNT_TYPE_GDATA, |
261 chromeos::disks::MOUNT_CONDITION_NONE); | 261 chromeos::disks::MOUNT_CONDITION_NONE); |
262 | 262 |
263 // Raise mount event. | 263 // Raise mount event. |
264 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); | 264 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); |
265 | 265 |
266 if (!callback.is_null()) | 266 if (!callback.is_null()) |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 void FileBrowserEventRouter::OnFileSystemMounted() { | 452 void FileBrowserEventRouter::OnFileSystemMounted() { |
453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
454 | 454 |
455 MountDrive(base::Bind(&base::DoNothing)); // Callback does nothing. | 455 MountDrive(base::Bind(&base::DoNothing)); // Callback does nothing. |
456 } | 456 } |
457 | 457 |
458 void FileBrowserEventRouter::OnFileSystemBeingUnmounted() { | 458 void FileBrowserEventRouter::OnFileSystemBeingUnmounted() { |
459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
460 | 460 |
461 // Raise a MountCompleted event to notify the File Manager. | 461 // Raise a MountCompleted event to notify the File Manager. |
462 const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); | 462 const std::string& gdata_path = gdata::util::GetDriveMountPointPathAsString(); |
463 DiskMountManager::MountPointInfo mount_info( | 463 DiskMountManager::MountPointInfo mount_info( |
464 gdata_path, | 464 gdata_path, |
465 gdata_path, | 465 gdata_path, |
466 chromeos::MOUNT_TYPE_GDATA, | 466 chromeos::MOUNT_TYPE_GDATA, |
467 chromeos::disks::MOUNT_CONDITION_NONE); | 467 chromeos::disks::MOUNT_CONDITION_NONE); |
468 MountCompleted(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, | 468 MountCompleted(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, |
469 mount_info); | 469 mount_info); |
470 } | 470 } |
471 | 471 |
472 void FileBrowserEventRouter::OnAuthenticationFailed() { | 472 void FileBrowserEventRouter::OnAuthenticationFailed() { |
473 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 473 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
474 | 474 |
475 // Raise a MountCompleted event to notify the File Manager. | 475 // Raise a MountCompleted event to notify the File Manager. |
476 const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); | 476 const std::string& gdata_path = gdata::util::GetDriveMountPointPathAsString(); |
477 DiskMountManager::MountPointInfo mount_info( | 477 DiskMountManager::MountPointInfo mount_info( |
478 gdata_path, | 478 gdata_path, |
479 gdata_path, | 479 gdata_path, |
480 chromeos::MOUNT_TYPE_GDATA, | 480 chromeos::MOUNT_TYPE_GDATA, |
481 chromeos::disks::MOUNT_CONDITION_NONE); | 481 chromeos::disks::MOUNT_CONDITION_NONE); |
482 MountCompleted(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, | 482 MountCompleted(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, |
483 mount_info); | 483 mount_info); |
484 } | 484 } |
485 | 485 |
486 void FileBrowserEventRouter::HandleFileWatchNotification( | 486 void FileBrowserEventRouter::HandleFileWatchNotification( |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 return scoped_refptr<RefcountedProfileKeyedService>( | 860 return scoped_refptr<RefcountedProfileKeyedService>( |
861 new FileBrowserEventRouter(profile)); | 861 new FileBrowserEventRouter(profile)); |
862 } | 862 } |
863 | 863 |
864 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const { | 864 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const { |
865 // Explicitly and always allow this router in guest login mode. see | 865 // Explicitly and always allow this router in guest login mode. see |
866 // chrome/browser/profiles/profile_keyed_base_factory.h comment | 866 // chrome/browser/profiles/profile_keyed_base_factory.h comment |
867 // for the details. | 867 // for the details. |
868 return true; | 868 return true; |
869 } | 869 } |
OLD | NEW |