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/prefs/public/pref_change_registrar.h" | 10 #include "base/prefs/public/pref_change_registrar.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 void FileBrowserEventRouter::MountDrive( | 238 void FileBrowserEventRouter::MountDrive( |
239 const base::Closure& callback) { | 239 const base::Closure& callback) { |
240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
241 | 241 |
242 // Pass back the gdata mount point path as source path. | 242 // Pass back the gdata mount point path as source path. |
243 const std::string& gdata_path = drive::util::GetDriveMountPointPathAsString(); | 243 const std::string& gdata_path = drive::util::GetDriveMountPointPathAsString(); |
244 DiskMountManager::MountPointInfo mount_info( | 244 DiskMountManager::MountPointInfo mount_info( |
245 gdata_path, | 245 gdata_path, |
246 gdata_path, | 246 gdata_path, |
247 chromeos::MOUNT_TYPE_GDATA, | 247 chromeos::MOUNT_TYPE_GOOGLE_DRIVE, |
248 chromeos::disks::MOUNT_CONDITION_NONE); | 248 chromeos::disks::MOUNT_CONDITION_NONE); |
249 | 249 |
250 // Raise mount event. | 250 // Raise mount event. |
251 // We can pass chromeos::MOUNT_ERROR_NONE even when authentication is failed | 251 // We can pass chromeos::MOUNT_ERROR_NONE even when authentication is failed |
252 // or network is unreachable. These two errors will be handled later. | 252 // or network is unreachable. These two errors will be handled later. |
253 OnMountEvent(DiskMountManager::MOUNTING, | 253 OnMountEvent(DiskMountManager::MOUNTING, |
254 chromeos::MOUNT_ERROR_NONE, | 254 chromeos::MOUNT_ERROR_NONE, |
255 mount_info); | 255 mount_info); |
256 | 256 |
257 if (!callback.is_null()) | 257 if (!callback.is_null()) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 } | 447 } |
448 | 448 |
449 void FileBrowserEventRouter::OnFileSystemBeingUnmounted() { | 449 void FileBrowserEventRouter::OnFileSystemBeingUnmounted() { |
450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
451 | 451 |
452 // Raise a mount event to notify the File Manager. | 452 // Raise a mount event to notify the File Manager. |
453 const std::string& gdata_path = drive::util::GetDriveMountPointPathAsString(); | 453 const std::string& gdata_path = drive::util::GetDriveMountPointPathAsString(); |
454 DiskMountManager::MountPointInfo mount_info( | 454 DiskMountManager::MountPointInfo mount_info( |
455 gdata_path, | 455 gdata_path, |
456 gdata_path, | 456 gdata_path, |
457 chromeos::MOUNT_TYPE_GDATA, | 457 chromeos::MOUNT_TYPE_GOOGLE_DRIVE, |
458 chromeos::disks::MOUNT_CONDITION_NONE); | 458 chromeos::disks::MOUNT_CONDITION_NONE); |
459 OnMountEvent(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, | 459 OnMountEvent(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, |
460 mount_info); | 460 mount_info); |
461 } | 461 } |
462 | 462 |
463 void FileBrowserEventRouter::OnAuthenticationFailed( | 463 void FileBrowserEventRouter::OnAuthenticationFailed( |
464 google_apis::GDataErrorCode error) { | 464 google_apis::GDataErrorCode error) { |
465 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 465 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
466 | 466 |
467 if (error == google_apis::GDATA_NO_CONNECTION) | 467 if (error == google_apis::GDATA_NO_CONNECTION) |
468 return; | 468 return; |
469 | 469 |
470 // Raise a mount event to notify the File Manager. | 470 // Raise a mount event to notify the File Manager. |
471 const std::string& gdata_path = drive::util::GetDriveMountPointPathAsString(); | 471 const std::string& gdata_path = drive::util::GetDriveMountPointPathAsString(); |
472 DiskMountManager::MountPointInfo mount_info( | 472 DiskMountManager::MountPointInfo mount_info( |
473 gdata_path, | 473 gdata_path, |
474 gdata_path, | 474 gdata_path, |
475 chromeos::MOUNT_TYPE_GDATA, | 475 chromeos::MOUNT_TYPE_GOOGLE_DRIVE, |
476 chromeos::disks::MOUNT_CONDITION_NONE); | 476 chromeos::disks::MOUNT_CONDITION_NONE); |
477 OnMountEvent(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, | 477 OnMountEvent(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, |
478 mount_info); | 478 mount_info); |
479 } | 479 } |
480 | 480 |
481 void FileBrowserEventRouter::HandleFileWatchNotification( | 481 void FileBrowserEventRouter::HandleFileWatchNotification( |
482 const FilePath& local_path, bool got_error) { | 482 const FilePath& local_path, bool got_error) { |
483 base::AutoLock lock(lock_); | 483 base::AutoLock lock(lock_); |
484 WatcherMap::const_iterator iter = file_watchers_.find(local_path); | 484 WatcherMap::const_iterator iter = file_watchers_.find(local_path); |
485 if (iter == file_watchers_.end()) { | 485 if (iter == file_watchers_.end()) { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |