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

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_private_api.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: Remove unused methods in mock_gdata_file_system.h Created 8 years, 4 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 unified diff | Download patch
OLDNEW
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_private_api.h" 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/string_split.h" 14 #include "base/string_split.h"
16 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
17 #include "base/time.h" 16 #include "base/time.h"
18 #include "base/values.h" 17 #include "base/values.h"
19 #include "chrome/browser/chromeos/cros/cros_library.h" 18 #include "chrome/browser/chromeos/cros/cros_library.h"
20 #include "chrome/browser/chromeos/cros/network_library.h" 19 #include "chrome/browser/chromeos/cros/network_library.h"
21 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" 20 #include "chrome/browser/chromeos/disks/disk_mount_manager.h"
22 #include "chrome/browser/chromeos/extensions/file_handler_util.h" 21 #include "chrome/browser/chromeos/extensions/file_handler_util.h"
23 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 22 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
24 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" 23 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h"
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 1081
1083 chromeos::MountType mount_type = 1082 chromeos::MountType mount_type =
1084 DiskMountManager::MountTypeFromString(mount_type_str); 1083 DiskMountManager::MountTypeFromString(mount_type_str);
1085 switch (mount_type) { 1084 switch (mount_type) {
1086 case chromeos::MOUNT_TYPE_INVALID: { 1085 case chromeos::MOUNT_TYPE_INVALID: {
1087 error_ = "Invalid mount type"; 1086 error_ = "Invalid mount type";
1088 SendResponse(false); 1087 SendResponse(false);
1089 break; 1088 break;
1090 } 1089 }
1091 case chromeos::MOUNT_TYPE_GDATA: { 1090 case chromeos::MOUNT_TYPE_GDATA: {
1092 gdata::GDataSystemService* system_service = 1091 const bool success = true;
1093 gdata::GDataSystemServiceFactory::GetForProfile(profile_); 1092 FileBrowserEventRouterFactory::GetForProfile(profile_)->
1094 if (system_service) { 1093 MountDrive(base::Bind(&AddMountFunction::SendResponse,
1095 system_service->docs_service()->Authenticate( 1094 this,
1096 base::Bind(&AddMountFunction::OnGDataAuthentication, 1095 success));
1097 this));
1098 }
1099 break; 1096 break;
1100 } 1097 }
1101 default: { 1098 default: {
1102 UrlList file_paths; 1099 UrlList file_paths;
1103 file_paths.push_back(GURL(file_url)); 1100 file_paths.push_back(GURL(file_url));
1104 1101
1105 GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( 1102 GetLocalPathsOnFileThreadAndRunCallbackOnUIThread(
1106 file_paths, 1103 file_paths,
1107 base::Bind(&AddMountFunction::GetLocalPathsResponseOnUIThread, 1104 base::Bind(&AddMountFunction::GetLocalPathsResponseOnUIThread,
1108 this, 1105 this,
1109 mount_type_str)); 1106 mount_type_str));
1110 break; 1107 break;
1111 } 1108 }
1112 } 1109 }
1113 1110
1114 return true; 1111 return true;
1115 } 1112 }
1116 1113
1117 void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) {
1118 chromeos::MountError error_code = chromeos::MOUNT_ERROR_NONE;
1119 // For the file manager to work offline, GDATA_NO_CONNECTION is allowed.
1120 if (error == gdata::HTTP_SUCCESS || error == gdata::GDATA_NO_CONNECTION) {
1121 error_code = chromeos::MOUNT_ERROR_NONE;
1122 } else {
1123 error_code = chromeos::MOUNT_ERROR_NOT_AUTHENTICATED;
1124 }
1125 // Pass back the gdata mount point path as source path.
1126 const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString();
1127 SetResult(Value::CreateStringValue(gdata_path));
1128 DiskMountManager::MountPointInfo mount_info(
1129 gdata_path,
1130 gdata_path,
1131 chromeos::MOUNT_TYPE_GDATA,
1132 chromeos::disks::MOUNT_CONDITION_NONE);
1133 // Raise mount event
1134 FileBrowserEventRouterFactory::GetForProfile(profile_)->
1135 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info);
1136 }
1137
1138 void AddMountFunction::OnGDataAuthentication(gdata::GDataErrorCode error,
1139 const std::string& token) {
1140 RaiseGDataMountEvent(error);
1141 SendResponse(true);
1142 }
1143
1144 void AddMountFunction::GetLocalPathsResponseOnUIThread( 1114 void AddMountFunction::GetLocalPathsResponseOnUIThread(
1145 const std::string& mount_type_str, 1115 const std::string& mount_type_str,
1146 const SelectedFileInfoList& files) { 1116 const SelectedFileInfoList& files) {
1147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1148 1118
1149 if (!files.size()) { 1119 if (!files.size()) {
1150 SendResponse(false); 1120 SendResponse(false);
1151 return; 1121 return;
1152 } 1122 }
1153 1123
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 gdata::GDataSystemService* system_service = 2384 gdata::GDataSystemService* system_service =
2415 gdata::GDataSystemServiceFactory::GetForProfile(profile_); 2385 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
2416 if (!system_service || !system_service->file_system()) 2386 if (!system_service || !system_service->file_system())
2417 return false; 2387 return false;
2418 2388
2419 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); 2389 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string));
2420 system_service->file_system()->RequestDirectoryRefresh(directory_path); 2390 system_service->file_system()->RequestDirectoryRefresh(directory_path);
2421 2391
2422 return true; 2392 return true;
2423 } 2393 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.h ('k') | chrome/browser/chromeos/gdata/gdata_file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698