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

Side by Side Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 13042004: Fix crash of chrome.fileSystem.chooseEntry on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/api/file_system/file_system_api.h" 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 entry_type_(entry_type), 410 entry_type_(entry_type),
411 function_(function) { 411 function_(function) {
412 select_file_dialog_ = ui::SelectFileDialog::Create( 412 select_file_dialog_ = ui::SelectFileDialog::Create(
413 this, new ChromeSelectFilePolicy(web_contents)); 413 this, new ChromeSelectFilePolicy(web_contents));
414 gfx::NativeWindow owning_window = web_contents ? 414 gfx::NativeWindow owning_window = web_contents ?
415 platform_util::GetTopLevel(web_contents->GetView()->GetNativeView()) : 415 platform_util::GetTopLevel(web_contents->GetView()->GetNativeView()) :
416 NULL; 416 NULL;
417 417
418 if (g_skip_picker_for_test) { 418 if (g_skip_picker_for_test) {
419 if (g_path_to_be_picked_for_test) { 419 if (g_path_to_be_picked_for_test) {
420 ui::SelectedFileInfo selected_path(*g_path_to_be_picked_for_test,
421 base::FilePath());
422 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 420 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
423 base::Bind( 421 base::Bind(
424 &FileSystemChooseEntryFunction::FilePicker:: 422 &FileSystemChooseEntryFunction::FilePicker::FileSelected,
425 FileSelectedWithExtraInfo, 423 base::Unretained(this), *g_path_to_be_picked_for_test, 1,
426 base::Unretained(this), selected_path, 1,
427 static_cast<void*>(NULL))); 424 static_cast<void*>(NULL)));
428 } else { 425 } else {
429 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 426 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
430 base::Bind( 427 base::Bind(
431 &FileSystemChooseEntryFunction::FilePicker:: 428 &FileSystemChooseEntryFunction::FilePicker::
432 FileSelectionCanceled, 429 FileSelectionCanceled,
433 base::Unretained(this), static_cast<void*>(NULL))); 430 base::Unretained(this), static_cast<void*>(NULL)));
434 } 431 }
435 return; 432 return;
436 } 433 }
437 434
438 select_file_dialog_->SelectFile(picker_type, 435 select_file_dialog_->SelectFile(picker_type,
439 string16(), 436 string16(),
440 suggested_name, 437 suggested_name,
441 &file_type_info, 0, FILE_PATH_LITERAL(""), 438 &file_type_info, 0, FILE_PATH_LITERAL(""),
442 owning_window, NULL); 439 owning_window, NULL);
443 } 440 }
444 441
445 virtual ~FilePicker() {} 442 virtual ~FilePicker() {}
446 443
447 private: 444 private:
448 // ui::SelectFileDialog::Listener implementation. 445 // ui::SelectFileDialog::Listener implementation.
449 virtual void FileSelected(const base::FilePath& path, 446 virtual void FileSelected(const base::FilePath& path,
450 int index, 447 int index,
451 void* params) OVERRIDE { 448 void* params) OVERRIDE {
452 // The version taking ui::SelectedFileInfo should be used. 449 function_->FileSelected(path, entry_type_);
453 NOTREACHED(); 450 delete this;
454 } 451 }
455 452
456 virtual void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file, 453 virtual void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file,
457 int index, 454 int index,
458 void* params) OVERRIDE { 455 void* params) OVERRIDE {
459 // Normally, file.local_path is used because it is a native path to the 456 // Normally, file.local_path is used because it is a native path to the
460 // local read-only cached file in the case of remote file system like 457 // local read-only cached file in the case of remote file system like
461 // Chrome OS's Google Drive integration. Here, however, |file.file_path| is 458 // Chrome OS's Google Drive integration. Here, however, |file.file_path| is
462 // necessary because we need to create a FileEntry denoting the remote file, 459 // necessary because we need to create a FileEntry denoting the remote file,
463 // not its cache. On other platforms than Chrome OS, they are the same. 460 // not its cache. On other platforms than Chrome OS, they are the same.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 if (entry_type == WRITABLE && !HasFileSystemWritePermission()) { 642 if (entry_type == WRITABLE && !HasFileSystemWritePermission()) {
646 error_ = kRequiresFileSystemWriteError; 643 error_ = kRequiresFileSystemWriteError;
647 return false; 644 return false;
648 } 645 }
649 646
650 file_type_info.support_drive = true; 647 file_type_info.support_drive = true;
651 return ShowPicker(suggested_name, file_type_info, picker_type, entry_type); 648 return ShowPicker(suggested_name, file_type_info, picker_type, entry_type);
652 } 649 }
653 650
654 } // namespace extensions 651 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698