OLD | NEW |
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/bookmarks/bookmarks_api.h" | 5 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 // There may be pending file dialogs, we need to tell them that we've gone | 739 // There may be pending file dialogs, we need to tell them that we've gone |
740 // away so they don't try and call back to us. | 740 // away so they don't try and call back to us. |
741 if (select_file_dialog_.get()) | 741 if (select_file_dialog_.get()) |
742 select_file_dialog_->ListenerDestroyed(); | 742 select_file_dialog_->ListenerDestroyed(); |
743 } | 743 } |
744 | 744 |
745 void BookmarksIOFunction::SelectFile(ui::SelectFileDialog::Type type) { | 745 void BookmarksIOFunction::SelectFile(ui::SelectFileDialog::Type type) { |
746 // GetDefaultFilepathForBookmarkExport() might have to touch the filesystem | 746 // GetDefaultFilepathForBookmarkExport() might have to touch the filesystem |
747 // (stat or access, for example), so this requires a thread with IO allowed. | 747 // (stat or access, for example), so this requires a thread with IO allowed. |
748 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { | 748 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
749 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 749 BrowserThread::PostTask( |
750 base::Bind(&BookmarksIOFunction::SelectFile, this, type)); | 750 BrowserThread::FILE, FROM_HERE, |
| 751 base::BindOnce(&BookmarksIOFunction::SelectFile, this, type)); |
751 return; | 752 return; |
752 } | 753 } |
753 | 754 |
754 // Pre-populating the filename field in case this is a SELECT_SAVEAS_FILE | 755 // Pre-populating the filename field in case this is a SELECT_SAVEAS_FILE |
755 // dialog. If not, there is no filename field in the dialog box. | 756 // dialog. If not, there is no filename field in the dialog box. |
756 base::FilePath default_path; | 757 base::FilePath default_path; |
757 if (type == ui::SelectFileDialog::SELECT_SAVEAS_FILE) | 758 if (type == ui::SelectFileDialog::SELECT_SAVEAS_FILE) |
758 default_path = GetDefaultFilepathForBookmarkExport(); | 759 default_path = GetDefaultFilepathForBookmarkExport(); |
759 else | 760 else |
760 DCHECK(type == ui::SelectFileDialog::SELECT_OPEN_FILE); | 761 DCHECK(type == ui::SelectFileDialog::SELECT_OPEN_FILE); |
761 | 762 |
762 // After getting the |default_path|, ask the UI to display the file dialog. | 763 // After getting the |default_path|, ask the UI to display the file dialog. |
763 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 764 BrowserThread::PostTask( |
764 base::Bind(&BookmarksIOFunction::ShowSelectFileDialog, this, | 765 BrowserThread::UI, FROM_HERE, |
765 type, default_path)); | 766 base::BindOnce(&BookmarksIOFunction::ShowSelectFileDialog, this, type, |
| 767 default_path)); |
766 } | 768 } |
767 | 769 |
768 void BookmarksIOFunction::ShowSelectFileDialog( | 770 void BookmarksIOFunction::ShowSelectFileDialog( |
769 ui::SelectFileDialog::Type type, | 771 ui::SelectFileDialog::Type type, |
770 const base::FilePath& default_path) { | 772 const base::FilePath& default_path) { |
771 if (!dispatcher()) | 773 if (!dispatcher()) |
772 return; // Extension was unloaded. | 774 return; // Extension was unloaded. |
773 | 775 |
774 // Balanced in one of the three callbacks of SelectFileDialog: | 776 // Balanced in one of the three callbacks of SelectFileDialog: |
775 // either FileSelectionCanceled, MultiFilesSelected, or FileSelected | 777 // either FileSelectionCanceled, MultiFilesSelected, or FileSelected |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 } | 841 } |
840 | 842 |
841 void BookmarksExportFunction::FileSelected(const base::FilePath& path, | 843 void BookmarksExportFunction::FileSelected(const base::FilePath& path, |
842 int index, | 844 int index, |
843 void* params) { | 845 void* params) { |
844 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); | 846 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); |
845 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 847 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
846 } | 848 } |
847 | 849 |
848 } // namespace extensions | 850 } // namespace extensions |
OLD | NEW |