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

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 return false;
1093 }
1094
1095 std::string mount_type_str;
1096 if (!args_->GetString(1, &mount_type_str)) {
1097 return false;
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::MountPathOptions::value_type((*it).c_str(),
1128 value.c_str()));
1129 }
1130 }
1131
1132 mount_lib->MountPath(source.c_str(), mount_type, options);
1133 #endif
1134
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 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()->UnmountPath(
1096 volume_device_path.c_str()); 1156 mount_path.c_str());
1097 #endif 1157 #endif
1098 1158
1099 SendResponse(true); 1159 SendResponse(true);
1100 return true; 1160 return true;
1101 } 1161 }
1102 1162
1163 GetMountPointsFunction::GetMountPointsFunction() {
1164 }
1165
1166 GetMountPointsFunction::~GetMountPointsFunction() {
1167 }
1168
1169 bool GetMountPointsFunction::RunImpl() {
1170 if (args_->GetSize() != 0)
1171 return false;
1172
1173 #ifdef OS_CHROMEOS
1174 chromeos::MountLibrary *mount_lib =
1175 chromeos::CrosLibrary::Get()->GetMountLibrary();
1176 chromeos::MountLibrary::MountPointMap mount_points =
1177 mount_lib->mount_points();
1178
1179 base::DictionaryValue *mounts = new base::DictionaryValue();
1180
1181 for (chromeos::MountLibrary::MountPointMap::const_iterator it =
1182 mount_points.begin();
1183 it != mount_points.end();
1184 ++it) {
1185 chromeos::MountLibrary::MountPointInfo mount_point_info = it->second;
1186
1187 mounts->Set(mount_point_info.mount_path,
1188 MountPointToValue(mount_point_info, mount_lib));
1189 }
1190
1191 result_.reset(mounts);
1192 #endif
1193
1194 return true;
1195 }
1196
1197 #ifdef OS_CHROMEOS
1198 base::DictionaryValue* GetMountPointsFunction::MountPointToValue(
1199 const chromeos::MountLibrary::MountPointInfo& mount_point_info,
1200 chromeos::MountLibrary* mount_lib) {
1201
1202 base::DictionaryValue *mount_info = new base::DictionaryValue();
1203
1204 mount_info->SetString("mountPath", mount_point_info.mount_path);
1205 mount_info->SetString(
1206 "mountType",
1207 mount_lib->MountTypeToString(mount_point_info.mount_type));
1208 mount_info->SetString("sourcePath", mount_point_info.source_path);
1209 return mount_info;
1210 }
1211 #endif
1212
1103 GetVolumeMetadataFunction::GetVolumeMetadataFunction() { 1213 GetVolumeMetadataFunction::GetVolumeMetadataFunction() {
1104 } 1214 }
1105 1215
1106 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() { 1216 GetVolumeMetadataFunction::~GetVolumeMetadataFunction() {
1107 } 1217 }
1108 1218
1109 bool GetVolumeMetadataFunction::RunImpl() { 1219 bool GetVolumeMetadataFunction::RunImpl() {
1110 if (args_->GetSize() != 1) { 1220 if (args_->GetSize() != 1) {
1111 error_ = "Invalid argument count"; 1221 error_ = "Invalid argument count";
1112 return false; 1222 return false;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 #undef SET_STRING 1361 #undef SET_STRING
1252 1362
1253 // TODO(serya): Create a new string in .grd file for this one in M13. 1363 // TODO(serya): Create a new string in .grd file for this one in M13.
1254 dict->SetString("PREVIEW_IMAGE", 1364 dict->SetString("PREVIEW_IMAGE",
1255 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); 1365 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON));
1256 dict->SetString("PLAY_MEDIA", 1366 dict->SetString("PLAY_MEDIA",
1257 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); 1367 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY));
1258 1368
1259 return true; 1369 return true;
1260 } 1370 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698