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

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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 file_selector->SelectFile(suggested_name.BaseName(), GetCurrentBrowser()); 226 file_selector->SelectFile(suggested_name.BaseName(), GetCurrentBrowser());
227 return true; 227 return true;
228 } 228 }
229 229
230 void FileHandlerSelectFileFunction::CreateFileOnFileThread( 230 void FileHandlerSelectFileFunction::CreateFileOnFileThread(
231 bool success, 231 bool success,
232 const std::string& file_system_name, 232 const std::string& file_system_name,
233 const GURL& file_system_root) { 233 const GURL& file_system_root) {
234 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 234 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
235 235
236 if (success)
237 success = DoCreateFile();
kinaba 2012/06/28 05:52:34 (Not sure if this part is intended to be a part of
zel 2012/06/28 17:50:46 Yes, we have to remove this since file picker API
kinaba 2012/06/29 01:48:08 I see, but it changes the behavior of existing cod
238 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 236 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
239 base::Bind(&FileHandlerSelectFileFunction::OnFileCreated, this, 237 base::Bind(&FileHandlerSelectFileFunction::OnFileCreated, this,
240 success, file_system_name, file_system_root)); 238 success, file_system_name, file_system_root));
241 } 239 }
242 240
243 bool FileHandlerSelectFileFunction::DoCreateFile() {
244 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
245
246 // Don't allow links.
247 if (file_util::PathExists(full_path_) && file_util::IsLink(full_path_))
248 return false;
249
250 bool created = false;
251 base::PlatformFileError error = base::PLATFORM_FILE_OK;
252 int creation_flags = base::PLATFORM_FILE_CREATE_ALWAYS |
253 base::PLATFORM_FILE_READ |
254 base::PLATFORM_FILE_WRITE;
255 base::CreatePlatformFile(full_path_, creation_flags, &created, &error);
256 return error == base::PLATFORM_FILE_OK;
257 }
258
259 void FileHandlerSelectFileFunction::OnFileCreated( 241 void FileHandlerSelectFileFunction::OnFileCreated(
260 bool success, 242 bool success,
261 const std::string& file_system_name, 243 const std::string& file_system_name,
262 const GURL& file_system_root) { 244 const GURL& file_system_root) {
263 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 245 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
264 246
265 FilePath virtual_path; 247 FilePath virtual_path;
266 if (success) 248 if (success)
267 virtual_path = GrantPermissions(); 249 virtual_path = GrantPermissions();
268 Respond(success, file_system_name, file_system_root, virtual_path); 250 Respond(success, file_system_name, file_system_root, virtual_path);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 result->set_function_for_test(this); 297 result->set_function_for_test(this);
316 return result; 298 return result;
317 } 299 }
318 return new FileSelectorImpl(this); 300 return new FileSelectorImpl(this);
319 } 301 }
320 302
321 FileSelector* FileHandlerSelectFileFunction::file_selector_for_test_ = NULL; 303 FileSelector* FileHandlerSelectFileFunction::file_selector_for_test_ = NULL;
322 304
323 bool FileHandlerSelectFileFunction::gesture_check_disabled_for_test_ = false; 305 bool FileHandlerSelectFileFunction::gesture_check_disabled_for_test_ = false;
324 306
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698