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" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/sha1.h" | 13 #include "base/sha1.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/bookmarks/bookmark_codec.h" | 20 #include "chrome/browser/bookmarks/bookmark_codec.h" |
21 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h" | 21 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h" |
22 #include "chrome/browser/bookmarks/bookmark_extension_helpers.h" | 22 #include "chrome/browser/bookmarks/bookmark_extension_helpers.h" |
23 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 23 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
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/chrome_select_file_policy.h" |
26 #include "chrome/browser/extensions/extension_event_router.h" | 27 #include "chrome/browser/extensions/extension_event_router.h" |
27 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 28 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
28 #include "chrome/browser/extensions/extensions_quota_service.h" | 29 #include "chrome/browser/extensions/extensions_quota_service.h" |
29 #include "chrome/browser/importer/importer_data_types.h" | 30 #include "chrome/browser/importer/importer_data_types.h" |
30 #include "chrome/browser/importer/importer_host.h" | 31 #include "chrome/browser/importer/importer_host.h" |
31 #include "chrome/browser/prefs/pref_service.h" | 32 #include "chrome/browser/prefs/pref_service.h" |
32 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/ui/browser_list.h" | 34 #include "chrome/browser/ui/browser_list.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" |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 SelectFileDialog::FileTypeInfo file_type_info; | 880 SelectFileDialog::FileTypeInfo file_type_info; |
880 file_type_info.extensions.resize(1); | 881 file_type_info.extensions.resize(1); |
881 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); | 882 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); |
882 | 883 |
883 WebContents* web_contents = dispatcher()->delegate()-> | 884 WebContents* web_contents = dispatcher()->delegate()-> |
884 GetAssociatedWebContents(); | 885 GetAssociatedWebContents(); |
885 | 886 |
886 // |tab_contents| can be NULL (for background pages), which is fine. In such | 887 // |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 | 888 // 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. | 889 // show an InfoBar, which is better than letting one appear out of the blue. |
889 select_file_dialog_->SelectFile(type, | 890 select_file_dialog_->SelectFile( |
890 string16(), | 891 type, |
891 default_path, | 892 string16(), |
892 &file_type_info, | 893 default_path, |
893 0, | 894 &file_type_info, |
894 FILE_PATH_LITERAL(""), | 895 0, |
895 web_contents, | 896 FILE_PATH_LITERAL(""), |
896 NULL, | 897 ChromeSelectFilePolicy::DisplayInfobarCallback(web_contents), |
897 NULL); | 898 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) { |
906 Release(); // Balanced in BookmarsIOFunction::SelectFile() | 908 Release(); // Balanced in BookmarsIOFunction::SelectFile() |
907 NOTREACHED() << "Should not be able to select multiple files"; | 909 NOTREACHED() << "Should not be able to select multiple files"; |
(...skipping 35 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 |