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/bookmarks/bookmark_extension_api.h" | 5 #include "chrome/browser/bookmarks/bookmark_extension_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/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/bookmarks/bookmark_model.h" | 24 #include "chrome/browser/bookmarks/bookmark_model.h" |
25 #include "chrome/browser/bookmarks/bookmark_utils.h" | 25 #include "chrome/browser/bookmarks/bookmark_utils.h" |
26 #include "chrome/browser/extensions/extension_event_router.h" | 26 #include "chrome/browser/extensions/extension_event_router.h" |
27 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 27 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
28 #include "chrome/browser/extensions/extensions_quota_service.h" | 28 #include "chrome/browser/extensions/extensions_quota_service.h" |
29 #include "chrome/browser/importer/importer_data_types.h" | 29 #include "chrome/browser/importer/importer_data_types.h" |
30 #include "chrome/browser/importer/importer_host.h" | 30 #include "chrome/browser/importer/importer_host.h" |
31 #include "chrome/browser/prefs/pref_service.h" | 31 #include "chrome/browser/prefs/pref_service.h" |
32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
| 34 #include "chrome/browser/ui/chrome_select_file_policy.h" |
34 #include "chrome/common/chrome_notification_types.h" | 35 #include "chrome/common/chrome_notification_types.h" |
35 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
36 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
37 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
38 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
39 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
40 | 41 |
41 namespace keys = bookmark_extension_api_constants; | 42 namespace keys = bookmark_extension_api_constants; |
42 | 43 |
43 using base::TimeDelta; | 44 using base::TimeDelta; |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 869 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
869 base::Bind(&BookmarksIOFunction::ShowSelectFileDialog, this, | 870 base::Bind(&BookmarksIOFunction::ShowSelectFileDialog, this, |
870 type, default_path)); | 871 type, default_path)); |
871 } | 872 } |
872 | 873 |
873 void BookmarksIOFunction::ShowSelectFileDialog(SelectFileDialog::Type type, | 874 void BookmarksIOFunction::ShowSelectFileDialog(SelectFileDialog::Type type, |
874 const FilePath& default_path) { | 875 const FilePath& default_path) { |
875 // Balanced in one of the three callbacks of SelectFileDialog: | 876 // Balanced in one of the three callbacks of SelectFileDialog: |
876 // either FileSelectionCanceled, MultiFilesSelected, or FileSelected | 877 // either FileSelectionCanceled, MultiFilesSelected, or FileSelected |
877 AddRef(); | 878 AddRef(); |
878 select_file_dialog_ = SelectFileDialog::Create(this); | 879 |
| 880 WebContents* web_contents = dispatcher()->delegate()-> |
| 881 GetAssociatedWebContents(); |
| 882 |
| 883 select_file_dialog_ = SelectFileDialog::Create( |
| 884 this, new ChromeSelectFilePolicy(web_contents)); |
879 SelectFileDialog::FileTypeInfo file_type_info; | 885 SelectFileDialog::FileTypeInfo file_type_info; |
880 file_type_info.extensions.resize(1); | 886 file_type_info.extensions.resize(1); |
881 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); | 887 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); |
882 | 888 |
883 WebContents* web_contents = dispatcher()->delegate()-> | |
884 GetAssociatedWebContents(); | |
885 | |
886 // |tab_contents| can be NULL (for background pages), which is fine. In such | 889 // |tab_contents| can be NULL (for background pages), which is fine. In such |
887 // a case if file-selection dialogs are forbidden by policy, we will not | 890 // a case if file-selection dialogs are forbidden by policy, we will not |
888 // show an InfoBar, which is better than letting one appear out of the blue. | 891 // show an InfoBar, which is better than letting one appear out of the blue. |
889 select_file_dialog_->SelectFile(type, | 892 select_file_dialog_->SelectFile(type, |
890 string16(), | 893 string16(), |
891 default_path, | 894 default_path, |
892 &file_type_info, | 895 &file_type_info, |
893 0, | 896 0, |
894 FILE_PATH_LITERAL(""), | 897 FILE_PATH_LITERAL(""), |
895 web_contents, | |
896 NULL, | 898 NULL, |
897 NULL); | 899 NULL); |
898 } | 900 } |
899 | 901 |
900 void BookmarksIOFunction::FileSelectionCanceled(void* params) { | 902 void BookmarksIOFunction::FileSelectionCanceled(void* params) { |
901 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 903 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
902 } | 904 } |
903 | 905 |
904 void BookmarksIOFunction::MultiFilesSelected( | 906 void BookmarksIOFunction::MultiFilesSelected( |
905 const std::vector<FilePath>& files, void* params) { | 907 const std::vector<FilePath>& files, void* params) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 int index, | 945 int index, |
944 void* params) { | 946 void* params) { |
945 #if !defined(OS_ANDROID) | 947 #if !defined(OS_ANDROID) |
946 // Android does not have support for the standard exporter. | 948 // Android does not have support for the standard exporter. |
947 // TODO(jgreenwald): remove ifdef once extensions are no longer built on | 949 // TODO(jgreenwald): remove ifdef once extensions are no longer built on |
948 // Android. | 950 // Android. |
949 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 951 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
950 #endif | 952 #endif |
951 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 953 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
952 } | 954 } |
OLD | NEW |