Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/file_browser_event_router.cc |
| diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc |
| index 4431f9dcaeef1f15f6bef881bbf519510c561d50..1dd4c5916f8c4e7605b4c5bbf4241c4ffe6b0033 100644 |
| --- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc |
| +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc |
| @@ -226,6 +226,48 @@ void FileBrowserEventRouter::RemoveFileWatch( |
| } |
| } |
| +void FileBrowserEventRouter::MountDrive( |
| + const base::Closure& callback) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + gdata::GDataSystemService* system_service = |
| + gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| + if (system_service) { |
| + system_service->docs_service()->Authenticate( |
| + base::Bind(&FileBrowserEventRouter::OnDriveAuthentication, |
|
satorux1
2012/08/02 01:13:05
OnAuthenticated
yoshiki
2012/08/02 05:53:42
Done.
|
| + this, |
| + callback)); |
| + } |
| +} |
| + |
| +void FileBrowserEventRouter::OnDriveAuthentication( |
| + const base::Closure& callback, |
| + gdata::GDataErrorCode error, |
| + const std::string& token) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + chromeos::MountError error_code; |
| + // For the file manager to work offline, GDATA_NO_CONNECTION is allowed. |
| + if (error == gdata::HTTP_SUCCESS || error == gdata::GDATA_NO_CONNECTION) |
| + error_code = chromeos::MOUNT_ERROR_NONE; |
| + else |
| + error_code = chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; |
| + |
| + // Pass back the gdata mount point path as source path. |
| + const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); |
| + DiskMountManager::MountPointInfo mount_info( |
| + gdata_path, |
| + gdata_path, |
| + chromeos::MOUNT_TYPE_GDATA, |
| + chromeos::disks::MOUNT_CONDITION_NONE); |
| + |
| + // Raise mount event. |
| + MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); |
| + |
| + if (!callback.is_null()) |
| + callback.Run(); |
| +} |
| + |
| void FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(bool start) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| @@ -416,6 +458,26 @@ void FileBrowserEventRouter::OnDocumentFeedFetched( |
| NULL, GURL()); |
| } |
| +void FileBrowserEventRouter::OnFileSystemMounted() { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + MountDrive(base::Bind(&base::DoNothing)); // Callback does nothing. |
| +} |
| + |
| +void FileBrowserEventRouter::OnFileSystemUnmounting() { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + // Raise a MountCompleted event to notify the File Manager. |
| + const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); |
| + DiskMountManager::MountPointInfo mount_info( |
| + gdata_path, |
| + gdata_path, |
| + chromeos::MOUNT_TYPE_GDATA, |
| + chromeos::disks::MOUNT_CONDITION_NONE); |
| + MountCompleted(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, |
| + mount_info); |
| +} |
| + |
| void FileBrowserEventRouter::OnAuthenticationFailed() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |