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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_mount.cc

Issue 23715003: Files.app: Rename the FileBrowserPrivateAPI's functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comments. Created 7 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_manager/private_api_mount.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_mount.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 9 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
10 #include "chrome/browser/chromeos/drive/file_system_interface.h" 10 #include "chrome/browser/chromeos/drive/file_system_interface.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 result->SetString("mountPath", "Downloads"); 61 result->SetString("mountPath", "Downloads");
62 result->SetString( 62 result->SetString(
63 "mountCondition", 63 "mountCondition",
64 DiskMountManager::MountConditionToString( 64 DiskMountManager::MountConditionToString(
65 chromeos::disks::MOUNT_CONDITION_NONE)); 65 chromeos::disks::MOUNT_CONDITION_NONE));
66 return result; 66 return result;
67 } 67 }
68 68
69 } // namespace 69 } // namespace
70 70
71 AddMountFunction::AddMountFunction() { 71 FileBrowserPrivateAddMountFunction::FileBrowserPrivateAddMountFunction() {
72 } 72 }
73 73
74 AddMountFunction::~AddMountFunction() { 74 FileBrowserPrivateAddMountFunction::~FileBrowserPrivateAddMountFunction() {
75 } 75 }
76 76
77 bool AddMountFunction::RunImpl() { 77 bool FileBrowserPrivateAddMountFunction::RunImpl() {
78 // The third argument is simply ignored. 78 // The third argument is simply ignored.
79 if (args_->GetSize() != 2 && args_->GetSize() != 3) { 79 if (args_->GetSize() != 2 && args_->GetSize() != 3) {
80 error_ = "Invalid argument count"; 80 error_ = "Invalid argument count";
81 return false; 81 return false;
82 } 82 }
83 83
84 std::string file_url; 84 std::string file_url;
85 if (!args_->GetString(0, &file_url)) { 85 if (!args_->GetString(0, &file_url)) {
86 return false; 86 return false;
87 } 87 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 drive::DriveIntegrationService* integration_service = 139 drive::DriveIntegrationService* integration_service =
140 drive::DriveIntegrationServiceFactory::GetForProfile(profile_); 140 drive::DriveIntegrationServiceFactory::GetForProfile(profile_);
141 drive::FileSystemInterface* file_system = 141 drive::FileSystemInterface* file_system =
142 integration_service ? integration_service->file_system() : NULL; 142 integration_service ? integration_service->file_system() : NULL;
143 if (!file_system) { 143 if (!file_system) {
144 SendResponse(false); 144 SendResponse(false);
145 break; 145 break;
146 } 146 }
147 file_system->MarkCacheFileAsMounted( 147 file_system->MarkCacheFileAsMounted(
148 drive::util::ExtractDrivePath(path), 148 drive::util::ExtractDrivePath(path),
149 base::Bind(&AddMountFunction::OnMountedStateSet, 149 base::Bind(&FileBrowserPrivateAddMountFunction::OnMountedStateSet,
150 this, mount_type_str, display_name)); 150 this, mount_type_str, display_name));
151 } else { 151 } else {
152 OnMountedStateSet(mount_type_str, display_name, 152 OnMountedStateSet(mount_type_str, display_name,
153 drive::FILE_ERROR_OK, path); 153 drive::FILE_ERROR_OK, path);
154 } 154 }
155 break; 155 break;
156 } 156 }
157 } 157 }
158 158
159 return true; 159 return true;
160 } 160 }
161 161
162 void AddMountFunction::OnMountedStateSet( 162 void FileBrowserPrivateAddMountFunction::OnMountedStateSet(
163 const std::string& mount_type, 163 const std::string& mount_type,
164 const base::FilePath::StringType& file_name, 164 const base::FilePath::StringType& file_name,
165 drive::FileError error, 165 drive::FileError error,
166 const base::FilePath& file_path) { 166 const base::FilePath& file_path) {
167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
168 168
169 if (error != drive::FILE_ERROR_OK) { 169 if (error != drive::FILE_ERROR_OK) {
170 SendResponse(false); 170 SendResponse(false);
171 return; 171 return;
172 } 172 }
173 173
174 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); 174 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
175 // Pass back the actual source path of the mount point. 175 // Pass back the actual source path of the mount point.
176 SetResult(new base::StringValue(file_path.value())); 176 SetResult(new base::StringValue(file_path.value()));
177 SendResponse(true); 177 SendResponse(true);
178 // MountPath() takes a std::string. 178 // MountPath() takes a std::string.
179 disk_mount_manager->MountPath( 179 disk_mount_manager->MountPath(
180 file_path.AsUTF8Unsafe(), base::FilePath(file_name).Extension(), 180 file_path.AsUTF8Unsafe(), base::FilePath(file_name).Extension(),
181 file_name, DiskMountManager::MountTypeFromString(mount_type)); 181 file_name, DiskMountManager::MountTypeFromString(mount_type));
182 } 182 }
183 183
184 RemoveMountFunction::RemoveMountFunction() { 184 FileBrowserPrivateRemoveMountFunction::FileBrowserPrivateRemoveMountFunction() {
185 } 185 }
186 186
187 RemoveMountFunction::~RemoveMountFunction() { 187 FileBrowserPrivateRemoveMountFunction::
188 ~FileBrowserPrivateRemoveMountFunction() {
188 } 189 }
189 190
190 bool RemoveMountFunction::RunImpl() { 191 bool FileBrowserPrivateRemoveMountFunction::RunImpl() {
191 if (args_->GetSize() != 1) { 192 if (args_->GetSize() != 1) {
192 return false; 193 return false;
193 } 194 }
194 195
195 std::string mount_path; 196 std::string mount_path;
196 if (!args_->GetString(0, &mount_path)) { 197 if (!args_->GetString(0, &mount_path)) {
197 return false; 198 return false;
198 } 199 }
199 200
200 drive::util::Log(logging::LOG_INFO, 201 drive::util::Log(logging::LOG_INFO,
201 "%s[%d] called. (mount_path: '%s')", 202 "%s[%d] called. (mount_path: '%s')",
202 name().c_str(), 203 name().c_str(),
203 request_id(), 204 request_id(),
204 mount_path.c_str()); 205 mount_path.c_str());
205 set_log_on_completion(true); 206 set_log_on_completion(true);
206 207
207 std::vector<GURL> file_paths; 208 std::vector<GURL> file_paths;
208 file_paths.push_back(GURL(mount_path)); 209 file_paths.push_back(GURL(mount_path));
209 file_manager::util::GetSelectedFileInfo( 210 file_manager::util::GetSelectedFileInfo(
210 render_view_host(), 211 render_view_host(),
211 profile(), 212 profile(),
212 file_paths, 213 file_paths,
213 file_manager::util::NEED_LOCAL_PATH_FOR_OPENING, 214 file_manager::util::NEED_LOCAL_PATH_FOR_OPENING,
214 base::Bind(&RemoveMountFunction::GetSelectedFileInfoResponse, this)); 215 base::Bind(&FileBrowserPrivateRemoveMountFunction::
216 GetSelectedFileInfoResponse, this));
215 return true; 217 return true;
216 } 218 }
217 219
218 void RemoveMountFunction::GetSelectedFileInfoResponse( 220 void FileBrowserPrivateRemoveMountFunction::GetSelectedFileInfoResponse(
219 const std::vector<ui::SelectedFileInfo>& files) { 221 const std::vector<ui::SelectedFileInfo>& files) {
220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
221 223
222 if (files.size() != 1) { 224 if (files.size() != 1) {
223 SendResponse(false); 225 SendResponse(false);
224 return; 226 return;
225 } 227 }
226 228
227 // TODO(tbarzic): Send response when callback is received, it would make more 229 // TODO(tbarzic): Send response when callback is received, it would make more
228 // sense than remembering issued unmount requests in file manager and showing 230 // sense than remembering issued unmount requests in file manager and showing
229 // errors for them when MountCompleted event is received. 231 // errors for them when MountCompleted event is received.
230 DiskMountManager::GetInstance()->UnmountPath( 232 DiskMountManager::GetInstance()->UnmountPath(
231 files[0].local_path.value(), 233 files[0].local_path.value(),
232 chromeos::UNMOUNT_OPTIONS_NONE, 234 chromeos::UNMOUNT_OPTIONS_NONE,
233 DiskMountManager::UnmountPathCallback()); 235 DiskMountManager::UnmountPathCallback());
234 SendResponse(true); 236 SendResponse(true);
235 } 237 }
236 238
237 GetMountPointsFunction::GetMountPointsFunction() { 239 FileBrowserPrivateGetMountPointsFunction::
240 FileBrowserPrivateGetMountPointsFunction() {
238 } 241 }
239 242
240 GetMountPointsFunction::~GetMountPointsFunction() { 243 FileBrowserPrivateGetMountPointsFunction::
244 ~FileBrowserPrivateGetMountPointsFunction() {
241 } 245 }
242 246
243 bool GetMountPointsFunction::RunImpl() { 247 bool FileBrowserPrivateGetMountPointsFunction::RunImpl() {
244 if (args_->GetSize()) 248 if (args_->GetSize())
245 return false; 249 return false;
246 250
247 base::ListValue *mounts = new base::ListValue(); 251 base::ListValue *mounts = new base::ListValue();
248 SetResult(mounts); 252 SetResult(mounts);
249 253
250 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); 254 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
251 DiskMountManager::MountPointMap mount_points = 255 DiskMountManager::MountPointMap mount_points =
252 disk_mount_manager->mount_points(); 256 disk_mount_manager->mount_points();
253 257
(...skipping 23 matching lines...) Expand all
277 name().c_str(), 281 name().c_str(),
278 request_id(), 282 request_id(),
279 log_string.c_str(), 283 log_string.c_str(),
280 mount_points.size()); 284 mount_points.size());
281 285
282 SendResponse(true); 286 SendResponse(true);
283 return true; 287 return true;
284 } 288 }
285 289
286 } // namespace extensions 290 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698