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

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_handler_api.cc

Issue 10600013: Wired support for file truncating with RemoteFileSystemOperation::OpenFile() method (case when base… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 unified diff | Download patch | Annotate | Revision Log
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_handler_api.h" 5 #include "chrome/browser/chromeos/extensions/file_browser_handler_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 file_selector->SelectFile(suggested_name.BaseName(), GetCurrentBrowser()); 230 file_selector->SelectFile(suggested_name.BaseName(), GetCurrentBrowser());
231 return true; 231 return true;
232 } 232 }
233 233
234 void FileHandlerSelectFileFunction::CreateFileOnFileThread( 234 void FileHandlerSelectFileFunction::CreateFileOnFileThread(
235 bool success, 235 bool success,
236 const std::string& file_system_name, 236 const std::string& file_system_name,
237 const GURL& file_system_root) { 237 const GURL& file_system_root) {
238 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 238 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
239 239
240 if (success)
241 success = DoCreateFile();
242 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 240 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
243 base::Bind(&FileHandlerSelectFileFunction::OnFileCreated, this, 241 base::Bind(&FileHandlerSelectFileFunction::OnFileCreated, this,
244 success, file_system_name, file_system_root)); 242 success, file_system_name, file_system_root));
245 } 243 }
246 244
247 bool FileHandlerSelectFileFunction::DoCreateFile() {
248 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
249
250 // Don't allow links.
251 if (file_util::PathExists(full_path_) && file_util::IsLink(full_path_))
252 return false;
253
254 bool created = false;
255 base::PlatformFileError error = base::PLATFORM_FILE_OK;
256 int creation_flags = base::PLATFORM_FILE_CREATE_ALWAYS |
257 base::PLATFORM_FILE_READ |
258 base::PLATFORM_FILE_WRITE;
259 base::CreatePlatformFile(full_path_, creation_flags, &created, &error);
260 return error == base::PLATFORM_FILE_OK;
261 }
262
263 void FileHandlerSelectFileFunction::OnFileCreated( 245 void FileHandlerSelectFileFunction::OnFileCreated(
264 bool success, 246 bool success,
265 const std::string& file_system_name, 247 const std::string& file_system_name,
266 const GURL& file_system_root) { 248 const GURL& file_system_root) {
267 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 249 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
268 250
269 FilePath virtual_path; 251 FilePath virtual_path;
270 if (success) 252 if (success)
271 virtual_path = GrantPermissions(); 253 virtual_path = GrantPermissions();
272 Respond(success, file_system_name, file_system_root, virtual_path); 254 Respond(success, file_system_name, file_system_root, virtual_path);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 result->set_function_for_test(this); 301 result->set_function_for_test(this);
320 return result; 302 return result;
321 } 303 }
322 return new FileSelectorImpl(this); 304 return new FileSelectorImpl(this);
323 } 305 }
324 306
325 FileSelector* FileHandlerSelectFileFunction::file_selector_for_test_ = NULL; 307 FileSelector* FileHandlerSelectFileFunction::file_selector_for_test_ = NULL;
326 308
327 bool FileHandlerSelectFileFunction::gesture_check_disabled_for_test_ = false; 309 bool FileHandlerSelectFileFunction::gesture_check_disabled_for_test_ = false;
328 310
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_handler_api.h ('k') | chrome/browser/chromeos/gdata/gdata_file_system_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698