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