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

Side by Side Diff: chrome/browser/extensions/extension_file_browser_private_api.cc

Issue 7457001: Adding support for mount point different from removable devices to MountLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_file_browser_private_api.h" 5 #include "chrome/browser/extensions/extension_file_browser_private_api.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 SendResponse(true); 1068 SendResponse(true);
1069 } 1069 }
1070 1070
1071 bool CancelFileDialogFunction::RunImpl() { 1071 bool CancelFileDialogFunction::RunImpl() {
1072 int32 tab_id = GetTabId(); 1072 int32 tab_id = GetTabId();
1073 FileManagerDialog::OnFileSelectionCanceled(tab_id); 1073 FileManagerDialog::OnFileSelectionCanceled(tab_id);
1074 SendResponse(true); 1074 SendResponse(true);
1075 return true; 1075 return true;
1076 } 1076 }
1077 1077
1078 UnmountVolumeFunction::UnmountVolumeFunction() { 1078 AddMountFunction::AddMountFunction() {
1079 } 1079 }
1080 1080
1081 UnmountVolumeFunction::~UnmountVolumeFunction() { 1081 AddMountFunction::~AddMountFunction() {
1082 } 1082 }
1083 1083
1084 bool UnmountVolumeFunction::RunImpl() { 1084 bool AddMountFunction::RunImpl() {
1085 if (args_->GetSize() != 2 && args_->GetSize() != 3) {
1086 error_ = "Invalid argument count";
1087 return false;
1088 }
1089
1090 std::string source;
1091 if (!args_->GetString(0, &source)) {
1092 NOTREACHED();
zel 2011/07/22 23:50:42 change NOTREACHED() in this function to this inste
1093 }
1094
1095 std::string mount_type_str;
1096 if (!args_->GetString(1, &mount_type_str)) {
1097 NOTREACHED();
1098 }
1099
1100 #ifdef OS_CHROMEOS
1101 chromeos::MountLibrary *mount_lib =
1102 chromeos::CrosLibrary::Get()->GetMountLibrary();
1103
1104 chromeos::MountType mount_type =
1105 mount_lib->MountTypeFromString(mount_type_str);
1106 if (mount_type == chromeos::MOUNT_TYPE_INVALID) {
1107 error_ = "Invalid mount type";
1108 return false;
1109 }
1110
1111 chromeos::MountPathOptions options;
1112
1113 if (args_->GetSize() == 3) {
1114 DictionaryValue *dict;
1115 if (!args_->GetDictionary(2, &dict)) {
1116 NOTREACHED();
1117 }
1118
1119 for (base::DictionaryValue::key_iterator it = dict->begin_keys();
1120 it != dict->end_keys();
1121 ++it) {
1122 std::string value;
1123 if (!dict->GetString(*it, &value)) {
1124 NOTREACHED();
1125 }
1126
1127 options.push_back(chromeos::MountPointOptions::value_type(*it, value));
1128 }
1129 }
1130
1131 mount_lib->Mount(source.c_str(), mount_type, options);
1132 #endif
1133
1134 SendResponse(true);
zel 2011/07/22 23:50:42 If this class derives from SyncExtensionFunction c
1135 return true;
1136 }
1137
1138 RemoveMountFunction::RemoveMountFunction() {
1139 }
1140
1141 RemoveMountFunction::~RemoveMountFunction() {
1142 }
1143
1144 bool RemoveMountFunction::RunImpl() {
1085 if (args_->GetSize() != 1) { 1145 if (args_->GetSize() != 1) {
1086 return false; 1146 return false;
1087 } 1147 }
1088 1148
1089 std::string volume_device_path; 1149 std::string mount_path;
1090 if (!args_->GetString(0, &volume_device_path)) { 1150 if (!args_->GetString(0, &mount_path)) {
1091 NOTREACHED(); 1151 NOTREACHED();
zel 2011/07/22 23:50:42 replace NOTREACHED(); with return false;
1092 } 1152 }
1093 1153
1094 #ifdef OS_CHROMEOS 1154 #ifdef OS_CHROMEOS
1095 chromeos::CrosLibrary::Get()->GetMountLibrary()->UnmountPath( 1155 chromeos::CrosLibrary::Get()->GetMountLibrary()->RemoveMount(
1096 volume_device_path.c_str()); 1156 mount_path.c_str());
1157 #endif
1158
1159 SendResponse(true);
1160 return true;
1161 }
1162
1163 GetMountPointsFunction::GetMountPointsFunction() {
1164 }
1165
1166 GetMountPointsFunction::~GetMountPointsFunction() {
1167 }
1168
1169 bool GetMountPointsFunction::RunImpl() {
1170 if (args_->GetSize() != 0) {
zel 2011/07/22 23:50:42 nit: {}
1171 return false;
1172 }
1173
1174 #ifdef OS_CHROMEOS
1175 chromeos::MountLibrary *mount_lib =
1176 chromeos::CrosLibrary::Get()->GetMountLibrary();
1177 chromeos::MountLibrary::MountPointMap mount_points =
1178 mount_lib->mount_points();
1179
1180 base::DictionaryValue *mounts = new base::DictionaryValue();
1181
1182 for (chromeos::MountLibrary::MountPointMap::const_iterator it =
1183 mount_points.begin();
1184 it != mount_points.end();
1185 ++it) {
1186 chromeos::MountLibrary::MountPointInfo mount_point_info = it->second;
1187 base::DictionaryValue *mount_info = new base::DictionaryValue();
zel 2011/07/22 23:50:42 make a helper function MountPointInfoToValue() for
1188
1189 mount_info->SetString("mountPath", mount_point_info.mount_path);
1190 mount_info->SetString(
1191 "mountType",
1192 mount_lib->MountTypeToString(mount_point_info.mount_type));
1193 mount_info->SetString("sourcePath", mount_point_info.source_path);
1194
1195 mounts->Set(mount_point_info.mount_path, mount_info);
1196 }
1197
1198 result_.reset(mounts);
1097 #endif 1199 #endif
1098 1200
1099 SendResponse(true); 1201 SendResponse(true);
1100 return true; 1202 return true;
1101 } 1203 }
1102 1204
1103 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { 1205 GetVolumeMetadataFunction::GetVolumeMetadataFunction() {
1104 } 1206 }
1105 1207
1106 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { 1208 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 case chromeos::OPTICAL: 1260 case chromeos::OPTICAL:
1159 return kVolumeTypeOptical; 1261 return kVolumeTypeOptical;
1160 case chromeos::HDD: 1262 case chromeos::HDD:
1161 return kVolumeTypeHardDrive; 1263 return kVolumeTypeHardDrive;
1162 default: 1264 default:
1163 break; 1265 break;
1164 } 1266 }
1165 return kVolumeTypeUnknown; 1267 return kVolumeTypeUnknown;
1166 } 1268 }
1167 #endif 1269 #endif
1270 /*
1271 MountVolumeFunction::MountVolumeFunction() {
zel 2011/07/22 23:50:42 remove this one, it's commented out anyway
1272 }
1168 1273
1274 MountVolumeFunction::~MountVolumeFunction() {
1275 }
1276
1277 void MountCompleted() {
1278 SendResponce(error_code == NO_ERROR);
1279 }
1280
1281 bool MountVolumeFunction::RunImpl() {
1282 if (args_->GetSize() != 1) {
1283 return false;
1284 }
1285
1286 std::string volume_device_path;
1287 if (!args_->GetString(0, &volume_device_path)) {
1288 NOTREACHED();
1289 }
1290
1291 bool success = false;
1292 #ifdef OS_CHROMEOS
1293 // success = chromeos::CrosLibrary::Get()->GetMountLibrary()->MountDevice(
1294 // volume_device_path.c_str(), type, options, this);
1295 #endif
1296
1297 if (success)
1298 SendResponse(success);
1299 return success;
1300 }
1301 */
1169 bool FileDialogStringsFunction::RunImpl() { 1302 bool FileDialogStringsFunction::RunImpl() {
1170 result_.reset(new DictionaryValue()); 1303 result_.reset(new DictionaryValue());
1171 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); 1304 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get());
1172 1305
1173 #define SET_STRING(ns, id) \ 1306 #define SET_STRING(ns, id) \
1174 dict->SetString(#id, l10n_util::GetStringUTF16(ns##_##id)) 1307 dict->SetString(#id, l10n_util::GetStringUTF16(ns##_##id))
1175 1308
1176 SET_STRING(IDS, WEB_FONT_FAMILY); 1309 SET_STRING(IDS, WEB_FONT_FAMILY);
1177 SET_STRING(IDS, WEB_FONT_SIZE); 1310 SET_STRING(IDS, WEB_FONT_SIZE);
1178 1311
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 #undef SET_STRING 1384 #undef SET_STRING
1252 1385
1253 // TODO(serya): Create a new string in .grd file for this one in M13. 1386 // TODO(serya): Create a new string in .grd file for this one in M13.
1254 dict->SetString("PREVIEW_IMAGE", 1387 dict->SetString("PREVIEW_IMAGE",
1255 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); 1388 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON));
1256 dict->SetString("PLAY_MEDIA", 1389 dict->SetString("PLAY_MEDIA",
1257 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); 1390 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY));
1258 1391
1259 return true; 1392 return true;
1260 } 1393 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698