Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2483)

Unified Diff: chrome/browser/chromeos/extensions/file_browser_event_router.cc

Issue 10834115: Drive: Mount/Unmount GoogleDrive on Files App when the file system is mounted/unmounted. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..45a20773e21f9161d9a854d6306390959337b220 100644
--- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc
@@ -226,6 +226,44 @@ void FileBrowserEventRouter::RemoveFileWatch(
}
}
+void FileBrowserEventRouter::MountGData(
+ const base::Callback<void(bool)>& callback) {
satorux1 2012/08/01 20:59:01 add DCHECK(BrowserThread::CurrentlyOn(BrowserThrea
yoshiki 2012/08/01 22:23:39 Done.
+ gdata::GDataSystemService* system_service =
+ gdata::GDataSystemServiceFactory::GetForProfile(profile_);
+ if (system_service) {
+ system_service->docs_service()->Authenticate(
+ base::Bind(&FileBrowserEventRouter::OnGDataAuthentication,
+ this,
+ callback));
+ }
+}
+
+void FileBrowserEventRouter::OnGDataAuthentication(
+ const base::Callback<void(bool)>& callback,
+ gdata::GDataErrorCode error,
+ const std::string& token) {
satorux1 2012/08/01 20:59:01 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::U
yoshiki 2012/08/01 22:23:39 Done.
+ 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(true);
+}
+
void FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(bool start) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -416,6 +454,25 @@ void FileBrowserEventRouter::OnDocumentFeedFetched(
NULL, GURL());
}
+void FileBrowserEventRouter::OnFileSystemMounted() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ MountGData(base::Callback<void(bool)>()); // 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));

Powered by Google App Engine
This is Rietveld 408576698